diff --git a/src/main/java/wtf/beatrice/limbomanager/Cache.java b/src/main/java/wtf/beatrice/limbomanager/Cache.java index 96ddbee..de74adc 100644 --- a/src/main/java/wtf/beatrice/limbomanager/Cache.java +++ b/src/main/java/wtf/beatrice/limbomanager/Cache.java @@ -10,6 +10,9 @@ public class Cache { public static final Coordinates baseCoords = new Coordinates(1000, 1000); + + public static int islandsDistance = 500; + public static int islandWalkingRange = 100; private static YamlConfiguration configuration; public static final HashMap playerIslands = new HashMap<>(); diff --git a/src/main/java/wtf/beatrice/limbomanager/LimboManager.java b/src/main/java/wtf/beatrice/limbomanager/LimboManager.java index b04d219..5463e76 100644 --- a/src/main/java/wtf/beatrice/limbomanager/LimboManager.java +++ b/src/main/java/wtf/beatrice/limbomanager/LimboManager.java @@ -52,9 +52,12 @@ public class LimboManager extends JavaPlugin { throw new RuntimeException(e); } + // cache some config variables + Cache.islandWalkingRange = configuration.getInt("sizing.allowed-range"); + Cache.islandsDistance = configuration.getInt("sizing.island-distance"); + // start location check runnable Cache.locationCheckRunnable = new LocationCheckRunnable(); - Cache.locationCheckRunnable.setDistanceMax(configuration.getInt("sizing.allowed-range")); Cache.locationCheckRunnable.task = Bukkit.getScheduler().runTaskTimerAsynchronously(this, Cache.locationCheckRunnable, 10L, 5L); } diff --git a/src/main/java/wtf/beatrice/limbomanager/listeners/PlayerTeleporter.java b/src/main/java/wtf/beatrice/limbomanager/listeners/PlayerTeleporter.java index 5f02883..aabcd6f 100644 --- a/src/main/java/wtf/beatrice/limbomanager/listeners/PlayerTeleporter.java +++ b/src/main/java/wtf/beatrice/limbomanager/listeners/PlayerTeleporter.java @@ -96,7 +96,7 @@ public class PlayerTeleporter implements Listener /* how are islands laid out? - we start from (1000, 1000) and we put islands at 500 blocks distance up to 10000. then we move to a new row. + we start from (1000, 1000) and we put islands at blocks distance up to 10000. then we move to a new row. */ Coordinates islandCoords = new Coordinates(Cache.baseCoords); @@ -107,13 +107,13 @@ public class PlayerTeleporter implements Listener if(!islandCoords.equals(currentCoords)) break; // else, if they are the same, - // we have to either increase X or move to a new row, in case it's over 10000. + // we have to either increase X or move to a new row and reset X, in case it's over 10000. if(islandCoords.getX() >= 10000) // if we need to create a new row { islandCoords.setX(1000); - islandCoords.setZ(islandCoords.getZ() + 500); + islandCoords.setZ(islandCoords.getZ() + Cache.islandsDistance); } else { // if we just need to increase the column - islandCoords.setX(islandCoords.getX() + 500); + islandCoords.setX(islandCoords.getX() + Cache.islandsDistance); } } diff --git a/src/main/java/wtf/beatrice/limbomanager/objects/LocationCheckRunnable.java b/src/main/java/wtf/beatrice/limbomanager/objects/LocationCheckRunnable.java index b878350..7f98ec2 100644 --- a/src/main/java/wtf/beatrice/limbomanager/objects/LocationCheckRunnable.java +++ b/src/main/java/wtf/beatrice/limbomanager/objects/LocationCheckRunnable.java @@ -16,7 +16,6 @@ public class LocationCheckRunnable implements Runnable public BukkitTask task; List playersToCheck = new ArrayList<>(); - private int distanceMax = 100; //just a default value // we give players a distanceMax block range to move in. @@ -61,7 +60,7 @@ public class LocationCheckRunnable implements Runnable int distanceZ = Math.abs(playerLocation.getBlockZ() - islandSpawnCoordinates.getZ()); // check if player is inside bounds - if(distanceX > distanceMax || distanceZ > distanceMax) + if(distanceX > Cache.islandWalkingRange || distanceZ > Cache.islandWalkingRange) { LocationUtils.teleportToOwnIsland(player); player.sendMessage("Out of bounds"); @@ -69,9 +68,4 @@ public class LocationCheckRunnable implements Runnable } } - - public void setDistanceMax(int distanceMax) - { - this.distanceMax = distanceMax; - } }