3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 12:30:06 +01:00

Misc bugfixes to multiworld support

Dieser Commit ist enthalten in:
md_5 2020-06-25 17:58:10 +10:00
Ursprung ca19c2f48e
Commit 8dc1da156f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: E8E901AC7C617C11
7 geänderte Dateien mit 164 neuen und 32 gelöschten Zeilen

Datei anzeigen

@ -30,9 +30,9 @@
+
+ return false;
+ }
+ // CraftBukkit end
+
+ public NBTTagCompound getChunkData(ResourceKey<World> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) throws IOException {
+ public NBTTagCompound getChunkData(ResourceKey<DimensionManager> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) throws IOException {
+ // CraftBukkit end
int i = a(nbttagcompound);
boolean flag = true;

Datei anzeigen

@ -101,7 +101,7 @@
Thread thread = new Thread("Server Shutdown Thread") {
public void run() {
dedicatedserver.safeShutdown(true);
@@ -157,6 +173,7 @@
@@ -157,14 +173,15 @@
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
Runtime.getRuntime().addShutdownHook(thread);
@ -109,11 +109,12 @@
} catch (Exception exception1) {
Main.LOGGER.fatal("Failed to start the minecraft server", exception1);
}
@@ -164,7 +181,7 @@
}
public static void convertWorld(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<World>> immutableset) {
- public static void convertWorld(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<World>> immutableset) {
- Main.LOGGER.info("Forcing world upgrade!");
+ public static void convertWorld(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<DimensionManager>> immutableset) { // CraftBukkit
+ Main.LOGGER.info("Forcing world upgrade! {}", convertable_conversionsession.getLevelName()); // CraftBukkit
WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, immutableset, flag);
IChatBaseComponent ichatbasecomponent = null;

Datei anzeigen

@ -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 @@
}

Datei anzeigen

@ -0,0 +1,41 @@
--- a/net/minecraft/server/PersistentStructureLegacy.java
+++ b/net/minecraft/server/PersistentStructureLegacy.java
@@ -14,7 +14,7 @@
public class PersistentStructureLegacy {
- private static final Map<String, String> a = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> {
+ private static final Map<String, String> a = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error
hashmap.put("Village", "Village");
hashmap.put("Mineshaft", "Mineshaft");
hashmap.put("Mansion", "Mansion");
@@ -27,7 +27,7 @@
hashmap.put("Fortress", "Fortress");
hashmap.put("EndCity", "EndCity");
});
- private static final Map<String, String> b = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> {
+ private static final Map<String, String> b = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error
hashmap.put("Iglu", "Igloo");
hashmap.put("TeDP", "Desert_Pyramid");
hashmap.put("TeJP", "Jungle_Pyramid");
@@ -228,16 +228,16 @@
}
}
- public static PersistentStructureLegacy a(ResourceKey<World> resourcekey, @Nullable WorldPersistentData worldpersistentdata) {
- if (resourcekey == World.OVERWORLD) {
+ public static PersistentStructureLegacy a(ResourceKey<DimensionManager> resourcekey, @Nullable WorldPersistentData worldpersistentdata) { // CraftBukkit
+ if (resourcekey == DimensionManager.OVERWORLD) { // CraftBukkit
return new PersistentStructureLegacy(worldpersistentdata, ImmutableList.of("Monument", "Stronghold", "Village", "Mineshaft", "Temple", "Mansion"), ImmutableList.of("Village", "Mineshaft", "Mansion", "Igloo", "Desert_Pyramid", "Jungle_Pyramid", "Swamp_Hut", "Stronghold", "Monument"));
} else {
ImmutableList immutablelist;
- if (resourcekey == World.THE_NETHER) {
+ if (resourcekey == DimensionManager.THE_NETHER) { // CraftBukkit
immutablelist = ImmutableList.of("Fortress");
return new PersistentStructureLegacy(worldpersistentdata, immutablelist, immutablelist);
- } else if (resourcekey == World.THE_END) {
+ } else if (resourcekey == DimensionManager.THE_END) { // CraftBukkit
immutablelist = ImmutableList.of("EndCity");
return new PersistentStructureLegacy(worldpersistentdata, immutablelist, immutablelist);
} else {

Datei anzeigen

@ -122,7 +122,7 @@
NBTTagCompound nbttagcompound = this.read(chunkcoordintpair);
- return nbttagcompound == null ? null : this.getChunkData(this.world.getDimensionKey(), this.l, nbttagcompound);
+ return nbttagcompound == null ? null : this.getChunkData(this.world.getDimensionKey(), this.l, nbttagcompound, chunkcoordintpair, world); // CraftBukkit
+ return nbttagcompound == null ? null : this.getChunkData(this.world.getTypeKey(), this.l, nbttagcompound, chunkcoordintpair, world); // CraftBukkit
}
boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) {

Datei anzeigen

@ -1,5 +1,77 @@
--- a/net/minecraft/server/WorldUpgrader.java
+++ b/net/minecraft/server/WorldUpgrader.java
@@ -25,7 +25,7 @@
private static final Logger LOGGER = LogManager.getLogger();
private static final ThreadFactory b = (new ThreadFactoryBuilder()).setDaemon(true).build();
- private final ImmutableSet<ResourceKey<World>> c;
+ private final ImmutableSet<ResourceKey<DimensionManager>> c; // CraftBukkit
private final boolean d;
private final Convertable.ConversionSession e;
private final Thread f;
@@ -36,12 +36,12 @@
private volatile int k;
private volatile int l;
private volatile int m;
- private final Object2FloatMap<ResourceKey<World>> n = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k()));
+ private final Object2FloatMap<ResourceKey<DimensionManager>> n = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k())); // CraftBukkit
private volatile IChatBaseComponent o = new ChatMessage("optimizeWorld.stage.counting");
private static final Pattern p = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
private final WorldPersistentData q;
- public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, ImmutableSet<ResourceKey<World>> immutableset, boolean flag) {
+ public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, ImmutableSet<ResourceKey<DimensionManager>> immutableset, boolean flag) { // CraftBukkit
this.c = immutableset;
this.d = flag;
this.g = datafixer;
@@ -69,12 +69,12 @@
private void i() {
this.k = 0;
- Builder<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder();
+ Builder<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder(); // CraftBukkit
List list;
for (UnmodifiableIterator unmodifiableiterator = this.c.iterator(); unmodifiableiterator.hasNext(); this.k += list.size()) {
- ResourceKey<World> resourcekey = (ResourceKey) unmodifiableiterator.next();
+ ResourceKey<DimensionManager> resourcekey = (ResourceKey) unmodifiableiterator.next(); // CraftBukkit
list = this.b(resourcekey);
builder.put(resourcekey, list.listIterator());
@@ -84,18 +84,18 @@
this.i = true;
} else {
float f = (float) this.k;
- ImmutableMap<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> immutablemap = builder.build();
- Builder<ResourceKey<World>, IChunkLoader> builder1 = ImmutableMap.builder();
+ ImmutableMap<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> immutablemap = builder.build(); // CraftBukkit
+ Builder<ResourceKey<DimensionManager>, IChunkLoader> builder1 = ImmutableMap.builder(); // CraftBukkit
UnmodifiableIterator unmodifiableiterator1 = this.c.iterator();
while (unmodifiableiterator1.hasNext()) {
- ResourceKey<World> resourcekey1 = (ResourceKey) unmodifiableiterator1.next();
- File file = this.e.a(resourcekey1);
+ ResourceKey<DimensionManager> resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); // CraftBukkit
+ File file = this.e.a(null); // CraftBukkit
builder1.put(resourcekey1, new IChunkLoader(new File(file, "region"), this.g, true));
}
- ImmutableMap<ResourceKey<World>, IChunkLoader> immutablemap1 = builder1.build();
+ ImmutableMap<ResourceKey<DimensionManager>, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit
long i = SystemUtils.getMonotonicMillis();
this.o = new ChatMessage("optimizeWorld.stage.upgrading");
@@ -107,7 +107,7 @@
float f2;
for (UnmodifiableIterator unmodifiableiterator2 = this.c.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) {
- ResourceKey<World> resourcekey2 = (ResourceKey) unmodifiableiterator2.next();
+ ResourceKey<DimensionManager> resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); // CraftBukkit
ListIterator<ChunkCoordIntPair> listiterator = (ListIterator) immutablemap.get(resourcekey2);
IChunkLoader ichunkloader = (IChunkLoader) immutablemap1.get(resourcekey2);
@@ -122,7 +122,7 @@
int j = IChunkLoader.a(nbttagcompound);
NBTTagCompound nbttagcompound1 = ichunkloader.getChunkData(resourcekey2, () -> {
@ -9,3 +81,14 @@
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("Level");
ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound2.getInt("xPos"), nbttagcompound2.getInt("zPos"));
@@ -195,8 +195,8 @@
}
}
- private List<ChunkCoordIntPair> b(ResourceKey<World> resourcekey) {
- File file = this.e.a(resourcekey);
+ private List<ChunkCoordIntPair> b(ResourceKey<DimensionManager> resourcekey) { // CraftBukkit
+ File file = this.e.a(null); // CraftBukkit
File file1 = new File(file, "region");
File[] afile = file1.listFiles((file2, s) -> {
return s.endsWith(".mca");

Datei anzeigen

@ -4,6 +4,7 @@ import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.MapMaker;
@ -985,12 +986,15 @@ public final class CraftServer implements Server {
worldSettings = new WorldSettings(name, EnumGamemode.getById(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration);
worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable());
}
worlddata.checkName(name);
worlddata.a(console.getServerModName(), console.getModded().isPresent());
if (console.options.has("forceUpgrade")) {
net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), console.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()));
}
long j = BiomeManager.a(creator.seed());