Misc bugfixes to multiworld support

This commit is contained in:
md_5
2020-06-25 17:58:10 +10:00
parent ca19c2f48e
commit 8dc1da156f
7 changed files with 164 additions and 32 deletions

View File

@@ -9,11 +9,12 @@
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.Unpooled;
@@ -54,6 +56,14 @@
@@ -54,6 +56,15 @@
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import com.google.common.collect.ImmutableSet;
+import jline.console.ConsoleReader;
+import joptsimple.OptionSet;
+import org.bukkit.Bukkit;
@@ -24,7 +25,7 @@
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable {
@@ -73,7 +83,7 @@
@@ -73,7 +84,7 @@
public final DataFixer dataConverterManager;
private String serverIp;
private int serverPort;
@@ -33,7 +34,7 @@
public final Map<ResourceKey<World>, WorldServer> worldServer;
private PlayerList playerList;
private volatile boolean isRunning;
@@ -124,6 +134,21 @@
@@ -124,6 +135,21 @@
private final DefinedStructureManager ak;
protected SaveData saveData;
@@ -55,7 +56,7 @@
public static <S extends MinecraftServer> S a(Function<Thread, S> function) {
AtomicReference<S> atomicreference = new AtomicReference();
Thread thread = new Thread(() -> {
@@ -133,21 +158,21 @@
@@ -133,21 +159,21 @@
thread.setUncaughtExceptionHandler((thread1, throwable) -> {
MinecraftServer.LOGGER.error(throwable);
});
@@ -80,7 +81,7 @@
this.isRunning = true;
this.h = new long[100];
this.K = "";
@@ -173,7 +198,34 @@
@@ -173,7 +199,34 @@
this.ak = new DefinedStructureManager(datapackresources.h(), convertable_conversionsession, datafixer);
this.serverThread = thread;
this.executorService = SystemUtils.f();
@@ -115,7 +116,7 @@
private void initializeScoreboards(WorldPersistentData worldpersistentdata) {
PersistentScoreboard persistentscoreboard = (PersistentScoreboard) worldpersistentdata.a(PersistentScoreboard::new, "scoreboard");
@@ -186,7 +238,7 @@
@@ -186,7 +239,7 @@
public static void convertWorld(Convertable.ConversionSession convertable_conversionsession) {
if (convertable_conversionsession.isConvertable()) {
@@ -124,7 +125,7 @@
convertable_conversionsession.convert(new IProgressUpdate() {
private long a = SystemUtils.getMonotonicMillis();
@@ -209,48 +261,185 @@
@@ -209,48 +262,187 @@
}
@@ -199,7 +200,9 @@
+ if (options.has("forceUpgrade")) {
+ net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), options.has("eraseCache"), () -> {
+ return true;
+ }, worlddata.getGeneratorSettings().g());
+ }, worlddata.getGeneratorSettings().e().c().stream().map((entry) -> {
+ return ResourceKey.a(IRegistry.ad, ((ResourceKey) entry.getKey()).a());
+ }).collect(ImmutableSet.toImmutableSet()));
+ }
+
+ IWorldDataServer iworlddataserver = worlddata;
@@ -344,7 +347,7 @@
WorldBorder worldborder = worldserver.getWorldBorder();
worldborder.a(iworlddataserver.q());
@@ -275,34 +464,8 @@
@@ -275,34 +467,8 @@
iworlddataserver.c(true);
}
@@ -380,7 +383,7 @@
private static void a(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1, boolean flag2) {
ChunkGenerator chunkgenerator = worldserver.getChunkProvider().getChunkGenerator();
@@ -317,6 +480,21 @@
@@ -317,6 +483,21 @@
Random random = new Random(worldserver.getSeed());
BlockPosition blockposition = worldchunkmanager.a(0, worldserver.getSeaLevel(), 0, 256, list, random);
ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition);
@@ -402,7 +405,7 @@
if (blockposition == null) {
MinecraftServer.LOGGER.warn("Unable to find spawn biome");
@@ -363,7 +541,7 @@
@@ -363,7 +544,7 @@
}
if (flag) {
@@ -411,7 +414,7 @@
worldgenfeatureconfigured.a(worldserver, worldserver.getStructureManager(), chunkgenerator, worldserver.random, new BlockPosition(iworlddataserver.a(), iworlddataserver.b(), iworlddataserver.c()));
}
@@ -383,8 +561,15 @@
@@ -383,8 +564,15 @@
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
}
@@ -429,7 +432,7 @@
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.getDimensionKey().a());
BlockPosition blockposition = worldserver.getSpawn();
@@ -397,17 +582,21 @@
@@ -397,17 +585,21 @@
chunkproviderserver.addTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE);
while (chunkproviderserver.b() != 441) {
@@ -460,7 +463,7 @@
if (forcedchunk != null) {
LongIterator longiterator = forcedchunk.a().iterator();
@@ -421,11 +610,17 @@
@@ -421,11 +613,17 @@
}
}
@@ -480,7 +483,7 @@
}
protected void loadResourcesZip() {
@@ -470,12 +665,16 @@
@@ -470,12 +668,16 @@
worldserver.save((IProgressUpdate) null, flag1, worldserver.savingDisabled && !flag2);
}
@@ -497,7 +500,7 @@
return flag3;
}
@@ -484,8 +683,29 @@
@@ -484,8 +686,29 @@
this.stop();
}
@@ -527,7 +530,7 @@
if (this.getServerConnection() != null) {
this.getServerConnection().b();
}
@@ -494,6 +714,7 @@
@@ -494,6 +717,7 @@
MinecraftServer.LOGGER.info("Saving players");
this.playerList.savePlayers();
this.playerList.shutdown();
@@ -535,7 +538,7 @@
}
MinecraftServer.LOGGER.info("Saving worlds");
@@ -571,14 +792,16 @@
@@ -571,14 +795,16 @@
while (this.isRunning) {
long i = SystemUtils.getMonotonicMillis() - this.nextTick;
@@ -553,7 +556,7 @@
this.nextTick += 50L;
GameProfilerTick gameprofilertick = GameProfilerTick.a("Server");
@@ -624,6 +847,12 @@
@@ -624,6 +850,12 @@
} catch (Throwable throwable1) {
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
} finally {
@@ -566,7 +569,7 @@
this.exit();
}
@@ -632,8 +861,15 @@
@@ -632,8 +864,15 @@
}
private boolean canSleepForTick() {
@@ -583,7 +586,7 @@
protected void sleepForTick() {
this.executeAll();
@@ -739,7 +975,7 @@
@@ -739,7 +978,7 @@
this.serverPing.b().a(agameprofile);
}
@@ -592,7 +595,7 @@
MinecraftServer.LOGGER.debug("Autosave started");
this.methodProfiler.enter("save");
this.playerList.savePlayers();
@@ -769,22 +1005,39 @@
@@ -769,22 +1008,39 @@
}
protected void b(BooleanSupplier booleansupplier) {
@@ -632,7 +635,7 @@
this.methodProfiler.enter("tick");
@@ -868,7 +1121,7 @@
@@ -868,7 +1124,7 @@
}
public String getServerModName() {
@@ -641,7 +644,7 @@
}
public CrashReport b(CrashReport crashreport) {
@@ -1217,11 +1470,11 @@
@@ -1217,11 +1473,11 @@
public CompletableFuture<Void> a(Collection<String> collection) {
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
@@ -655,7 +658,7 @@
}, this).thenCompose((immutablelist) -> {
return DataPackResources.a(immutablelist, this.j() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.h(), this.executorService, this);
}).thenAcceptAsync((datapackresources) -> {
@@ -1592,6 +1845,22 @@
@@ -1592,6 +1848,22 @@
}