mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Fix auto-trim
This commit is contained in:
parent
79b16b8040
commit
d427ba3152
@ -110,7 +110,7 @@ public class ChunkListener implements Listener {
|
|||||||
String name = world.getName();
|
String name = world.getName();
|
||||||
boolean autosave = world.isAutoSave();
|
boolean autosave = world.isAutoSave();
|
||||||
boolean plotworld = PS.get().isPlotWorld(name);
|
boolean plotworld = PS.get().isPlotWorld(name);
|
||||||
if (autosave && plotworld) {
|
if (!Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE && autosave && plotworld) {
|
||||||
world.setAutoSave(false);
|
world.setAutoSave(false);
|
||||||
}
|
}
|
||||||
HashMap<ChunkLoc, Integer> map = players.get(name);
|
HashMap<ChunkLoc, Integer> map = players.get(name);
|
||||||
@ -121,12 +121,7 @@ public class ChunkListener implements Listener {
|
|||||||
int x = chunk.getX();
|
int x = chunk.getX();
|
||||||
int z = chunk.getZ();
|
int z = chunk.getZ();
|
||||||
if (!map.containsKey(new ChunkLoc(x, z))) {
|
if (!map.containsKey(new ChunkLoc(x, z))) {
|
||||||
Plot plot = MainUtil.getPlot(new Location(name, x << 4, 1, z << 4));
|
if (!Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE || !plotworld || !unloadChunk(name, chunk)) {
|
||||||
if (Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE && plot == null || plot.owner == null && plotworld) {
|
|
||||||
unloadChunk(chunk);
|
|
||||||
CraftChunk c = null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
chunk.unload(true, false);
|
chunk.unload(true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,10 +134,28 @@ public class ChunkListener implements Listener {
|
|||||||
}, 300);
|
}, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unloadChunk(Chunk chunk) {
|
public boolean unloadChunk(String world, Chunk chunk) {
|
||||||
|
int X = chunk.getX();
|
||||||
|
int Z = chunk.getZ();
|
||||||
|
int x = X << 4;
|
||||||
|
int z = Z << 4;
|
||||||
|
int x2 = x + 15;
|
||||||
|
int z2 = z + 15;
|
||||||
|
Plot plot;
|
||||||
|
plot = MainUtil.getPlot(new Location(world, x, 1, z));
|
||||||
|
if (plot != null && plot.owner != null) return false;
|
||||||
|
plot = MainUtil.getPlot(new Location(world, x2, 1, z2));
|
||||||
|
if (plot != null && plot.owner != null) return false;
|
||||||
|
plot = MainUtil.getPlot(new Location(world, x2, 1, z));
|
||||||
|
if (plot != null && plot.owner != null) return false;
|
||||||
|
plot = MainUtil.getPlot(new Location(world, x, 1, z2));
|
||||||
|
if (plot != null && plot.owner != null) return false;
|
||||||
|
plot = MainUtil.getPlot(new Location(world, x + 7, 1, z + 7));
|
||||||
|
if (plot != null && plot.owner != null) return false;
|
||||||
Object c = methodGetHandleChunk.of(chunk).call();
|
Object c = methodGetHandleChunk.of(chunk).call();
|
||||||
mustSave.of(c).set(false);
|
mustSave.of(c).set(false);
|
||||||
chunk.unload(false, false);
|
chunk.unload(false, false);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -151,11 +164,7 @@ public class ChunkListener implements Listener {
|
|||||||
Chunk chunk = event.getChunk();
|
Chunk chunk = event.getChunk();
|
||||||
String world = chunk.getWorld().getName();
|
String world = chunk.getWorld().getName();
|
||||||
if (PS.get().isPlotWorld(world)) {
|
if (PS.get().isPlotWorld(world)) {
|
||||||
int x = chunk.getX();
|
if (unloadChunk(world, chunk)) {
|
||||||
int z = chunk.getZ();
|
|
||||||
Plot plot = MainUtil.getPlot(new Location(world, x << 4, 1, z << 4));
|
|
||||||
if (plot == null || plot.owner == null && PS.get().isPlotWorld(world)) {
|
|
||||||
unloadChunk(chunk);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,6 +174,7 @@ public class ChunkListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onChunkLoad(ChunkLoadEvent event) {
|
public void onChunkLoad(ChunkLoadEvent event) {
|
||||||
processChunk(event.getChunk(), false);
|
processChunk(event.getChunk(), false);
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user