Fix issues with chunk saving in single world plots

This commit is contained in:
dordsor21 2021-09-10 14:05:12 +01:00
parent 7bc76a3824
commit 4568b17c54
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
3 changed files with 4 additions and 8 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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