From 4568b17c54bb419f49366b4b4038c7e32800205b Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 10 Sep 2021 14:05:12 +0100 Subject: [PATCH] Fix issues with chunk saving in single world plots --- .../java/com/plotsquared/bukkit/listener/ChunkListener.java | 2 +- .../plotsquared/bukkit/listener/SingleWorldListener.java | 6 ++---- .../plotsquared/core/plot/world/SinglePlotAreaManager.java | 4 +--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java index 566cc819b..83acb6d13 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java @@ -230,7 +230,7 @@ public class ChunkListener implements Listener { } Object c = this.methodGetHandleChunk.of(chunk).call(); RefField.RefExecutor field = this.mustSave.of(c); - if ((Boolean) field.get()) { + if ((Boolean) field.get() != isTrueForNotSave) { field.set(isTrueForNotSave); if (chunk.isLoaded()) { ignoreUnload = true; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java index c0072d1e8..709f4e111 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java @@ -47,7 +47,6 @@ public class SingleWorldListener implements Listener { private final Method methodGetHandleChunk; private Field mustSave; - private boolean isTrueForNotSave = true; public SingleWorldListener() throws Exception { ReflectionUtils.RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); @@ -57,9 +56,8 @@ public class SingleWorldListener implements Listener { ReflectionUtils.RefClass classChunk = getRefClass("{nms}.Chunk"); if (PlotSquared.platform().serverVersion()[1] == 13) { this.mustSave = classChunk.getField("mustSave").getRealField(); - this.isTrueForNotSave = false; } else { - this.mustSave = classChunk.getField("mustNotSave").getRealField(); + this.mustSave = classChunk.getField("unsaved").getRealField(); } } else { ReflectionUtils.RefClass classChunk = getRefClass("net.minecraft.world.level.chunk.Chunk"); @@ -74,7 +72,7 @@ public class SingleWorldListener implements Listener { try { Object nmsChunk = methodGetHandleChunk.invoke(chunk); if (mustSave != null) { - this.mustSave.set(nmsChunk, isTrueForNotSave); + this.mustSave.set(nmsChunk, false); } } catch (Throwable e) { e.printStackTrace(); diff --git a/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotAreaManager.java b/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotAreaManager.java index 11edf1881..0682a4298 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotAreaManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotAreaManager.java @@ -148,9 +148,7 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager { if (found != null && found.length != 0) { return found; } - return isWorld(world) || world.equals("*") ? - array : - all.length == 0 ? noPlotAreas : super.getPlotAreas(world, region); + return isWorld(world) || world.equals("*") ? array : all.length == 0 ? noPlotAreas : found; } @Override