Skip to content

Commit e8160cf

Browse files
committed
Add NumberUtils - getPercentage and chance
1 parent b8fc077 commit e8160cf

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ shadowJar {
88
}
99

1010
group 'me.dkim19375'
11-
version '2.0.0'
11+
version '2.1.0'
1212

1313
repositories {
1414
mavenCentral()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package me.dkim19375.dkim19375core;
2+
3+
public class NumberUtils {
4+
public static long getPercentage(long lower, long max) {
5+
return (lower * 100) / max;
6+
}
7+
8+
public static double getPercentageDouble(double lower, double max) {
9+
return (lower * 100) / max;
10+
}
11+
12+
public static boolean percentChance(float chance) {
13+
return Math.random() <= chance;
14+
}
15+
16+
public static boolean percentChance(int chance) {
17+
return Math.random() <= chance;
18+
}
19+
}

0 commit comments

Comments
 (0)