Use correct field for unsaved in 1.18

This commit is contained in:
dordsor21 2022-03-12 15:04:31 +00:00 committed by Jordan
parent 7efd42ae45
commit 3a6f845c01

View File

@ -46,7 +46,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
public class SingleWorldListener implements Listener { public class SingleWorldListener implements Listener {
private final Method methodGetHandleChunk; private final Method methodGetHandleChunk;
private Field shouldSave; private Field shouldSave = null;
public SingleWorldListener() throws Exception { public SingleWorldListener() throws Exception {
ReflectionUtils.RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); ReflectionUtils.RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
@ -59,9 +59,12 @@ public class SingleWorldListener implements Listener {
} else { } else {
this.shouldSave = classChunk.getField("s").getRealField(); this.shouldSave = classChunk.getField("s").getRealField();
} }
} else { } else if (PlotSquared.platform().serverVersion()[1] == 17) {
ReflectionUtils.RefClass classChunk = getRefClass("net.minecraft.world.level.chunk.Chunk"); ReflectionUtils.RefClass classChunk = getRefClass("net.minecraft.world.level.chunk.Chunk");
this.shouldSave = classChunk.getField("r").getRealField(); 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) { } catch (NoSuchFieldException e) {
e.printStackTrace(); e.printStackTrace();