Replaced All Instances of Random With SplittableRandom

SplittableRandom is faster (negligable) than Random and is also able to recursively return new instances of itself for an even more complex pseudo random generator compared to the default Random supplied by Java.
This commit is contained in:
Paldiu
2020-12-25 15:57:10 -05:00
parent dec35f76e4
commit eb9759f2d8
8 changed files with 18 additions and 18 deletions

View File

@ -21,7 +21,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.SplittableRandom;
import java.util.Set;
import java.util.TimeZone;
import java.util.UUID;
@ -85,7 +85,7 @@ public class FUtil
ChatColor.DARK_BLUE,
ChatColor.DARK_PURPLE,
ChatColor.LIGHT_PURPLE);
private static final Random RANDOM = new Random();
private static final SplittableRandom RANDOM = new SplittableRandom();
private static final String CHARACTER_STRING = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
private static final Map<Integer, String> TIMEZONE_LOOKUP = new HashMap<>();
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
@ -721,7 +721,7 @@ public class FUtil
public static char getRandomCharacter()
{
return CHARACTER_STRING.charAt(new Random().nextInt(CHARACTER_STRING.length()));
return CHARACTER_STRING.charAt(new SplittableRandom().nextInt(CHARACTER_STRING.length()));
}
public static void give(Player player, Material material, String coloredName, int amount, String... lore)