SPIGOT-6823: Fix loading custom world in combination with superflat

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2021-12-03 08:34:38 +11:00
parent 215251ce7b
commit ea74321d65
2 changed files with 30 additions and 30 deletions

View file

@ -28,12 +28,13 @@
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ICommandListener, AutoCloseable {
public static final Logger LOGGER = LogManager.getLogger();
@@ -252,6 +273,20 @@
@@ -252,6 +273,21 @@
protected SaveData worldData;
private volatile boolean isSaving;
+ // CraftBukkit start
+ public DataPackConfiguration datapackconfiguration;
+ public final DataPackConfiguration datapackconfiguration;
+ public final RegistryReadOps<NBTBase> registryreadops;
+ public org.bukkit.craftbukkit.CraftServer server;
+ public OptionSet options;
+ public org.bukkit.command.ConsoleCommandSender console;
@ -49,7 +50,7 @@
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
AtomicReference<S> atomicreference = new AtomicReference();
Thread thread = new Thread(() -> {
@@ -265,14 +300,14 @@
@@ -265,14 +301,14 @@
thread.setPriority(8);
}
@ -66,7 +67,7 @@
super("Server");
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
this.profiler = this.metricsRecorder.getProfiler();
@@ -284,7 +319,7 @@
@@ -284,7 +320,7 @@
this.status = new ServerPing();
this.random = new Random();
this.port = -1;
@ -75,13 +76,14 @@
this.running = true;
this.tickTimes = new long[100];
this.resourcePack = "";
@@ -314,13 +349,40 @@
@@ -314,13 +350,41 @@
this.structureManager = new DefinedStructureManager(datapackresources.getResourceManager(), convertable_conversionsession, datafixer);
this.serverThread = thread;
this.executor = SystemUtils.backgroundExecutor();
+ // CraftBukkit start
+ this.options = options;
+ this.datapackconfiguration = datapackconfiguration;
+ this.registryreadops = RegistryReadOps.createAndLoad(DynamicOpsNBT.INSTANCE, datapackresources.getResourceManager(), iregistrycustom_dimension);
+ this.vanillaCommandDispatcher = datapackresources.commands; // CraftBukkit
+ // Try to see if we're actually running in a terminal, disable jline if not
+ if (System.console() == null && System.getProperty("jline.terminal") == null) {
@ -117,7 +119,7 @@
ScoreboardServer scoreboardserver1 = this.getScoreboard();
Objects.requireNonNull(scoreboardserver1);
@@ -329,7 +391,7 @@
@@ -329,7 +393,7 @@
protected abstract boolean initServer() throws IOException;
@ -126,7 +128,7 @@
if (!JvmProfiler.INSTANCE.isRunning()) {
;
}
@@ -337,13 +399,8 @@
@@ -337,13 +401,8 @@
boolean flag = false;
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
@ -141,7 +143,7 @@
if (profiledduration != null) {
profiledduration.finish();
}
@@ -358,35 +415,204 @@
@@ -358,35 +417,203 @@
}
@ -150,7 +152,6 @@
+ private void loadWorld0(String s) {
+ Convertable.ConversionSession worldSession = this.storageSource;
+ IRegistryCustom.Dimension iregistrycustom_dimension = this.registryHolder;
+ RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.createAndLoad(DynamicOpsNBT.INSTANCE, this.resources.getResourceManager(), iregistrycustom_dimension);
+ WorldDataServer overworldData = (WorldDataServer) worldSession.getDataTag(registryreadops, datapackconfiguration);
+ if (overworldData == null) {
+ WorldSettings worldsettings;
@ -370,7 +371,7 @@
WorldBorder worldborder = worldserver.getWorldBorder();
if (!iworlddataserver.isInitialized()) {
@@ -411,31 +637,10 @@
@@ -411,31 +638,10 @@
iworlddataserver.setInitialized(true);
}
@ -404,7 +405,7 @@
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
if (flag1) {
@@ -443,6 +648,21 @@
@@ -443,6 +649,21 @@
} else {
ChunkGenerator chunkgenerator = worldserver.getChunkSource().getGenerator();
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkgenerator.climateSampler().findSpawnPosition());
@ -426,7 +427,7 @@
int i = chunkgenerator.getSpawnHeight(worldserver);
if (i < worldserver.getMinBuildHeight()) {
@@ -500,8 +720,15 @@
@@ -500,8 +721,15 @@
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
}
@ -444,7 +445,7 @@
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
BlockPosition blockposition = worldserver.getSharedSpawnPos();
@@ -514,16 +741,20 @@
@@ -514,16 +742,20 @@
chunkproviderserver.addRegionTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE);
while (chunkproviderserver.getTickingGenerated() != 441) {
@ -473,7 +474,7 @@
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks");
if (forcedchunk != null) {
@@ -538,11 +769,18 @@
@@ -538,11 +770,18 @@
}
}
@ -495,7 +496,7 @@
}
protected void detectBundledResources() {
@@ -587,12 +825,16 @@
@@ -587,12 +826,16 @@
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
}
@ -512,7 +513,7 @@
if (flag1) {
Iterator iterator1 = this.getAllLevels().iterator();
@@ -627,8 +869,29 @@
@@ -627,8 +870,29 @@
this.stopServer();
}
@ -542,7 +543,7 @@
if (this.getConnection() != null) {
this.getConnection().stop();
}
@@ -638,6 +901,7 @@
@@ -638,6 +902,7 @@
MinecraftServer.LOGGER.info("Saving players");
this.playerList.saveAll();
this.playerList.removeAll();
@ -550,7 +551,7 @@
}
MinecraftServer.LOGGER.info("Saving worlds");
@@ -712,9 +976,10 @@
@@ -712,9 +977,10 @@
while (this.running) {
long i = SystemUtils.getMillis() - this.nextTickTime;
@ -562,7 +563,7 @@
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
this.nextTickTime += j * 50L;
this.lastOverloadWarning = this.nextTickTime;
@@ -725,6 +990,7 @@
@@ -725,6 +991,7 @@
this.debugCommandProfiler = new MinecraftServer.a(SystemUtils.getNanos(), this.tickCount);
}
@ -570,7 +571,7 @@
this.nextTickTime += 50L;
this.startMetricsRecordingTick();
this.profiler.push("tick");
@@ -775,6 +1041,12 @@
@@ -775,6 +1042,12 @@
this.profileCache.clearExecutor();
}
@ -583,7 +584,7 @@
this.onServerExit();
}
@@ -783,8 +1055,15 @@
@@ -783,8 +1056,15 @@
}
private boolean haveTime() {
@ -600,7 +601,7 @@
protected void waitUntilNextTick() {
this.runAllTasks();
@@ -830,7 +1109,7 @@
@@ -830,7 +1110,7 @@
}
}
@ -609,7 +610,7 @@
this.getProfiler().incrementCounter("runTask");
super.doRunTask(ticktask);
}
@@ -901,7 +1180,7 @@
@@ -901,7 +1181,7 @@
}
}
@ -618,7 +619,7 @@
MinecraftServer.LOGGER.debug("Autosave started");
this.profiler.push("save");
this.saveEverything(true, false, false);
@@ -920,22 +1199,39 @@
@@ -920,22 +1200,39 @@
}
public void tickChildren(BooleanSupplier booleansupplier) {
@ -658,7 +659,7 @@
this.profiler.push("tick");
@@ -1024,7 +1320,7 @@
@@ -1024,7 +1321,7 @@
@DontObfuscate
public String getServerModName() {
@ -667,7 +668,7 @@
}
public SystemReport fillSystemReport(SystemReport systemreport) {
@@ -1354,16 +1650,17 @@
@@ -1354,16 +1651,17 @@
public CompletableFuture<Void> reloadResources(Collection<String> collection) {
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
@ -687,7 +688,7 @@
this.packRepository.setSelected(collection);
this.worldData.setDataPackConfig(getSelectedPacks(this.packRepository));
datapackresources.updateGlobals();
@@ -1717,7 +2014,7 @@
@@ -1717,7 +2015,7 @@
try {
label51:
{
@ -696,7 +697,7 @@
try {
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
@@ -1767,6 +2064,22 @@
@@ -1767,6 +2065,22 @@
}

View file

@ -1033,8 +1033,7 @@ public final class CraftServer implements Server {
boolean hardcore = creator.hardcore();
RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.createAndLoad(DynamicOpsNBT.INSTANCE, console.resources.getResourceManager(), console.registryHolder);
WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag(registryreadops, console.datapackconfiguration);
WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag(console.registryreadops, console.datapackconfiguration);
WorldSettings worldSettings;
// See MinecraftServer.a(String, String, long, WorldType, JsonElement)