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

@@ -14,6 +14,7 @@ import wtf.beatrice.hidekobot.util.Logger;
import java.awt.*;
import java.lang.reflect.Field;
import java.time.LocalDateTime;
import java.util.Random;
public class Cache
{
@@ -23,6 +24,10 @@ public class Cache
private static final String botPrefix = "hideko";
private static final Logger logger = new Logger(Cache.class);
// the Random instance that we should always use when looking for an RNG based thing.
// the seed is updated periodically.
private static final Random randomInstance = new Random();
private static PropertiesSource propertiesSource = null;
private static ConfigurationSource configurationSource = null;
private static DatabaseSource databaseSource = null;
@@ -60,6 +65,14 @@ public class Cache
*/
public static int[] getSupportedAvatarResolutions() { return supportedAvatarResolutions; }
public static Random getRandom() {
return randomInstance;
}
public static void setRandomSeed(long seed) {
randomInstance.setSeed(seed);
}
/**
* Checks if the bot has been started with the verbose argument.
*