Reverted change of coords to long because not needed.

Mincreaft max coords are +/- 30 million.
This commit is contained in:
Tastybento 2018-02-10 13:19:54 -08:00
parent ed65aa421d
commit 65d34f5842
3 changed files with 26 additions and 26 deletions

View File

@ -30,7 +30,7 @@ public class IslandCache {
*/ */
private HashMap<UUID, Island> islandsByUUID; private HashMap<UUID, Island> islandsByUUID;
// 2D islandGrid of islands, x,z // 2D islandGrid of islands, x,z
private TreeMap<Long, TreeMap<Long, Island>> islandGrid = new TreeMap<>(); private TreeMap<Integer, TreeMap<Integer, Island>> islandGrid = new TreeMap<>();
public IslandCache() { public IslandCache() {
islandsByLocation = HashBiMap.create(); islandsByLocation = HashBiMap.create();
@ -72,7 +72,7 @@ public class IslandCache {
if (DEBUG) { if (DEBUG) {
plugin.getLogger().info("DEBUG: min x is in the grid :" + newIsland.getMinX()); plugin.getLogger().info("DEBUG: min x is in the grid :" + newIsland.getMinX());
} }
TreeMap<Long, Island> zEntry = islandGrid.get(newIsland.getMinX()); TreeMap<Integer, Island> zEntry = islandGrid.get(newIsland.getMinX());
if (zEntry.containsKey(newIsland.getMinZ())) { if (zEntry.containsKey(newIsland.getMinZ())) {
if (DEBUG) { if (DEBUG) {
plugin.getLogger().info("DEBUG: min z is in the grid :" + newIsland.getMinZ()); plugin.getLogger().info("DEBUG: min z is in the grid :" + newIsland.getMinZ());
@ -111,7 +111,7 @@ public class IslandCache {
if (DEBUG) { if (DEBUG) {
plugin.getLogger().info("DEBUG: added island to grid at " + newIsland.getMinX() + "," + newIsland.getMinZ()); plugin.getLogger().info("DEBUG: added island to grid at " + newIsland.getMinX() + "," + newIsland.getMinZ());
} }
TreeMap<Long, Island> zEntry = new TreeMap<>(); TreeMap<Integer, Island> zEntry = new TreeMap<>();
zEntry.put(newIsland.getMinZ(), newIsland); zEntry.put(newIsland.getMinZ(), newIsland);
islandGrid.put(newIsland.getMinX(), zEntry); islandGrid.put(newIsland.getMinX(), zEntry);
} }
@ -177,8 +177,8 @@ public class IslandCache {
plugin.getLogger().info("DEBUG: deleting island at " + island.getCenter()); plugin.getLogger().info("DEBUG: deleting island at " + island.getCenter());
} }
if (island != null) { if (island != null) {
long x = island.getMinX(); int x = island.getMinX();
long z = island.getMinZ(); int z = island.getMinZ();
if (DEBUG) { if (DEBUG) {
plugin.getLogger().info("DEBUG: x = " + x + " z = " + z); plugin.getLogger().info("DEBUG: x = " + x + " z = " + z);
} }
@ -186,7 +186,7 @@ public class IslandCache {
if (DEBUG) { if (DEBUG) {
plugin.getLogger().info("DEBUG: x found"); plugin.getLogger().info("DEBUG: x found");
} }
TreeMap<Long, Island> zEntry = islandGrid.get(x); TreeMap<Integer, Island> zEntry = islandGrid.get(x);
if (zEntry.containsKey(z)) { if (zEntry.containsKey(z)) {
if (DEBUG) { if (DEBUG) {
plugin.getLogger().info("DEBUG: z found - deleting the island"); plugin.getLogger().info("DEBUG: z found - deleting the island");
@ -228,14 +228,14 @@ public class IslandCache {
* @param z * @param z
* @return Island or null * @return Island or null
*/ */
public Island getIslandAt(long x, long z) { public Island getIslandAt(int x, int z) {
if (DEBUG2) { if (DEBUG2) {
plugin.getLogger().info("DEBUG: getting island at " + x + "," + z); plugin.getLogger().info("DEBUG: getting island at " + x + "," + z);
plugin.getLogger().info("DEBUG: island grid is " + islandGrid.size()); plugin.getLogger().info("DEBUG: island grid is " + islandGrid.size());
} }
Entry<Long, TreeMap<Long, Island>> en = islandGrid.floorEntry(x); Entry<Integer, TreeMap<Integer, Island>> en = islandGrid.floorEntry(x);
if (en != null) { if (en != null) {
Entry<Long, Island> ent = en.getValue().floorEntry(z); Entry<Integer, Island> ent = en.getValue().floorEntry(z);
if (ent != null) { if (ent != null) {
// Check if in the island range // Check if in the island range
Island island = ent.getValue(); Island island = ent.getValue();

View File

@ -48,14 +48,14 @@ public class Island implements DataObject {
private int range; private int range;
// Coordinates of the island area // Coordinates of the island area
private long minX; private int minX;
private long minZ; private int minZ;
// Coordinates of minimum protected area // Coordinates of minimum protected area
private long minProtectedX; private int minProtectedX;
private long minProtectedZ; private int minProtectedZ;
// Protection size // Protection size
private int protectionRange; private int protectionRange;
@ -213,28 +213,28 @@ public class Island implements DataObject {
/** /**
* @return the minProtectedX * @return the minProtectedX
*/ */
public long getMinProtectedX() { public int getMinProtectedX() {
return minProtectedX; return minProtectedX;
} }
/** /**
* @return the minProtectedZ * @return the minProtectedZ
*/ */
public long getMinProtectedZ() { public int getMinProtectedZ() {
return minProtectedZ; return minProtectedZ;
} }
/** /**
* @return the minX * @return the minX
*/ */
public long getMinX() { public int getMinX() {
return minX; return minX;
} }
/** /**
* @return the minZ * @return the minZ
*/ */
public long getMinZ() { public int getMinZ() {
return minZ; return minZ;
} }
@ -410,7 +410,7 @@ public class Island implements DataObject {
* @param z * @param z
* @return true if in the island space * @return true if in the island space
*/ */
public boolean inIslandSpace(long x, long z) { public boolean inIslandSpace(int x, int z) {
//Bukkit.getLogger().info("DEBUG: center - " + center); //Bukkit.getLogger().info("DEBUG: center - " + center);
return x >= minX && x < minX + range*2 && z >= minZ && z < minZ + range*2; return x >= minX && x < minX + range*2 && z >= minZ && z < minZ + range*2;
} }
@ -420,7 +420,7 @@ public class Island implements DataObject {
* @param blockCoord * @param blockCoord
* @return true or false * @return true or false
*/ */
public boolean inIslandSpace(Pair<Long, Long> blockCoord) { public boolean inIslandSpace(Pair<Integer, Integer> blockCoord) {
return inIslandSpace(blockCoord.x, blockCoord.z); return inIslandSpace(blockCoord.x, blockCoord.z);
} }
@ -577,21 +577,21 @@ public class Island implements DataObject {
/** /**
* @param minProtectedX the minProtectedX to set * @param minProtectedX the minProtectedX to set
*/ */
public final void setMinProtectedX(long minProtectedX) { public final void setMinProtectedX(int minProtectedX) {
this.minProtectedX = minProtectedX; this.minProtectedX = minProtectedX;
} }
/** /**
* @param minProtectedZ the minProtectedZ to set * @param minProtectedZ the minProtectedZ to set
*/ */
public final void setMinProtectedZ(long minProtectedZ) { public final void setMinProtectedZ(int minProtectedZ) {
this.minProtectedZ = minProtectedZ; this.minProtectedZ = minProtectedZ;
} }
/** /**
* @param minX the minX to set * @param minX the minX to set
*/ */
public final void setMinX(long minX) { public final void setMinX(int minX) {
this.minX = minX; this.minX = minX;
} }
@ -599,7 +599,7 @@ public class Island implements DataObject {
/** /**
* @param minZ the minZ to set * @param minZ the minZ to set
*/ */
public final void setMinZ(long minZ) { public final void setMinZ(int minZ) {
this.minZ = minZ; this.minZ = minZ;
} }

View File

@ -137,10 +137,10 @@ public class SafeSpotTeleport {
// Create ever increasing squares around the target location // Create ever increasing squares around the target location
int radius = 0; int radius = 0;
do { do {
for (long i = x - radius; i <= x + radius; i++) { for (int i = x - radius; i <= x + radius; i++) {
for (long j = z - radius; j <= z + radius; j++) { for (int j = z - radius; j <= z + radius; j++) {
Pair<Long, Long> blockCoord = new Pair<>(i,j); Pair<Integer, Integer> blockCoord = new Pair<>(i,j);
Pair<Integer, Integer> chunkCoord = new Pair<>((int)i/16, (int)j/16); Pair<Integer, Integer> chunkCoord = new Pair<>((int)i/16, (int)j/16);
if (!result.contains(chunkCoord)) { if (!result.contains(chunkCoord)) {
Bukkit.getLogger().info("Block coord = " + blockCoord); Bukkit.getLogger().info("Block coord = " + blockCoord);