2022-05-04 12:18:07 +00:00
|
|
|
package dev.plex.util;
|
|
|
|
|
2022-05-10 05:08:45 +00:00
|
|
|
import net.kyori.adventure.text.format.NamedTextColor;
|
2022-05-04 12:18:07 +00:00
|
|
|
|
2023-03-08 20:26:10 +00:00
|
|
|
import java.util.concurrent.ThreadLocalRandom;
|
|
|
|
|
2022-05-04 12:18:07 +00:00
|
|
|
public class RandomUtil
|
|
|
|
{
|
|
|
|
public static NamedTextColor getRandomColor()
|
|
|
|
{
|
|
|
|
NamedTextColor[] colors = NamedTextColor.NAMES.values().stream().filter(namedTextColor -> namedTextColor != NamedTextColor.BLACK && namedTextColor != NamedTextColor.DARK_BLUE).toArray(NamedTextColor[]::new);
|
|
|
|
return colors[randomNum(colors.length)];
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean randomBoolean()
|
|
|
|
{
|
|
|
|
return ThreadLocalRandom.current().nextBoolean();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int randomNum()
|
|
|
|
{
|
|
|
|
return ThreadLocalRandom.current().nextInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int randomNum(int limit)
|
|
|
|
{
|
|
|
|
return ThreadLocalRandom.current().nextInt(limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int randomNum(int start, int limit)
|
|
|
|
{
|
|
|
|
return ThreadLocalRandom.current().nextInt(start, limit);
|
|
|
|
}
|
|
|
|
}
|