Move math method to new NumberUtils class
This commit is contained in:
parent
b45f7f5a8f
commit
ea061e55e6
@ -4,6 +4,8 @@
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea/dictionaries" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea/libraries" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
|
@ -5,6 +5,7 @@ import net.mindoverflow.network.uhccore.utils.CommonValues;
|
||||
import net.mindoverflow.network.uhccore.utils.ConfigEntries;
|
||||
import net.mindoverflow.network.uhccore.utils.Debugger;
|
||||
import net.mindoverflow.network.uhccore.utils.FileUtils;
|
||||
import net.mindoverflow.network.uhccore.utils.math.NumberUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -47,9 +48,9 @@ public class StartUhcCommand {
|
||||
for(int i = 0; i < CommonValues.totalTeams; i++)
|
||||
{
|
||||
|
||||
double x = getRandomNumberInRange(borderX - range + 1, borderX + range - 1) + 0.5;
|
||||
double z = getRandomNumberInRange(borderZ - range + 1, borderZ + range - 1) + 0.5;
|
||||
int y = spawnWorld.getHighestBlockYAt((int) x, (int) z);
|
||||
double x = NumberUtils.getRandomNumberInRange(borderX - range + 1, borderX + range - 1) + 0.5;
|
||||
double z = NumberUtils.getRandomNumberInRange(borderZ - range + 1, borderZ + range - 1) + 0.5;
|
||||
int y = spawnWorld.getHighestBlockYAt((int) x, (int) z); // todo: this method is shit, ushe the one i already implemented in Factions...
|
||||
|
||||
Location loc = new Location(spawnWorld, x, y + 1, z);
|
||||
|
||||
@ -119,15 +120,4 @@ public class StartUhcCommand {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static int getRandomNumberInRange(int min, int max) {
|
||||
|
||||
if (min >= max) {
|
||||
throw new IllegalArgumentException("max must be greater than min");
|
||||
}
|
||||
|
||||
Random r = new Random();
|
||||
return r.nextInt((max - min) + 1) + min;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
package net.mindoverflow.network.uhccore.utils.math;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class NumberUtils {
|
||||
|
||||
public static int getRandomNumberInRange(int min, int max) {
|
||||
|
||||
if (min >= max) {
|
||||
throw new IllegalArgumentException("max must be greater than min");
|
||||
}
|
||||
|
||||
Random r = new Random();
|
||||
return r.nextInt((max - min) + 1) + min;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user