Add workaround for Spigot 1.13.2 bug with loadChunk(x,z,false)

Workaround problem with fact that World.loadChunk(x, z, false) fails
when called on existing chunks that have not been migrated to 1.13.x
format.
This commit is contained in:
Mike Primm 2018-12-01 19:22:47 -06:00
parent 24c62e80ec
commit 12c4df777d
2 changed files with 27 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package org.dynmap.bukkit.helper.v113_2;
import org.bukkit.block.Biome;
import org.bukkit.ChunkSnapshot;
import org.bukkit.World;
import org.dynmap.bukkit.helper.AbstractMapChunkCache;
import org.dynmap.bukkit.helper.BukkitVersionHelper;
import org.dynmap.renderer.DynmapBlockState;
@ -63,4 +64,25 @@ public class MapChunkCache113_2 extends AbstractMapChunkCache {
public Snapshot wrapChunkSnapshot(ChunkSnapshot css) {
return new WrappedSnapshot(css);
}
@Override
public boolean loadChunkNoGenerate(World w, int x, int z) {
boolean rslt = w.loadChunk(x, z, false);
// Workaround for Spigot 1.13.2 bug - check if generated and do load-with-generate if so to drive migration of old chunks
if (!rslt) {
boolean generated = true;
// Check one in each direction: see if all are generated
for (int xx = x-3; xx <= x+3; xx++) {
for (int zz = z-3; zz <= z+3; zz++) {
if (w.isChunkGenerated(xx, zz) == false) {
generated = false;
break;
}
}
}
if (generated) {
rslt = w.loadChunk(x, z, true);
}
}
return rslt;
}
}

View File

@ -796,7 +796,7 @@ public abstract class AbstractMapChunkCache extends MapChunkCache {
wasLoaded = true;
}
try {
didload = w.loadChunk(chunk.x, chunk.z, false);
didload = loadChunkNoGenerate(w, chunk.x, chunk.z);
} catch (Throwable t) { /* Catch chunk error from Bukkit */
Log.warning("Bukkit error loading chunk " + chunk.x + "," + chunk.z + " on " + w.getName());
if(!wasLoaded) { /* If wasn't loaded, we loaded it if it now is */
@ -1013,6 +1013,10 @@ public abstract class AbstractMapChunkCache extends MapChunkCache {
return dw;
}
public boolean loadChunkNoGenerate(World w, int x, int z) {
return w.loadChunk(x, z, false);
}
static {
Biome[] b = Biome.values();
BiomeMap[] bm = BiomeMap.values();