From c34294c48c9c81ddf74ab334b2abe68f94e4ceb1 Mon Sep 17 00:00:00 2001 From: Zontreck Date: Sun, 11 Feb 2024 21:55:30 -0700 Subject: [PATCH] Add a newer math helper --- .../dev/zontreck/ariaslib/util/MathUtil.java | 18 ++++++++++++++++++ .../dev/zontreck/ariaslib/util/Percent.java | 1 + .../dev/zontreck/ariaslib/util/Progress.java | 1 + 3 files changed, 20 insertions(+) create mode 100644 src/main/java/dev/zontreck/ariaslib/util/MathUtil.java diff --git a/src/main/java/dev/zontreck/ariaslib/util/MathUtil.java b/src/main/java/dev/zontreck/ariaslib/util/MathUtil.java new file mode 100644 index 0000000..63df89f --- /dev/null +++ b/src/main/java/dev/zontreck/ariaslib/util/MathUtil.java @@ -0,0 +1,18 @@ +package dev.zontreck.ariaslib.util; + +/** + * This class will be used to house math helper functions + */ +public class MathUtil +{ + /** + * A newer helper function to get the percentage with large number support + * @param current Min value + * @param max Maximum value for progress + * @return Percentage + */ + public static int getPercent(long current, long max) + { + return Math.round(current*100/max); + } +} diff --git a/src/main/java/dev/zontreck/ariaslib/util/Percent.java b/src/main/java/dev/zontreck/ariaslib/util/Percent.java index 3b51a2b..da4b2ab 100644 --- a/src/main/java/dev/zontreck/ariaslib/util/Percent.java +++ b/src/main/java/dev/zontreck/ariaslib/util/Percent.java @@ -2,6 +2,7 @@ package dev.zontreck.ariaslib.util; import java.io.PrintStream; +@Deprecated public class Percent { int current; diff --git a/src/main/java/dev/zontreck/ariaslib/util/Progress.java b/src/main/java/dev/zontreck/ariaslib/util/Progress.java index a0d6670..c2fc89e 100644 --- a/src/main/java/dev/zontreck/ariaslib/util/Progress.java +++ b/src/main/java/dev/zontreck/ariaslib/util/Progress.java @@ -2,6 +2,7 @@ package dev.zontreck.ariaslib.util; import java.util.concurrent.atomic.AtomicInteger; +@Deprecated public class Progress { private int maximum;