From fbf07bbf1a04c74d9bc9910cb8bf894c4600a0bd Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sat, 12 Mar 2022 15:04:31 +0000 Subject: [PATCH] Use correct field for unsaved in 1.18 --- .../plotsquared/bukkit/listener/SingleWorldListener.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 12ef2146e..2c9358245 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java @@ -46,7 +46,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass; public class SingleWorldListener implements Listener { private final Method methodGetHandleChunk; - private Field shouldSave; + private Field shouldSave = null; public SingleWorldListener() throws Exception { ReflectionUtils.RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); @@ -59,9 +59,12 @@ public class SingleWorldListener implements Listener { } else { this.shouldSave = classChunk.getField("s").getRealField(); } - } else { + } else if (PlotSquared.platform().serverVersion()[1] == 17) { ReflectionUtils.RefClass classChunk = getRefClass("net.minecraft.world.level.chunk.Chunk"); this.shouldSave = classChunk.getField("r").getRealField(); + } else if (PlotSquared.platform().serverVersion()[1] == 18) { + ReflectionUtils.RefClass classChunk = getRefClass("net.minecraft.world.level.chunk.IChunkAccess"); + this.shouldSave = classChunk.getField("b").getRealField(); } } catch (NoSuchFieldException e) { e.printStackTrace();