package tools; import org.bukkit.Location; import org.bukkit.World; import java.util.Random; public class RandomUtil { public static boolean random(double d) { return d >= new Random().nextFloat(); } public static int getRandomInt(int min, int max) { if (min == max) { return max; } Random r = new Random(); int i = min < max ? min : max; int a = min < max ? max : min; return r.nextInt(a - i + 1) + i; } public static double getRandomDouble(double min, double max, int scl) { int pow = (int) Math.pow(10, scl); return Math.floor((Math.random() * (max - min) + min) * pow) / pow; } public static Location getRandomLocation(World world, double minX, double maxX, double minY, double maxY, double minZ, double maxZ) { double rx = getRandomDouble(minX, maxX, 3); double ry = getRandomDouble(minY, maxY, 3); double rz = getRandomDouble(minZ, maxZ, 3); return new Location(world, rx, ry, rz); } }