Fix confusing migration message appearing on fresh server

This commit is contained in:
md_5 2019-01-05 17:03:12 +11:00
parent 516a408f4a
commit 3a5dc78f47

View File

@ -120,7 +120,7 @@
IDataManager idatamanager = this.getConvertable().a(s, this);
this.a(this.getWorld(), idatamanager);
@@ -244,54 +296,144 @@
@@ -244,54 +296,145 @@
}
this.a(idatamanager.getDirectory(), worlddata);
@ -197,13 +197,9 @@
- SecondaryWorldServer secondaryworldserver = (new SecondaryWorldServer(this, idatamanager, DimensionManager.NETHER, worldserver, this.methodProfiler)).i_();
+ File newWorld = new File(new File(name), dim);
+ File oldWorld = new File(new File(s), dim);
- this.worldServer.put(DimensionManager.NETHER, secondaryworldserver);
- secondaryworldserver.addIWorldAccess(new WorldManager(this, secondaryworldserver));
- if (!this.H()) {
- secondaryworldserver.getWorldData().setGameType(this.getGamemode());
- }
+ if ((!newWorld.isDirectory()) && (oldWorld.isDirectory())) {
+ File oldLevelDat = new File(new File(s), "level.dat"); // The data folders exist on first run as they are created in the PersistentCollection constructor above, but the level.dat won't
+
+ if (!newWorld.isDirectory() && oldWorld.isDirectory() && oldLevelDat.isFile()) {
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder required ----");
+ MinecraftServer.LOGGER.info("Unfortunately due to the way that Minecraft implemented multiworld support in 1.6, Bukkit requires that you move your " + worldType + " folder to a new location in order to operate correctly.");
+ MinecraftServer.LOGGER.info("We will move this folder for you, but it will mean that you need to move it back should you wish to stop using Bukkit in the future.");
@ -217,7 +213,7 @@
+ MinecraftServer.LOGGER.info("Success! To restore " + worldType + " in the future, simply move " + newWorld + " to " + oldWorld);
+ // Migrate world data too.
+ try {
+ com.google.common.io.Files.copy(new File(new File(s), "level.dat"), new File(new File(name), "level.dat"));
+ com.google.common.io.Files.copy(oldLevelDat, new File(new File(name), "level.dat"));
+ org.apache.commons.io.FileUtils.copyDirectory(new File(new File(s), "data"), new File(new File(name), "data"));
+ } catch (IOException exception) {
+ MinecraftServer.LOGGER.warn("Unable to migrate world data.");
@ -233,7 +229,11 @@
+ }
+ }
- SecondaryWorldServer secondaryworldserver1 = (new SecondaryWorldServer(this, idatamanager, DimensionManager.THE_END, worldserver, this.methodProfiler)).i_();
- this.worldServer.put(DimensionManager.NETHER, secondaryworldserver);
- secondaryworldserver.addIWorldAccess(new WorldManager(this, secondaryworldserver));
- if (!this.H()) {
- secondaryworldserver.getWorldData().setGameType(this.getGamemode());
- }
+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, this, this.dataConverterManager);
+ // world =, b0 to dimension, s1 to name, added Environment and gen
+ worlddata = idatamanager.getWorldData();
@ -244,24 +244,25 @@
+ world = (WorldServer) new SecondaryWorldServer(this, idatamanager, DimensionManager.a(dimension), this.getWorldServer(DimensionManager.OVERWORLD), this.methodProfiler, worlddata, org.bukkit.World.Environment.getEnvironment(dimension), gen).i_();
+ }
- SecondaryWorldServer secondaryworldserver1 = (new SecondaryWorldServer(this, idatamanager, DimensionManager.THE_END, worldserver, this.methodProfiler)).i_();
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld()));
- this.worldServer.put(DimensionManager.THE_END, secondaryworldserver1);
- secondaryworldserver1.addIWorldAccess(new WorldManager(this, secondaryworldserver1));
- if (!this.H()) {
- secondaryworldserver1.getWorldData().setGameType(this.getGamemode());
- }
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld()));
+
+ world.addIWorldAccess(new WorldManager(this, world));
+ if (!this.H()) {
+ world.getWorldData().setGameType(this.getGamemode());
+ }
+
+ this.worldServer.put(world.dimension, world);
+ this.getPlayerList().setPlayerFileData(world);
- this.getPlayerList().setPlayerFileData(worldserver);
- if (worlddata.P() != null) {
- this.getBossBattleCustomData().a(worlddata.P());
+ this.worldServer.put(world.dimension, world);
+ this.getPlayerList().setPlayerFileData(world);
+
+ if (worlddata.P() != null) {
+ this.getBossBattleCustomData().a(worlddata.P());
+ }
@ -297,7 +298,7 @@
this.resourcePackRepository.a((ResourcePackSource) this.resourcePackFolder);
this.resourcePackRepository.a();
List<ResourcePackLoader> list = Lists.newArrayList();
@@ -320,42 +462,52 @@
@@ -320,42 +463,52 @@
boolean flag4 = true;
this.b((IChatBaseComponent) (new ChatMessage("menu.generatingTerrain", new Object[0])));
@ -343,7 +344,10 @@
+ CompletableFuture completablefuture = worldserver.getChunkProvider().a((Iterable) list, (chunk) -> {
+ set.add(chunk.getPos());
+ });
+
- throw new RuntimeException(executionexception.getCause());
- } catch (TimeoutException timeoutexception) {
- this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625);
+ while (!completablefuture.isDone()) {
+ try {
+ completablefuture.get(1L, TimeUnit.SECONDS);
@ -353,10 +357,7 @@
+ if (executionexception.getCause() instanceof RuntimeException) {
+ throw (RuntimeException) executionexception.getCause();
+ }
- throw new RuntimeException(executionexception.getCause());
- } catch (TimeoutException timeoutexception) {
- this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625);
+
+ throw new RuntimeException(executionexception.getCause());
+ } catch (TimeoutException timeoutexception) {
+ this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625);
@ -376,7 +377,7 @@
MinecraftServer.LOGGER.info("Time elapsed: {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS));
Iterator iterator = DimensionManager.b().iterator();
@@ -414,6 +566,10 @@
@@ -414,6 +567,10 @@
protected void l() {
this.w = null;
this.x = 0;
@ -387,7 +388,7 @@
}
protected void saveChunks(boolean flag) {
@@ -437,8 +593,24 @@
@@ -437,8 +594,24 @@
}
@ -413,7 +414,7 @@
if (this.getServerConnection() != null) {
this.getServerConnection().b();
}
@@ -447,6 +619,7 @@
@@ -447,6 +620,7 @@
MinecraftServer.LOGGER.info("Saving players");
this.playerList.savePlayers();
this.playerList.u();
@ -421,7 +422,7 @@
}
MinecraftServer.LOGGER.info("Saving worlds");
@@ -511,11 +684,13 @@
@@ -511,11 +685,13 @@
if (i > 2000L && this.nextTick - this.lastOverloadTime >= 15000L) {
long j = i / 50L;
@ -435,7 +436,7 @@
this.a(this::canSleepForTick);
this.nextTick += 50L;
@@ -554,6 +729,12 @@
@@ -554,6 +730,12 @@
} catch (Throwable throwable1) {
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
} finally {
@ -448,7 +449,7 @@
this.t();
}
@@ -622,7 +803,7 @@
@@ -622,7 +804,7 @@
this.m.b().a(agameprofile);
}
@ -457,7 +458,7 @@
this.methodProfiler.enter("save");
this.playerList.savePlayers();
this.saveChunks(true);
@@ -648,6 +829,7 @@
@@ -648,6 +830,7 @@
}
public void b(BooleanSupplier booleansupplier) {
@ -465,7 +466,7 @@
this.methodProfiler.enter("jobs");
FutureTask futuretask;
@@ -660,23 +842,40 @@
@@ -660,23 +843,40 @@
this.getFunctionData().tick();
this.methodProfiler.exitEnter("levels");
@ -512,7 +513,7 @@
this.methodProfiler.enter("tick");
@@ -727,10 +926,11 @@
@@ -727,10 +927,11 @@
this.k.add(itickable);
}
@ -525,7 +526,7 @@
boolean flag = true;
String s = null;
String s1 = ".";
@@ -778,13 +978,16 @@
@@ -778,13 +979,16 @@
++j;
}
}
@ -543,7 +544,7 @@
if (s != null) {
dedicatedserver.h(s);
}
@@ -822,6 +1025,29 @@
@@ -822,6 +1026,29 @@
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(MinecraftServer.LOGGER));
Runtime.getRuntime().addShutdownHook(thread);
@ -573,7 +574,7 @@
} catch (Exception exception) {
MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception);
}
@@ -833,11 +1059,13 @@
@@ -833,11 +1060,13 @@
}
public void v() {
@ -587,7 +588,7 @@
}
public File c(String s) {
@@ -877,7 +1105,7 @@
@@ -877,7 +1106,7 @@
}
public boolean isDebugging() {
@ -596,7 +597,7 @@
}
public void f(String s) {
@@ -892,7 +1120,7 @@
@@ -892,7 +1121,7 @@
}
public String getServerModName() {
@ -605,7 +606,7 @@
}
public CrashReport b(CrashReport crashreport) {
@@ -928,7 +1156,7 @@
@@ -928,7 +1157,7 @@
}
public boolean D() {
@ -614,7 +615,7 @@
}
public void sendMessage(IChatBaseComponent ichatbasecomponent) {
@@ -1068,7 +1296,7 @@
@@ -1068,7 +1297,7 @@
public abstract boolean Q();
public boolean getOnlineMode() {
@ -623,7 +624,7 @@
}
public void setOnlineMode(boolean flag) {
@@ -1228,7 +1456,7 @@
@@ -1228,7 +1457,7 @@
public <V> ListenableFuture<V> a(Callable<V> callable) {
Validate.notNull(callable);
@ -632,7 +633,7 @@
ListenableFutureTask<V> listenablefuturetask = ListenableFutureTask.create(callable);
this.f.add(listenablefuturetask);
@@ -1411,4 +1639,11 @@
@@ -1411,4 +1640,11 @@
return 0;
}
}