mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-25 10:14:43 +02:00
Use ThreadedLocalRandom for RNG utils
This commit is contained in:
@ -13,6 +13,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class RandomChanceUtil
|
||||
{
|
||||
@ -78,9 +79,7 @@ public class RandomChanceUtil
|
||||
}
|
||||
|
||||
public static boolean rollDice(double chanceOfSuccess, int bound) {
|
||||
Random random = new Random();
|
||||
|
||||
return chanceOfSuccess > random.nextInt(bound);
|
||||
return chanceOfSuccess > ThreadLocalRandom.current().nextInt(bound);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,8 +99,6 @@ public class RandomChanceUtil
|
||||
{
|
||||
double chanceOfSuccess = calculateChanceOfSuccess(randomChance);
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
//Check the odds
|
||||
return rollDice(chanceOfSuccess, 100);
|
||||
}
|
||||
|
Reference in New Issue
Block a user