SPIGOT-5103: World.save does not save gamerules

This commit is contained in:
md_5 2019-06-25 21:02:13 +10:00
parent 3164e5312f
commit e8b39d430a
2 changed files with 58 additions and 41 deletions

View file

@ -263,17 +263,17 @@
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); + this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
+ this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP)); + this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP));
+ // CraftBukkit end + // CraftBukkit end
+
+ }
+
+ // CraftBukkit start
+ public void initWorld(WorldServer worldserver1, WorldData worlddata, WorldSettings worldsettings) {
+ worldserver1.getWorldBorder().b(worlddata);
- this.worldServer.put(DimensionManager.OVERWORLD, worldserver); - this.worldServer.put(DimensionManager.OVERWORLD, worldserver);
- this.initializeScoreboards(worldserver.getWorldPersistentData()); - this.initializeScoreboards(worldserver.getWorldPersistentData());
- worldserver.getWorldBorder().b(worlddata); - worldserver.getWorldBorder().b(worlddata);
- WorldServer worldserver1 = this.getWorldServer(DimensionManager.OVERWORLD); - WorldServer worldserver1 = this.getWorldServer(DimensionManager.OVERWORLD);
+ }
+
+ // CraftBukkit start
+ public void initWorld(WorldServer worldserver1, WorldData worlddata, WorldSettings worldsettings) {
+ worldserver1.getWorldBorder().b(worlddata);
+
+ // CraftBukkit start + // CraftBukkit start
+ if (worldserver1.generator != null) { + if (worldserver1.generator != null) {
+ worldserver1.getWorld().getPopulators().addAll(worldserver1.generator.getDefaultPopulators(worldserver1.getWorld())); + worldserver1.getWorld().getPopulators().addAll(worldserver1.generator.getDefaultPopulators(worldserver1.getWorld()));
@ -405,24 +405,24 @@
} }
protected void a(String s, WorldNBTStorage worldnbtstorage) { protected void a(String s, WorldNBTStorage worldnbtstorage) {
@@ -449,14 +627,14 @@ @@ -451,12 +629,16 @@
} catch (ExceptionWorldConflict exceptionworldconflict) { }
MinecraftServer.LOGGER.warn(exceptionworldconflict.getMessage());
} }
- }
- WorldServer worldserver1 = this.getWorldServer(DimensionManager.OVERWORLD); + // CraftBukkit start - moved to WorldServer.save
+ WorldServer worldserver1 = worldserver; // CraftBukkit + /*
WorldServer worldserver1 = this.getWorldServer(DimensionManager.OVERWORLD);
WorldData worlddata = worldserver1.getWorldData(); WorldData worlddata = worldserver1.getWorldData();
worldserver1.getWorldBorder().a(worlddata); worldserver1.getWorldBorder().a(worlddata);
worlddata.c(this.getBossBattleCustomData().c()); worlddata.c(this.getBossBattleCustomData().c());
worldserver1.getDataManager().saveWorldData(worlddata, this.getPlayerList().r()); worldserver1.getDataManager().saveWorldData(worlddata, this.getPlayerList().r());
+ } // CraftBukkit - moved down + */
+ // CraftBukkit end
return flag3; return flag3;
} }
@@ -465,8 +643,29 @@ @@ -465,8 +647,29 @@
this.stop(); this.stop();
} }
@ -452,7 +452,7 @@
if (this.getServerConnection() != null) { if (this.getServerConnection() != null) {
this.getServerConnection().b(); this.getServerConnection().b();
} }
@@ -475,6 +674,7 @@ @@ -475,6 +678,7 @@
MinecraftServer.LOGGER.info("Saving players"); MinecraftServer.LOGGER.info("Saving players");
this.playerList.savePlayers(); this.playerList.savePlayers();
this.playerList.shutdown(); this.playerList.shutdown();
@ -460,7 +460,7 @@
} }
MinecraftServer.LOGGER.info("Saving worlds"); MinecraftServer.LOGGER.info("Saving worlds");
@@ -544,14 +744,16 @@ @@ -544,14 +748,16 @@
while (this.isRunning) { while (this.isRunning) {
long i = SystemUtils.getMonotonicMillis() - this.nextTick; long i = SystemUtils.getMonotonicMillis() - this.nextTick;
@ -478,7 +478,7 @@
this.nextTick += 50L; this.nextTick += 50L;
if (this.S) { if (this.S) {
this.S = false; this.S = false;
@@ -598,6 +800,12 @@ @@ -598,6 +804,12 @@
} catch (Throwable throwable1) { } catch (Throwable throwable1) {
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
} finally { } finally {
@ -491,7 +491,7 @@
this.exit(); this.exit();
} }
@@ -606,8 +814,15 @@ @@ -606,8 +818,15 @@
} }
private boolean canSleepForTick() { private boolean canSleepForTick() {
@ -508,7 +508,7 @@
protected void sleepForTick() { protected void sleepForTick() {
this.executeAll(); this.executeAll();
@@ -708,7 +923,7 @@ @@ -708,7 +927,7 @@
this.serverPing.b().a(agameprofile); this.serverPing.b().a(agameprofile);
} }
@ -517,7 +517,7 @@
MinecraftServer.LOGGER.debug("Autosave started"); MinecraftServer.LOGGER.debug("Autosave started");
this.methodProfiler.enter("save"); this.methodProfiler.enter("save");
this.playerList.savePlayers(); this.playerList.savePlayers();
@@ -738,23 +953,40 @@ @@ -738,23 +957,40 @@
} }
protected void b(BooleanSupplier booleansupplier) { protected void b(BooleanSupplier booleansupplier) {
@ -559,7 +559,7 @@
this.methodProfiler.enter("tick"); this.methodProfiler.enter("tick");
@@ -793,7 +1025,8 @@ @@ -793,7 +1029,8 @@
this.tickables.add(runnable); this.tickables.add(runnable);
} }
@ -569,7 +569,7 @@
OptionParser optionparser = new OptionParser(); OptionParser optionparser = new OptionParser();
OptionSpec<Void> optionspec = optionparser.accepts("nogui"); OptionSpec<Void> optionspec = optionparser.accepts("nogui");
OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits");
@@ -816,15 +1049,17 @@ @@ -816,15 +1053,17 @@
optionparser.printHelpOn(System.err); optionparser.printHelpOn(System.err);
return; return;
} }
@ -589,7 +589,7 @@
MinecraftServer.LOGGER.info("Initialized '" + java_nio_file_path.toAbsolutePath().toString() + "' and '" + java_nio_file_path1.toAbsolutePath().toString() + "'"); MinecraftServer.LOGGER.info("Initialized '" + java_nio_file_path.toAbsolutePath().toString() + "' and '" + java_nio_file_path1.toAbsolutePath().toString() + "'");
return; return;
} }
@@ -836,14 +1071,15 @@ @@ -836,14 +1075,15 @@
DispenserRegistry.init(); DispenserRegistry.init();
DispenserRegistry.c(); DispenserRegistry.c();
@ -608,7 +608,7 @@
dedicatedserver.i((String) optionset.valueOf(optionspec7)); dedicatedserver.i((String) optionset.valueOf(optionspec7));
dedicatedserver.setPort((Integer) optionset.valueOf(optionspec10)); dedicatedserver.setPort((Integer) optionset.valueOf(optionspec10));
dedicatedserver.e(optionset.has(optionspec2)); dedicatedserver.e(optionset.has(optionspec2));
@@ -866,6 +1102,29 @@ @@ -866,6 +1106,29 @@
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(MinecraftServer.LOGGER)); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(MinecraftServer.LOGGER));
Runtime.getRuntime().addShutdownHook(thread); Runtime.getRuntime().addShutdownHook(thread);
@ -638,7 +638,7 @@
} catch (Exception exception) { } catch (Exception exception) {
MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception); MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception);
} }
@@ -885,7 +1144,9 @@ @@ -885,7 +1148,9 @@
} }
public void startServerThread() { public void startServerThread() {
@ -648,7 +648,7 @@
} }
public File d(String s) { public File d(String s) {
@@ -940,7 +1201,7 @@ @@ -940,7 +1205,7 @@
} }
public String getServerModName() { public String getServerModName() {
@ -657,7 +657,7 @@
} }
public CrashReport b(CrashReport crashreport) { public CrashReport b(CrashReport crashreport) {
@@ -979,7 +1240,7 @@ @@ -979,7 +1244,7 @@
} }
public boolean E() { public boolean E() {
@ -666,7 +666,7 @@
} }
@Override @Override
@@ -1482,4 +1743,16 @@ @@ -1482,4 +1747,16 @@
} }
public abstract boolean b(GameProfile gameprofile); public abstract boolean b(GameProfile gameprofile);

View file

@ -249,7 +249,24 @@
if (iprogressupdate != null) { if (iprogressupdate != null) {
iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0])); iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0]));
} }
@@ -715,8 +801,16 @@ @@ -648,6 +734,16 @@
chunkproviderserver.save(flag);
}
+
+ // CraftBukkit start - moved from MinecraftServer.saveChunks
+ // PAIL - rename
+ WorldServer worldserver1 = this;
+ WorldData worlddata = worldserver1.getWorldData();
+
+ worldserver1.getWorldBorder().a(worlddata);
+ worlddata.c(this.server.getBossBattleCustomData().c());
+ worldserver1.getDataManager().saveWorldData(worlddata, this.server.getPlayerList().r());
+ // CraftBukkit end
}
protected void k_() throws ExceptionWorldConflict {
@@ -715,8 +811,16 @@
while (objectiterator.hasNext()) { while (objectiterator.hasNext()) {
Entity entity = (Entity) objectiterator.next(); Entity entity = (Entity) objectiterator.next();
@ -267,7 +284,7 @@
EnumCreatureType enumcreaturetype = entity.getEntityType().d(); EnumCreatureType enumcreaturetype = entity.getEntityType().d();
if (enumcreaturetype != EnumCreatureType.MISC && this.getChunkProvider().b(entity)) { if (enumcreaturetype != EnumCreatureType.MISC && this.getChunkProvider().b(entity)) {
@@ -730,11 +824,24 @@ @@ -730,11 +834,24 @@
@Override @Override
public boolean addEntity(Entity entity) { public boolean addEntity(Entity entity) {
@ -294,7 +311,7 @@
} }
public void addEntityTeleport(Entity entity) { public void addEntityTeleport(Entity entity) {
@@ -784,13 +891,18 @@ @@ -784,13 +901,18 @@
this.registerEntity(entityplayer); this.registerEntity(entityplayer);
} }
@ -315,7 +332,7 @@
IChunkAccess ichunkaccess = this.getChunkAt(MathHelper.floor(entity.locX / 16.0D), MathHelper.floor(entity.locZ / 16.0D), ChunkStatus.FULL, entity.attachedToPlayer); IChunkAccess ichunkaccess = this.getChunkAt(MathHelper.floor(entity.locX / 16.0D), MathHelper.floor(entity.locZ / 16.0D), ChunkStatus.FULL, entity.attachedToPlayer);
if (!(ichunkaccess instanceof Chunk)) { if (!(ichunkaccess instanceof Chunk)) {
@@ -818,7 +930,7 @@ @@ -818,7 +940,7 @@
if (entity1 == null) { if (entity1 == null) {
return false; return false;
} else { } else {
@ -324,7 +341,7 @@
return true; return true;
} }
} }
@@ -873,6 +985,7 @@ @@ -873,6 +995,7 @@
this.I.remove(((EntityInsentient) entity).getNavigation()); this.I.remove(((EntityInsentient) entity).getNavigation());
} }
@ -332,7 +349,7 @@
} }
private void registerEntity(Entity entity) { private void registerEntity(Entity entity) {
@@ -896,6 +1009,7 @@ @@ -896,6 +1019,7 @@
if (entity instanceof EntityInsentient) { if (entity instanceof EntityInsentient) {
this.I.add(((EntityInsentient) entity).getNavigation()); this.I.add(((EntityInsentient) entity).getNavigation());
} }
@ -340,7 +357,7 @@
} }
} }
@@ -926,6 +1040,18 @@ @@ -926,6 +1050,18 @@
} }
public void strikeLightning(EntityLightning entitylightning) { public void strikeLightning(EntityLightning entitylightning) {
@ -359,7 +376,7 @@
this.globalEntityList.add(entitylightning); this.globalEntityList.add(entitylightning);
this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entitylightning.locX, entitylightning.locY, entitylightning.locZ, 512.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutSpawnEntityWeather(entitylightning)); this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entitylightning.locX, entitylightning.locY, entitylightning.locZ, 512.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutSpawnEntityWeather(entitylightning));
} }
@@ -934,6 +1060,12 @@ @@ -934,6 +1070,12 @@
public void a(int i, BlockPosition blockposition, int j) { public void a(int i, BlockPosition blockposition, int j) {
Iterator iterator = this.server.getPlayerList().getPlayers().iterator(); Iterator iterator = this.server.getPlayerList().getPlayers().iterator();
@ -372,7 +389,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next(); EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -942,6 +1074,12 @@ @@ -942,6 +1084,12 @@
double d1 = (double) blockposition.getY() - entityplayer.locY; double d1 = (double) blockposition.getY() - entityplayer.locY;
double d2 = (double) blockposition.getZ() - entityplayer.locZ; double d2 = (double) blockposition.getZ() - entityplayer.locZ;
@ -385,7 +402,7 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
} }
@@ -1002,6 +1140,14 @@ @@ -1002,6 +1150,14 @@
@Override @Override
public Explosion createExplosion(@Nullable Entity entity, DamageSource damagesource, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { public Explosion createExplosion(@Nullable Entity entity, DamageSource damagesource, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) {
@ -400,7 +417,7 @@
Explosion explosion = new Explosion(this, entity, d0, d1, d2, f, flag, explosion_effect); Explosion explosion = new Explosion(this, entity, d0, d1, d2, f, flag, explosion_effect);
if (damagesource != null) { if (damagesource != null) {
@@ -1010,6 +1156,8 @@ @@ -1010,6 +1166,8 @@
explosion.a(); explosion.a();
explosion.a(false); explosion.a(false);
@ -409,7 +426,7 @@
if (explosion_effect == Explosion.Effect.NONE) { if (explosion_effect == Explosion.Effect.NONE) {
explosion.clearBlocks(); explosion.clearBlocks();
} }
@@ -1074,13 +1222,20 @@ @@ -1074,13 +1232,20 @@
} }
public <T extends ParticleParam> int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { public <T extends ParticleParam> int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
@ -432,7 +449,7 @@
++j; ++j;
} }
} }
@@ -1163,7 +1318,13 @@ @@ -1163,7 +1328,13 @@
@Override @Override
public WorldMap a(String s) { public WorldMap a(String s) {
return (WorldMap) this.getMinecraftServer().getWorldServer(DimensionManager.OVERWORLD).getWorldPersistentData().b(() -> { return (WorldMap) this.getMinecraftServer().getWorldServer(DimensionManager.OVERWORLD).getWorldPersistentData().b(() -> {