Another try at 1.9 chunk freeze workaround - avoid unloadChunk API

This commit is contained in:
Mike Primm 2016-04-08 00:25:30 -05:00
parent eecef06684
commit 95ba9b9521
3 changed files with 18 additions and 1 deletions

View File

@ -144,4 +144,8 @@ public abstract class BukkitVersionHelper {
* Get world border
*/
public Polygon getWorldBorder(World world) { return null; }
/**
* Test if broken unloadChunk
*/
public boolean isUnloadChunkBroken() { return false; }
}

View File

@ -33,8 +33,10 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
private Method worldbordermaxz;
private Method getbiomebyid;
private Method getidbybiome;
private boolean isBadUnload = false;
BukkitVersionHelperCB() {
isBadUnload = Bukkit.getServer().getBukkitVersion().contains("1.9");
}
@Override
protected String getNMSPackage() {
@ -314,5 +316,10 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
}
return super.getBiomeBaseID(bb);
}
/**
* Test if broken unloadChunk
*/
@Override
public boolean isUnloadChunkBroken() { return isBadUnload; }
}

View File

@ -878,7 +878,13 @@ public class NewMapChunkCache extends MapChunkCache {
* by the MC base server is 21x21 (or about a 160 block radius).
* Also, if we did generate it, need to save it */
if (w.isChunkInUse(chunk.x, chunk.z) == false) {
helper.unloadChunkNoSave(w, c, chunk.x, chunk.z);
if (helper.isUnloadChunkBroken()) {
// Give up on broken unloadChunk API - lets see if this works
w.unloadChunkRequest(chunk.x, chunk.z);
}
else {
helper.unloadChunkNoSave(w, c, chunk.x, chunk.z);
}
}
endChunkLoad(startTime, ChunkStats.UNLOADED_CHUNKS);
}