Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] RandomUtils percentageChance method validation always fails #2

Closed
WakelessSloth56 opened this issue Feb 13, 2022 · 1 comment
Closed
Assignees
Labels
Projects

Comments

@WakelessSloth56
Copy link
Collaborator

Caused by: java.lang.IllegalArgumentException: The left bound must be less than the right bound
        at org.apache.commons.lang3.Validate.isTrue(Validate.java:158) ~[commons-lang3-3.12.0.jar%2318!/:3.12.0]
        at org.auioc.mods.arnicalib.utils.java.Validate.isBoundedInterval(Validate.java:143) ~[%2381!/:?]
        at org.auioc.mods.arnicalib.utils.java.Validate.isInCloseInterval(Validate.java:181) ~[%2381!/:?]
        at org.auioc.mods.arnicalib.utils.java.RandomUtils.percentageChance(RandomUtils.java:73) ~[%2381!/:?]
@WakelessSloth56 WakelessSloth56 self-assigned this Feb 13, 2022
@WakelessSloth56 WakelessSloth56 added this to Needs triage in Bug via automation Feb 13, 2022
@WakelessSloth56
Copy link
Collaborator Author

public static boolean percentageChance(int chance) {
Validate.isInCloseInterval(chance, 0, 100);
return nextInt(0, 100) < chance;
}
public static boolean percentageChance(int chance, Random random) {
Validate.isInCloseInterval(chance, 0, 100);
return random.nextInt(100) < chance;
}

public static void isInCloseInterval(long left, long right, long value) {

isInCloseInterval method parameter order should be left bound, right bound, value.

@WakelessSloth56 WakelessSloth56 moved this from Needs triage to High priority in Bug Feb 13, 2022
Bug automation moved this from High priority to Closed Feb 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Bug
  
Closed
Development

No branches or pull requests

1 participant