From 932873ba029ce2c9cf775e21031c15b663203746 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 31 Mar 2021 12:42:32 +0200 Subject: [PATCH] Do not access nms for older versions on newer ones --- .../plotsquared/bukkit/listener/SingleWorldListener.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 dc55b9d7f..ea9d265f7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java @@ -49,13 +49,19 @@ public class SingleWorldListener implements Listener { private Method methodGetHandleChunk; private Field mustSave; + private boolean isTrueForNotSave = true; public SingleWorldListener(Plugin plugin) throws Exception { ReflectionUtils.RefClass classChunk = getRefClass("{nms}.Chunk"); ReflectionUtils.RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle").getRealMethod(); try { - this.mustSave = classChunk.getField("mustSave").getRealField(); + if (PlotSquared.get().IMP.getServerVersion()[1] == 13) { + this.mustSave = classChunk.getField("mustSave").getRealField(); + this.isTrueForNotSave = false; + } else { + this.mustSave = classChunk.getField("mustNotSave").getRealField(); + } } catch (NoSuchFieldException e) { e.printStackTrace(); }