|
@@ -128,19 +128,17 @@ public class PlotMap {
|
|
|
|
|
|
@Override
|
|
|
public String toString() {
|
|
|
- return String.format("Plot(%d, %d, %d, %d, %d, %d)", minX, minY, minZ, maxX, maxY, maxZ);
|
|
|
+ return String.format("Plot(%d, %d, %d, %d, %d, %d)", minX, minY, minZ, maxX, maxY,
|
|
|
+ maxZ);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private static int idCounter = 0;
|
|
|
|
|
|
private static final int SIZE_FACTOR = 64;
|
|
|
- private final static int[] PRIMES
|
|
|
- = {
|
|
|
- 17, 37, 79, 163, 331, 673, 1361, 2729, 5471, 10949, 21911, 43853, 87719,
|
|
|
- 175447, 350899, 701819, 1403641, 2807303, 5614657, 11229331, 22458671,
|
|
|
- 44917381, 89834777, 179669557, 359339171, 718678369
|
|
|
- };
|
|
|
+ private final static int[] PRIMES = {17, 37, 79, 163, 331, 673, 1361, 2729, 5471, 10949, 21911,
|
|
|
+ 43853, 87719, 175447, 350899, 701819, 1403641, 2807303, 5614657, 11229331, 22458671,
|
|
|
+ 44917381, 89834777, 179669557, 359339171, 718678369};
|
|
|
|
|
|
private int primeIndex = 0;
|
|
|
private int size = 0;
|
|
@@ -219,7 +217,8 @@ public class PlotMap {
|
|
|
}
|
|
|
|
|
|
public List<Plot> getPlotAt(int x, int y, int z) {
|
|
|
- ArrayList<Plot> list = plots[hash(Math.floorDiv(x, SIZE_FACTOR), Math.floorDiv(z, SIZE_FACTOR), plots.length)];
|
|
|
+ ArrayList<Plot> list = plots[hash(Math.floorDiv(x, SIZE_FACTOR),
|
|
|
+ Math.floorDiv(z, SIZE_FACTOR), plots.length)];
|
|
|
if(list == null) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
@@ -227,7 +226,8 @@ public class PlotMap {
|
|
|
}
|
|
|
|
|
|
public boolean anyPlotMatches(int x, int y, int z, boolean empty, Predicate<Plot> pred) {
|
|
|
- ArrayList<Plot> list = plots[hash(Math.floorDiv(x, SIZE_FACTOR), Math.floorDiv(z, SIZE_FACTOR), plots.length)];
|
|
|
+ ArrayList<Plot> list = plots[hash(Math.floorDiv(x, SIZE_FACTOR),
|
|
|
+ Math.floorDiv(z, SIZE_FACTOR), plots.length)];
|
|
|
if(list == null) {
|
|
|
return empty;
|
|
|
}
|
|
@@ -331,7 +331,7 @@ public class PlotMap {
|
|
|
|
|
|
public void save(String path) {
|
|
|
File f = new File(path);
|
|
|
- try(DataOutputStream out = new DataOutputStream(new FileOutputStream(f))) {
|
|
|
+ try (DataOutputStream out = new DataOutputStream(new FileOutputStream(f))) {
|
|
|
Iterator<Plot> iter = getIterator();
|
|
|
while(iter.hasNext()) {
|
|
|
Plot p = iter.next();
|
|
@@ -352,7 +352,7 @@ public class PlotMap {
|
|
|
out.writeInt(p.flags);
|
|
|
out.writeUTF(p.name);
|
|
|
}
|
|
|
- } catch(IOException ex) {
|
|
|
+ } catch (IOException ex) {
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
}
|
|
@@ -361,7 +361,7 @@ public class PlotMap {
|
|
|
if(!f.exists()) {
|
|
|
return;
|
|
|
}
|
|
|
- try(DataInputStream in = new DataInputStream(new FileInputStream(f))) {
|
|
|
+ try (DataInputStream in = new DataInputStream(new FileInputStream(f))) {
|
|
|
while(true) {
|
|
|
int id = in.readInt();
|
|
|
int minX = in.readShort();
|
|
@@ -381,13 +381,14 @@ public class PlotMap {
|
|
|
p.flags = in.readInt();
|
|
|
p.name = in.readUTF();
|
|
|
}
|
|
|
- } catch(EOFException ex) {
|
|
|
- } catch(IOException ex) {
|
|
|
+ } catch (EOFException ex) {
|
|
|
+ } catch (IOException ex) {
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public ArrayList<Plot> getIntersectingPlots(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
|
|
+ public ArrayList<Plot> getIntersectingPlots(int minX, int minY, int minZ, int maxX, int maxY,
|
|
|
+ int maxZ) {
|
|
|
if(minX > maxX) {
|
|
|
int tmp = minX;
|
|
|
minX = maxX;
|
|
@@ -410,7 +411,8 @@ public class PlotMap {
|
|
|
|
|
|
Plot p = last;
|
|
|
while(p != null) {
|
|
|
- if(maxX > p.minX && p.maxX > minX && maxY > p.minY && p.maxY > minY && maxZ > p.minZ && p.maxZ > minZ) {
|
|
|
+ if(maxX > p.minX && p.maxX > minX && maxY > p.minY && p.maxY > minY && maxZ > p.minZ
|
|
|
+ && p.maxZ > minZ) {
|
|
|
list.add(p);
|
|
|
}
|
|
|
p = p.previous;
|