mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
Put world into worldlist before initing the world
Some parts of legacy conversion will need the overworld to get the legacy structure data storage
This commit is contained in:
parent
b854576e5d
commit
299d7beee0
2 changed files with 52 additions and 48 deletions
|
@ -308,7 +308,7 @@
|
|||
if (profiledduration != null) {
|
||||
profiledduration.finish(true);
|
||||
}
|
||||
@@ -387,23 +468,240 @@
|
||||
@@ -387,23 +468,241 @@
|
||||
|
||||
protected void forceDifficulty() {}
|
||||
|
||||
|
@ -515,9 +515,10 @@
|
|||
+ }
|
||||
+
|
||||
+ worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());
|
||||
+ this.addLevel(world); // Paper - Put world into worldlist before initing the world; move up
|
||||
+ this.initWorld(world, worlddata, this.worldData, worldoptions);
|
||||
+
|
||||
+ this.addLevel(world);
|
||||
+ // Paper - Put world into worldlist before initing the world; move up
|
||||
+ this.getPlayerList().addWorldborderListener(world);
|
||||
+
|
||||
+ if (worlddata.getCustomBossEvents() != null) {
|
||||
|
@ -563,10 +564,12 @@
|
|||
|
||||
if (!iworlddataserver.isInitialized()) {
|
||||
try {
|
||||
@@ -427,30 +725,8 @@
|
||||
iworlddataserver.setInitialized(true);
|
||||
@@ -425,32 +724,10 @@
|
||||
}
|
||||
|
||||
iworlddataserver.setInitialized(true);
|
||||
- }
|
||||
-
|
||||
- this.getPlayerList().addWorldborderListener(worldserver);
|
||||
- if (this.worldData.getCustomBossEvents() != null) {
|
||||
- this.getCustomBossEvents().load(this.worldData.getCustomBossEvents(), this.registryAccess());
|
||||
|
@ -587,15 +590,15 @@
|
|||
- worldborder.addListener(new BorderChangeListener.DelegateBorderChangeListener(worldserver1.getWorldBorder()));
|
||||
- this.levels.put(resourcekey1, worldserver1);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
}
|
||||
|
||||
- worldborder.applySettings(iworlddataserver.getWorldBorder());
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
private static void setInitialSpawn(ServerLevel world, ServerLevelData worldProperties, boolean bonusChest, boolean debugWorld) {
|
||||
if (debugWorld) {
|
||||
@@ -458,6 +734,21 @@
|
||||
@@ -458,6 +735,21 @@
|
||||
} else {
|
||||
ServerChunkCache chunkproviderserver = world.getChunkSource();
|
||||
ChunkPos chunkcoordintpair = new ChunkPos(chunkproviderserver.randomState().sampler().findSpawnPosition());
|
||||
|
@ -617,7 +620,7 @@
|
|||
int i = chunkproviderserver.getGenerator().getSpawnHeight(world);
|
||||
|
||||
if (i < world.getMinY()) {
|
||||
@@ -516,31 +807,36 @@
|
||||
@@ -516,31 +808,36 @@
|
||||
iworlddataserver.setGameType(GameType.SPECTATOR);
|
||||
}
|
||||
|
||||
|
@ -665,7 +668,7 @@
|
|||
ForcedChunksSavedData forcedchunk = (ForcedChunksSavedData) worldserver1.getDataStorage().get(ForcedChunksSavedData.factory(), "chunks");
|
||||
|
||||
if (forcedchunk != null) {
|
||||
@@ -555,10 +851,17 @@
|
||||
@@ -555,10 +852,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -687,7 +690,7 @@
|
|||
}
|
||||
|
||||
public GameType getDefaultGameType() {
|
||||
@@ -588,12 +891,16 @@
|
||||
@@ -588,12 +892,16 @@
|
||||
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force);
|
||||
}
|
||||
|
||||
|
@ -706,7 +709,7 @@
|
|||
if (flush) {
|
||||
Iterator iterator1 = this.getAllLevels().iterator();
|
||||
|
||||
@@ -628,18 +935,45 @@
|
||||
@@ -628,18 +936,45 @@
|
||||
this.stopServer();
|
||||
}
|
||||
|
||||
|
@ -753,7 +756,7 @@
|
|||
}
|
||||
|
||||
MinecraftServer.LOGGER.info("Saving worlds");
|
||||
@@ -693,6 +1027,15 @@
|
||||
@@ -693,6 +1028,15 @@
|
||||
} catch (IOException ioexception1) {
|
||||
MinecraftServer.LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), ioexception1);
|
||||
}
|
||||
|
@ -769,7 +772,7 @@
|
|||
|
||||
}
|
||||
|
||||
@@ -709,6 +1052,14 @@
|
||||
@@ -709,6 +1053,14 @@
|
||||
}
|
||||
|
||||
public void halt(boolean waitForShutdown) {
|
||||
|
@ -784,7 +787,7 @@
|
|||
this.running = false;
|
||||
if (waitForShutdown) {
|
||||
try {
|
||||
@@ -720,6 +1071,64 @@
|
||||
@@ -720,6 +1072,64 @@
|
||||
|
||||
}
|
||||
|
||||
|
@ -849,7 +852,7 @@
|
|||
protected void runServer() {
|
||||
try {
|
||||
if (!this.initServer()) {
|
||||
@@ -727,9 +1136,16 @@
|
||||
@@ -727,9 +1137,16 @@
|
||||
}
|
||||
|
||||
this.nextTickTimeNanos = Util.getNanos();
|
||||
|
@ -867,7 +870,7 @@
|
|||
while (this.running) {
|
||||
long i;
|
||||
|
||||
@@ -744,12 +1160,31 @@
|
||||
@@ -744,12 +1161,31 @@
|
||||
if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) {
|
||||
long k = j / i;
|
||||
|
||||
|
@ -899,7 +902,7 @@
|
|||
boolean flag = i == 0L;
|
||||
|
||||
if (this.debugCommandProfilerDelayStart) {
|
||||
@@ -757,6 +1192,8 @@
|
||||
@@ -757,6 +1193,8 @@
|
||||
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount);
|
||||
}
|
||||
|
||||
|
@ -908,7 +911,7 @@
|
|||
this.nextTickTimeNanos += i;
|
||||
|
||||
try {
|
||||
@@ -830,6 +1267,13 @@
|
||||
@@ -830,6 +1268,13 @@
|
||||
this.services.profileCache().clearExecutor();
|
||||
}
|
||||
|
||||
|
@ -922,7 +925,7 @@
|
|||
this.onServerExit();
|
||||
}
|
||||
|
||||
@@ -889,9 +1333,16 @@
|
||||
@@ -889,9 +1334,16 @@
|
||||
}
|
||||
|
||||
private boolean haveTime() {
|
||||
|
@ -940,7 +943,7 @@
|
|||
public static boolean throwIfFatalException() {
|
||||
RuntimeException runtimeexception = (RuntimeException) MinecraftServer.fatalException.get();
|
||||
|
||||
@@ -903,7 +1354,7 @@
|
||||
@@ -903,7 +1355,7 @@
|
||||
}
|
||||
|
||||
public static void setFatalException(RuntimeException exception) {
|
||||
|
@ -949,7 +952,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -961,6 +1412,7 @@
|
||||
@@ -961,6 +1413,7 @@
|
||||
if (super.pollTask()) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -957,7 +960,7 @@
|
|||
if (this.tickRateManager.isSprinting() || this.haveTime()) {
|
||||
Iterator iterator = this.getAllLevels().iterator();
|
||||
|
||||
@@ -968,16 +1420,16 @@
|
||||
@@ -968,16 +1421,16 @@
|
||||
ServerLevel worldserver = (ServerLevel) iterator.next();
|
||||
|
||||
if (worldserver.getChunkSource().pollTask()) {
|
||||
|
@ -977,7 +980,7 @@
|
|||
Profiler.get().incrementCounter("runTask");
|
||||
super.doRunTask(ticktask);
|
||||
}
|
||||
@@ -1025,6 +1477,7 @@
|
||||
@@ -1025,6 +1478,7 @@
|
||||
}
|
||||
|
||||
public void tickServer(BooleanSupplier shouldKeepTicking) {
|
||||
|
@ -985,7 +988,7 @@
|
|||
long i = Util.getNanos();
|
||||
int j = this.pauseWhileEmptySeconds() * 20;
|
||||
|
||||
@@ -1041,11 +1494,13 @@
|
||||
@@ -1041,11 +1495,13 @@
|
||||
this.autoSave();
|
||||
}
|
||||
|
||||
|
@ -999,7 +1002,7 @@
|
|||
++this.tickCount;
|
||||
this.tickRateManager.tick();
|
||||
this.tickChildren(shouldKeepTicking);
|
||||
@@ -1055,12 +1510,18 @@
|
||||
@@ -1055,12 +1511,18 @@
|
||||
}
|
||||
|
||||
--this.ticksUntilAutosave;
|
||||
|
@ -1019,7 +1022,7 @@
|
|||
gameprofilerfiller.push("tallying");
|
||||
long k = Util.getNanos() - i;
|
||||
int l = this.tickCount % 100;
|
||||
@@ -1069,12 +1530,17 @@
|
||||
@@ -1069,12 +1531,17 @@
|
||||
this.aggregatedTickTimesNanos += k;
|
||||
this.tickTimesNanos[l] = k;
|
||||
this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float) k / (float) TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F;
|
||||
|
@ -1038,7 +1041,7 @@
|
|||
MinecraftServer.LOGGER.debug("Autosave started");
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
@@ -1123,7 +1589,7 @@
|
||||
@@ -1123,7 +1590,7 @@
|
||||
private ServerStatus buildServerStatus() {
|
||||
ServerStatus.Players serverping_serverpingplayersample = this.buildPlayerStatus();
|
||||
|
||||
|
@ -1047,7 +1050,7 @@
|
|||
}
|
||||
|
||||
private ServerStatus.Players buildPlayerStatus() {
|
||||
@@ -1133,7 +1599,7 @@
|
||||
@@ -1133,7 +1600,7 @@
|
||||
if (this.hidesOnlinePlayers()) {
|
||||
return new ServerStatus.Players(i, list.size(), List.of());
|
||||
} else {
|
||||
|
@ -1056,7 +1059,7 @@
|
|||
ObjectArrayList<GameProfile> objectarraylist = new ObjectArrayList(j);
|
||||
int k = Mth.nextInt(this.random, 0, list.size() - j);
|
||||
|
||||
@@ -1154,24 +1620,56 @@
|
||||
@@ -1154,24 +1621,56 @@
|
||||
this.getPlayerList().getPlayers().forEach((entityplayer) -> {
|
||||
entityplayer.connection.suspendFlushing();
|
||||
});
|
||||
|
@ -1113,7 +1116,7 @@
|
|||
|
||||
gameprofilerfiller.push("tick");
|
||||
|
||||
@@ -1186,6 +1684,7 @@
|
||||
@@ -1186,6 +1685,7 @@
|
||||
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.pop();
|
||||
|
@ -1121,7 +1124,7 @@
|
|||
}
|
||||
|
||||
gameprofilerfiller.popPush("connection");
|
||||
@@ -1267,6 +1766,22 @@
|
||||
@@ -1267,6 +1767,22 @@
|
||||
return (ServerLevel) this.levels.get(key);
|
||||
}
|
||||
|
||||
|
@ -1144,7 +1147,7 @@
|
|||
public Set<ResourceKey<Level>> levelKeys() {
|
||||
return this.levels.keySet();
|
||||
}
|
||||
@@ -1296,7 +1811,7 @@
|
||||
@@ -1296,7 +1812,7 @@
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
|
@ -1153,7 +1156,7 @@
|
|||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport details) {
|
||||
@@ -1347,7 +1862,7 @@
|
||||
@@ -1347,7 +1863,7 @@
|
||||
|
||||
@Override
|
||||
public void sendSystemMessage(Component message) {
|
||||
|
@ -1162,7 +1165,7 @@
|
|||
}
|
||||
|
||||
public KeyPair getKeyPair() {
|
||||
@@ -1385,11 +1900,14 @@
|
||||
@@ -1385,11 +1901,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1182,7 +1185,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1403,7 +1921,7 @@
|
||||
@@ -1403,7 +1922,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
ServerLevel worldserver = (ServerLevel) iterator.next();
|
||||
|
||||
|
@ -1191,7 +1194,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -1481,10 +1999,20 @@
|
||||
@@ -1481,10 +2000,20 @@
|
||||
|
||||
@Override
|
||||
public String getMotd() {
|
||||
|
@ -1213,7 +1216,7 @@
|
|||
this.motd = motd;
|
||||
}
|
||||
|
||||
@@ -1507,7 +2035,7 @@
|
||||
@@ -1507,7 +2036,7 @@
|
||||
}
|
||||
|
||||
public ServerConnectionListener getConnection() {
|
||||
|
@ -1222,7 +1225,7 @@
|
|||
}
|
||||
|
||||
public boolean isReady() {
|
||||
@@ -1632,13 +2160,19 @@
|
||||
@@ -1632,13 +2161,19 @@
|
||||
return this.functionManager;
|
||||
}
|
||||
|
||||
|
@ -1244,7 +1247,7 @@
|
|||
}, this).thenCompose((immutablelist) -> {
|
||||
MultiPackResourceManager resourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, immutablelist);
|
||||
List<Registry.PendingTags<?>> list = TagLoader.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess());
|
||||
@@ -1654,6 +2188,7 @@
|
||||
@@ -1654,6 +2189,7 @@
|
||||
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
|
||||
this.resources.close();
|
||||
this.resources = minecraftserver_reloadableresources;
|
||||
|
@ -1252,7 +1255,7 @@
|
|||
this.packRepository.setSelected(dataPacks);
|
||||
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(MinecraftServer.getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures());
|
||||
|
||||
@@ -1665,6 +2200,8 @@
|
||||
@@ -1665,6 +2201,8 @@
|
||||
this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary());
|
||||
this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager);
|
||||
this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures());
|
||||
|
@ -1261,7 +1264,7 @@
|
|||
}, this);
|
||||
|
||||
if (this.isSameThread()) {
|
||||
@@ -1789,14 +2326,15 @@
|
||||
@@ -1789,14 +2327,15 @@
|
||||
if (this.isEnforceWhitelist()) {
|
||||
PlayerList playerlist = source.getServer().getPlayerList();
|
||||
UserWhiteList whitelist = playerlist.getWhiteList();
|
||||
|
@ -1279,7 +1282,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1952,7 +2490,7 @@
|
||||
@@ -1952,7 +2491,7 @@
|
||||
final List<String> list = Lists.newArrayList();
|
||||
final GameRules gamerules = this.getGameRules();
|
||||
|
||||
|
@ -1288,7 +1291,7 @@
|
|||
@Override
|
||||
public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type) {
|
||||
list.add(String.format(Locale.ROOT, "%s=%s\n", key.getId(), gamerules.getRule(key)));
|
||||
@@ -2058,7 +2596,7 @@
|
||||
@@ -2058,7 +2597,7 @@
|
||||
try {
|
||||
label51:
|
||||
{
|
||||
|
@ -1297,7 +1300,7 @@
|
|||
|
||||
try {
|
||||
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
||||
@@ -2105,9 +2643,24 @@
|
||||
@@ -2105,9 +2644,24 @@
|
||||
if (bufferedwriter != null) {
|
||||
bufferedwriter.close();
|
||||
}
|
||||
|
@ -1322,7 +1325,7 @@
|
|||
private ProfilerFiller createProfiler() {
|
||||
if (this.willStartRecordingMetrics) {
|
||||
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
|
||||
@@ -2225,18 +2778,24 @@
|
||||
@@ -2225,18 +2779,24 @@
|
||||
}
|
||||
|
||||
public void logChatMessage(Component message, ChatType.Bound params, @Nullable String prefix) {
|
||||
|
@ -1351,7 +1354,7 @@
|
|||
}
|
||||
|
||||
public boolean logIPs() {
|
||||
@@ -2379,4 +2938,30 @@
|
||||
@@ -2379,4 +2939,30 @@
|
||||
public static record ServerResourcePackInfo(UUID id, String url, String hash, boolean isRequired, @Nullable Component prompt) {
|
||||
|
||||
}
|
||||
|
|
|
@ -1336,10 +1336,11 @@ public final class CraftServer implements Server {
|
|||
return null;
|
||||
}
|
||||
|
||||
this.console.addLevel(internal); // Paper - Put world into worldlist before initing the world; move up
|
||||
this.console.initWorld(internal, worlddata, worlddata, worlddata.worldGenOptions());
|
||||
|
||||
internal.setSpawnSettings(true);
|
||||
this.console.addLevel(internal);
|
||||
// Paper - Put world into worldlist before initing the world; move up
|
||||
|
||||
this.getServer().prepareLevels(internal.getChunkSource().chunkMap.progressListener, internal);
|
||||
internal.entityManager.tick(); // SPIGOT-6526: Load pending entities so they are available to the API
|
||||
|
|
Loading…
Reference in a new issue