Add experimental option to try to migrate old chunks

This commit is contained in:
Mike Primm 2019-06-09 09:59:08 -05:00
parent 881b7dfefd
commit 286a12c4ef
6 changed files with 56 additions and 5 deletions

View File

@ -120,6 +120,7 @@ public class DynmapCore implements DynmapCommonAPI {
private List<String> sortPermissionNodes;
private int perTickLimit = 50; // 50 ms
private boolean dumpMissing = false;
private static boolean migrate_chunks = false;
private int config_hashcode; /* Used to signal need to reload web configuration (world changes, config update, etc) */
private int fullrenderplayerlimit; /* Number of online players that will cause fullrender processing to pause */
@ -203,6 +204,10 @@ public class DynmapCore implements DynmapCommonAPI {
public final void setBiomeNames(String[] names) {
biomenames = names;
}
public static final boolean migrateChunks() {
return migrate_chunks;
}
public final String getBiomeName(int biomeid) {
String n = null;
@ -447,6 +452,10 @@ public class DynmapCore implements DynmapCommonAPI {
dumpMissing = configuration.getBoolean("dump-missing-blocks", false);
migrate_chunks = configuration.getBoolean("migrate-chunks", false);
if (migrate_chunks)
Log.info("EXPERIMENTAL: chunk migration enabled");
/* Load preupdate/postupdate commands */
ImageIOManager.preUpdateCommand = configuration.getString("custom-commands/image-updates/preupdatecommand", "");
ImageIOManager.postUpdateCommand = configuration.getString("custom-commands/image-updates/postupdatecommand", "");

View File

@ -3,11 +3,13 @@ package org.dynmap.bukkit.helper.v113_2;
import org.bukkit.block.Biome;
import org.bukkit.ChunkSnapshot;
import org.bukkit.World;
import org.dynmap.DynmapCore;
import org.dynmap.bukkit.helper.AbstractMapChunkCache;
import org.dynmap.bukkit.helper.BukkitVersionHelper;
import org.dynmap.renderer.DynmapBlockState;
import net.minecraft.server.v1_13_R2.DataPaletteBlock;
import net.minecraft.server.v1_13_R2.Chunk;
/**
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
@ -68,7 +70,7 @@ public class MapChunkCache113_2 extends AbstractMapChunkCache {
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) {
if ((!rslt) && DynmapCore.migrateChunks()) {
boolean generated = true;
// Check one in each direction: see if all are generated
for (int xx = x-3; xx <= x+3; xx++) {

View File

@ -298,6 +298,12 @@ public class MapChunkCache114_1 extends AbstractMapChunkCache {
}
if (nbt != null) {
nbt = nbt.getCompound("Level");
if (nbt != null) {
String stat = nbt.getString("Status");
if ((stat == null) || (stat.equals("full") == false)) {
nbt = null;
}
}
}
return nbt;
}
@ -315,7 +321,14 @@ public class MapChunkCache114_1 extends AbstractMapChunkCache {
if (nbt != null) {
String stat = nbt.getString("Status");
if ((stat == null) || (stat.equals("full") == false)) {
nbt = null;
nbt = null;
if ((stat == null) || stat.equals("") && DynmapCore.migrateChunks()) {
Chunk c = cw.getHandle().getChunkAt(x, z);
if (c != null) {
nbt = fetchLoadedChunkNBT(w, x, z);
cw.getHandle().unloadChunk(c);
}
}
}
}
}

View File

@ -297,6 +297,12 @@ public class MapChunkCache114 extends AbstractMapChunkCache {
}
if (nbt != null) {
nbt = nbt.getCompound("Level");
if (nbt != null) {
String stat = nbt.getString("Status");
if ((stat == null) || (stat.equals("full") == false)) {
nbt = null;
}
}
}
return nbt;
}
@ -313,9 +319,16 @@ public class MapChunkCache114 extends AbstractMapChunkCache {
nbt = nbt.getCompound("Level");
if (nbt != null) {
String stat = nbt.getString("Status");
if ((stat == null) || (stat.equals("full") == false)) {
nbt = null;
}
if ((stat == null) || (stat.equals("full") == false)) {
nbt = null;
if ((stat == null) || stat.equals("") && DynmapCore.migrateChunks()) {
Chunk c = cw.getHandle().getChunkAt(x, z);
if (c != null) {
nbt = fetchLoadedChunkNBT(w, x, z);
cw.getHandle().unloadChunk(c);
}
}
}
}
}
return nbt;

View File

@ -1624,4 +1624,11 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
Polygon getWorldBorder(World w) {
return helper.getWorldBorder(w);
}
public static boolean migrateChunks() {
if ((plugin != null) && (plugin.core != null)) {
return plugin.core.migrateChunks();
}
return false;
}
}

View File

@ -463,3 +463,10 @@ verbose: false
# - class: org.dynmap.debug.LogDebugger
# Debug: dump blocks missing render data
dump-missing-blocks: false
# Have dynmap migrate old chunks to the new format for the current MC version (specifically, for migrating pre-1.13 chunks to 1.13 or 1.14). This is needed
# in order to render chunks on an upgraded server (due to various bugs/limitations in CB/spigot 1.13+). This setting is NOT suggested to be enabled full time,
# but only long enough to do a fullrender of a migrated world - it should be turned back off once worlds are migrated). It is EXPERIMENTAL, so be sure to backup
# your worlds before running with this setting enabled (set to true)
#
#migrate-chunks: true