From 5eaaeec6804e54e18e763775a19597634581f5fe Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Tue, 3 Mar 2015 23:03:58 +0100 Subject: [PATCH] Minor IntervalUtil tweaks. --- .../massivecore/util/IntervalUtil.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/com/massivecraft/massivecore/util/IntervalUtil.java b/src/com/massivecraft/massivecore/util/IntervalUtil.java index 6abe37bf..8d7d63ba 100644 --- a/src/com/massivecraft/massivecore/util/IntervalUtil.java +++ b/src/com/massivecraft/massivecore/util/IntervalUtil.java @@ -92,28 +92,35 @@ public class IntervalUtil // RANDOM SIMPLE // -------------------------------------------- // - public static int randomIntegerFromInterval(int min, int max) + public static int random(int min, int max) { - return min+MassiveCore.random.nextInt(max-min+1); + return min + MassiveCore.random.nextInt(max - min + 1); + } + + public static long random(long min, long max) + { + return min + (long)(MassiveCore.random.nextDouble() * (max - min)); + } + + public static double random(double min, double max) + { + return min + MassiveCore.random.nextDouble() * (max - min); } public static int randomIntegerFromInterval(Entry interval) { int min = interval.getKey(); int max = interval.getValue(); - return randomIntegerFromInterval(min, max); + return random(min, max); } - public static double randomDoubleFromInterval(double min, double max) - { - return min+MassiveCore.random.nextDouble()*(max-min); - } + public static double randomDoubleFromInterval(Entry interval) { double min = interval.getKey(); double max = interval.getValue(); - return randomDoubleFromInterval(min, max); + return random(min, max); } // -------------------------------------------- //