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;
// 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() {
islandsByLocation = HashBiMap.create();
@ -72,7 +72,7 @@ public class IslandCache {
if (DEBUG) {
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 (DEBUG) {
plugin.getLogger().info("DEBUG: min z is in the grid :" + newIsland.getMinZ());
@ -111,7 +111,7 @@ public class IslandCache {
if (DEBUG) {
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);
islandGrid.put(newIsland.getMinX(), zEntry);
}
@ -177,8 +177,8 @@ public class IslandCache {
plugin.getLogger().info("DEBUG: deleting island at " + island.getCenter());
}
if (island != null) {
long x = island.getMinX();
long z = island.getMinZ();
int x = island.getMinX();
int z = island.getMinZ();
if (DEBUG) {
plugin.getLogger().info("DEBUG: x = " + x + " z = " + z);
}
@ -186,7 +186,7 @@ public class IslandCache {
if (DEBUG) {
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 (DEBUG) {
plugin.getLogger().info("DEBUG: z found - deleting the island");
@ -228,14 +228,14 @@ public class IslandCache {
* @param z
* @return Island or null
*/
public Island getIslandAt(long x, long z) {
public Island getIslandAt(int x, int z) {
if (DEBUG2) {
plugin.getLogger().info("DEBUG: getting island at " + x + "," + z);
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) {
Entry<Long, Island> ent = en.getValue().floorEntry(z);
Entry<Integer, Island> ent = en.getValue().floorEntry(z);
if (ent != null) {
// Check if in the island range
Island island = ent.getValue();

View File

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

View File

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