Increase randomness by updating the random's seed every minute

This commit is contained in:
2022-12-20 22:15:52 +01:00
parent 264a94fe0d
commit ba64c02049
4 changed files with 31 additions and 4 deletions

View File

@@ -1,12 +1,11 @@
package wtf.beatrice.hidekobot.util;
import wtf.beatrice.hidekobot.Cache;
import java.util.Random;
public class RandomUtil
{
private static final Random random = new Random();
/**
* Returns a random integer picked in a range.
*
@@ -29,7 +28,7 @@ public class RandomUtil
int difference = (max - min) + 1;
// find a number between 0 and our range (eg. 5 -> 8 = 0 -> 3)
int randomTemp = random.nextInt(difference);
int randomTemp = Cache.getRandom().nextInt(difference);
// add the minimum value, so we are sure to be in the original range (0->5, 1->6, 2->7, 3->8)
return randomTemp + min;