@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -55,6 +55,13 @@
|
||||
@@ -59,6 +59,13 @@
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -14,13 +14,12 @@
|
||||
|
||||
public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStatistics, ICommandListener, Runnable {
|
||||
|
||||
@@ -125,7 +132,22 @@
|
||||
@@ -129,7 +136,21 @@
|
||||
private boolean forceUpgrade;
|
||||
private float ap;
|
||||
|
||||
- public MinecraftServer(@Nullable File file, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
|
||||
+ // CraftBukkit start
|
||||
+ public List<WorldServer> worlds = new ArrayList<WorldServer>();
|
||||
+ public org.bukkit.craftbukkit.CraftServer server;
|
||||
+ public OptionSet options;
|
||||
+ public org.bukkit.command.ConsoleCommandSender console;
|
||||
@@ -38,10 +37,10 @@
|
||||
this.ac = new ResourceManager(EnumResourcePackType.SERVER_DATA);
|
||||
this.resourcePackRepository = new ResourcePackRepository(ResourcePackLoader::new);
|
||||
this.ag = new CraftingManager();
|
||||
@@ -136,22 +158,51 @@
|
||||
@@ -140,22 +161,51 @@
|
||||
this.al = new AdvancementDataWorld();
|
||||
this.am = new CustomFunctionData(this);
|
||||
this.d = proxy;
|
||||
this.c = proxy;
|
||||
- this.commandDispatcher = commanddispatcher;
|
||||
+ this.commandDispatcher = this.vanillaCommandDispatcher = commanddispatcher; // CraftBukkit
|
||||
this.U = yggdrasilauthenticationservice;
|
||||
@@ -49,10 +48,10 @@
|
||||
this.W = gameprofilerepository;
|
||||
this.X = usercache;
|
||||
- this.universe = file;
|
||||
- this.m = file == null ? null : new ServerConnection(this);
|
||||
- this.l = file == null ? null : new ServerConnection(this);
|
||||
- this.convertable = file == null ? null : new WorldLoaderServer(file.toPath(), file.toPath().resolve("../backups"), datafixer);
|
||||
+ // this.universe = file; // CraftBukkit
|
||||
+ this.m = new ServerConnection(this); // CraftBukkit
|
||||
+ this.l = new ServerConnection(this); // CraftBukkit
|
||||
+ // this.convertable = file == null ? null : new WorldLoaderServer(file.toPath(), file.toPath().resolve("../backups"), datafixer); // CraftBukkit - moved to DedicatedServer.init
|
||||
this.dataConverterManager = datafixer;
|
||||
this.ac.a((IResourcePackListener) this.ah);
|
||||
@@ -94,7 +93,7 @@
|
||||
public abstract boolean init() throws IOException;
|
||||
|
||||
public void convertWorld(String s) {
|
||||
@@ -176,11 +227,11 @@
|
||||
@@ -180,11 +230,11 @@
|
||||
}
|
||||
|
||||
if (this.forceUpgrade) {
|
||||
@@ -109,50 +108,57 @@
|
||||
IChatBaseComponent ichatbasecomponent = null;
|
||||
|
||||
while (!worldupgrader.b()) {
|
||||
@@ -219,9 +270,10 @@
|
||||
@@ -223,8 +273,9 @@
|
||||
}
|
||||
|
||||
public void a(String s, String s1, long i, WorldType worldtype, JsonElement jsonelement) {
|
||||
- this.convertWorld(s);
|
||||
+ // this.convertWorld(s); // CraftBukkit - moved down
|
||||
this.b((IChatBaseComponent) (new ChatMessage("menu.loadingLevel", new Object[0])));
|
||||
this.worldServer = new WorldServer[3];
|
||||
+ /* CraftBukkit start - Remove ticktime arrays and worldsettings
|
||||
this.f = new long[this.worldServer.length][100];
|
||||
IDataManager idatamanager = this.convertable.a(s, this);
|
||||
IDataManager idatamanager = this.getConvertable().a(s, this);
|
||||
|
||||
@@ -247,40 +299,116 @@
|
||||
this.a(this.getWorld(), idatamanager);
|
||||
@@ -249,54 +300,144 @@
|
||||
}
|
||||
|
||||
this.a(idatamanager.getDirectory(), worlddata);
|
||||
- PersistentCollection persistentcollection = new PersistentCollection(idatamanager);
|
||||
+ */
|
||||
+ int worldCount = 3;
|
||||
|
||||
- for (int j = 0; j < this.worldServer.length; ++j) {
|
||||
- byte b0 = 0;
|
||||
- this.a(idatamanager, persistentcollection, worlddata, worldsettings);
|
||||
- this.a(this.getDifficulty());
|
||||
- this.a(persistentcollection);
|
||||
- }
|
||||
+ for (int j = 0; j < worldCount; ++j) {
|
||||
+ WorldServer world;
|
||||
+ WorldData worlddata;
|
||||
+ byte dimension = 0;
|
||||
|
||||
if (j == 1) {
|
||||
- b0 = -1;
|
||||
+
|
||||
+ if (j == 1) {
|
||||
+ if (getAllowNether()) {
|
||||
+ dimension = -1;
|
||||
+ } else {
|
||||
+ continue;
|
||||
+ }
|
||||
}
|
||||
+ }
|
||||
|
||||
if (j == 2) {
|
||||
- b0 = 1;
|
||||
- protected void a(IDataManager idatamanager, PersistentCollection persistentcollection, WorldData worlddata, WorldSettings worldsettings) {
|
||||
- if (this.L()) {
|
||||
- this.worldServer.put(DimensionManager.OVERWORLD, (new DemoWorldServer(this, idatamanager, persistentcollection, worlddata, DimensionManager.OVERWORLD, this.methodProfiler)).i_());
|
||||
- } else {
|
||||
- this.worldServer.put(DimensionManager.OVERWORLD, (new WorldServer(this, idatamanager, persistentcollection, worlddata, DimensionManager.OVERWORLD, this.methodProfiler)).i_());
|
||||
- }
|
||||
+ if (j == 2) {
|
||||
+ if (server.getAllowEnd()) {
|
||||
+ dimension = 1;
|
||||
+ } else {
|
||||
+ continue;
|
||||
+ }
|
||||
}
|
||||
+ }
|
||||
|
||||
- WorldServer worldserver = this.getWorldServer(DimensionManager.OVERWORLD);
|
||||
+ String worldType = org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase();
|
||||
+ String name = (dimension == 0) ? s : s + "_" + worldType;
|
||||
+ this.convertWorld(name); // Run conversion now
|
||||
@@ -161,7 +167,7 @@
|
||||
+ WorldSettings worldsettings = new WorldSettings(i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype);
|
||||
+ worldsettings.setGeneratorSettings(jsonelement);
|
||||
+
|
||||
if (j == 0) {
|
||||
+ if (j == 0) {
|
||||
+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), s1, this, this.dataConverterManager);
|
||||
+ worlddata = idatamanager.getWorldData();
|
||||
+ if (worlddata == null) {
|
||||
@@ -169,24 +175,34 @@
|
||||
+ }
|
||||
+ worlddata.checkName(s1); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end)
|
||||
+ this.a(idatamanager.getDirectory(), worlddata);
|
||||
if (this.N()) {
|
||||
- this.worldServer[j] = (WorldServer) (new DemoWorldServer(this, idatamanager, worlddata, b0, this.methodProfiler)).b();
|
||||
+ world = (WorldServer) (new DemoWorldServer(this, idatamanager, worlddata, dimension, this.methodProfiler)).b();
|
||||
} else {
|
||||
- this.worldServer[j] = (WorldServer) (new WorldServer(this, idatamanager, worlddata, b0, this.methodProfiler)).b();
|
||||
+ world = (WorldServer) (new WorldServer(this, idatamanager, worlddata, dimension, this.methodProfiler, org.bukkit.World.Environment.getEnvironment(dimension), gen)).b();
|
||||
}
|
||||
+ PersistentCollection persistentcollection = new PersistentCollection(idatamanager);
|
||||
|
||||
- this.worldServer[j].a(worldsettings);
|
||||
- worldserver.a(worldsettings);
|
||||
- worldserver.addIWorldAccess(new WorldManager(this, worldserver));
|
||||
- if (!this.H()) {
|
||||
- worldserver.getWorldData().setGameType(this.getGamemode());
|
||||
- }
|
||||
+ if (this.L()) {
|
||||
+ world = (WorldServer) (new DemoWorldServer(this, idatamanager, persistentcollection, worlddata, DimensionManager.OVERWORLD, this.methodProfiler)).i_();
|
||||
+ } else {
|
||||
+ world = (WorldServer) (new WorldServer(this, idatamanager, persistentcollection, worlddata, DimensionManager.OVERWORLD, this.methodProfiler, org.bukkit.World.Environment.getEnvironment(dimension), gen)).i_();
|
||||
+ }
|
||||
|
||||
- SecondaryWorldServer secondaryworldserver = (new SecondaryWorldServer(this, idatamanager, DimensionManager.NETHER, worldserver, this.methodProfiler)).b();
|
||||
+ world.a(worldsettings);
|
||||
+ this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard());
|
||||
} else {
|
||||
- this.worldServer[j] = (WorldServer) (new SecondaryWorldServer(this, idatamanager, b0, this.worldServer[0], this.methodProfiler)).b();
|
||||
+ } else {
|
||||
+ String dim = "DIM" + dimension;
|
||||
+
|
||||
|
||||
- this.worldServer.put(DimensionManager.NETHER, secondaryworldserver);
|
||||
- secondaryworldserver.addIWorldAccess(new WorldManager(this, secondaryworldserver));
|
||||
- if (!this.H()) {
|
||||
- secondaryworldserver.getWorldData().setGameType(this.getGamemode());
|
||||
- }
|
||||
+ File newWorld = new File(new File(name), dim);
|
||||
+ File oldWorld = new File(new File(s), dim);
|
||||
+
|
||||
|
||||
- SecondaryWorldServer secondaryworldserver1 = (new SecondaryWorldServer(this, idatamanager, DimensionManager.THE_END, worldserver, this.methodProfiler)).b();
|
||||
+ if ((!newWorld.isDirectory()) && (oldWorld.isDirectory())) {
|
||||
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder required ----");
|
||||
+ MinecraftServer.LOGGER.info("Unfortunately due to the way that Minecraft implemented multiworld support in 1.6, Bukkit requires that you move your " + worldType + " folder to a new location in order to operate correctly.");
|
||||
@@ -216,7 +232,12 @@
|
||||
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder failed ----");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
|
||||
- this.worldServer.put(DimensionManager.THE_END, secondaryworldserver1);
|
||||
- secondaryworldserver1.addIWorldAccess(new WorldManager(this, secondaryworldserver1));
|
||||
- if (!this.H()) {
|
||||
- secondaryworldserver1.getWorldData().setGameType(this.getGamemode());
|
||||
- }
|
||||
+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, this, this.dataConverterManager);
|
||||
+ // world =, b0 to dimension, s1 to name, added Environment and gen
|
||||
+ worlddata = idatamanager.getWorldData();
|
||||
@@ -224,35 +245,32 @@
|
||||
+ worlddata = new WorldData(worldsettings, name);
|
||||
+ }
|
||||
+ worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end)
|
||||
+ world = (WorldServer) new SecondaryWorldServer(this, idatamanager, dimension, this.worlds.get(0), this.methodProfiler, worlddata, org.bukkit.World.Environment.getEnvironment(dimension), gen).b();
|
||||
}
|
||||
|
||||
- this.worldServer[j].addIWorldAccess(new WorldManager(this, this.worldServer[j]));
|
||||
+ world = (WorldServer) new SecondaryWorldServer(this, idatamanager, DimensionManager.a(dimension), this.getWorldServer(DimensionManager.OVERWORLD), this.methodProfiler, worlddata, org.bukkit.World.Environment.getEnvironment(dimension), gen).b();
|
||||
+ }
|
||||
+
|
||||
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld()));
|
||||
+
|
||||
+ world.addIWorldAccess(new WorldManager(this, world));
|
||||
if (!this.J()) {
|
||||
- this.worldServer[j].getWorldData().setGameType(this.getGamemode());
|
||||
+ if (!this.H()) {
|
||||
+ world.getWorldData().setGameType(this.getGamemode());
|
||||
}
|
||||
- }
|
||||
|
||||
- this.s.setPlayerFileData(this.worldServer);
|
||||
- if (worlddata.P() != null) {
|
||||
- this.aR().a(worlddata.P());
|
||||
+ worlds.add(world);
|
||||
+ getPlayerList().setPlayerFileData(worlds.toArray(new WorldServer[worlds.size()]));
|
||||
+ }
|
||||
+
|
||||
+ this.worldServer.put(world.dimension, world);
|
||||
+ this.getPlayerList().setPlayerFileData(world);
|
||||
|
||||
- this.getPlayerList().setPlayerFileData(worldserver);
|
||||
- if (worlddata.P() != null) {
|
||||
- this.aP().a(worlddata.P());
|
||||
+ if (worlddata.P() != null) {
|
||||
+ this.aR().a(worlddata.P());
|
||||
+ this.aP().a(worlddata.P());
|
||||
+ }
|
||||
}
|
||||
+ this.s.setPlayerFileData(this.worldServer);
|
||||
+ this.a(this.getDifficulty());
|
||||
+ this.a(this.getWorldServer(DimensionManager.OVERWORLD).worldMaps);
|
||||
+ // CraftBukkit end
|
||||
|
||||
this.a(this.getDifficulty());
|
||||
this.g_();
|
||||
@@ -289,6 +417,25 @@
|
||||
}
|
||||
|
||||
protected void a(File file, WorldData worlddata) {
|
||||
this.resourcePackRepository.a((ResourcePackSource) (new ResourcePackSourceVanilla()));
|
||||
this.resourcePackFolder = new ResourcePackSourceFolder(new File(file, "datapacks"));
|
||||
@@ -278,12 +296,13 @@
|
||||
this.resourcePackRepository.a((ResourcePackSource) this.resourcePackFolder);
|
||||
this.resourcePackRepository.a();
|
||||
ArrayList arraylist = Lists.newArrayList();
|
||||
@@ -319,41 +466,52 @@
|
||||
this.b((IChatBaseComponent) (new ChatMessage("menu.generatingTerrain", new Object[0])));
|
||||
boolean flag5 = false;
|
||||
@@ -325,42 +466,52 @@
|
||||
boolean flag4 = true;
|
||||
|
||||
- MinecraftServer.LOGGER.info("Preparing start region for level 0");
|
||||
- WorldServer worldserver = this.worldServer[0];
|
||||
this.b((IChatBaseComponent) (new ChatMessage("menu.generatingTerrain", new Object[0])));
|
||||
- WorldServer worldserver = this.getWorldServer(DimensionManager.OVERWORLD);
|
||||
|
||||
- MinecraftServer.LOGGER.info("Preparing start region for dimension " + DimensionManager.a(worldserver.worldProvider.getDimensionManager()));
|
||||
- BlockPosition blockposition = worldserver.getSpawn();
|
||||
- ArrayList arraylist = Lists.newArrayList();
|
||||
- Set set = Sets.newConcurrentHashSet();
|
||||
@@ -293,9 +312,8 @@
|
||||
- for (int i = -192; i <= 192 && this.isRunning(); i += 16) {
|
||||
- for (int j = -192; j <= 192 && this.isRunning(); j += 16) {
|
||||
- arraylist.add(new ChunkCoordIntPair(blockposition.getX() + i >> 4, blockposition.getZ() + j >> 4));
|
||||
+ for (int m = 0; m < worlds.size(); m++) {
|
||||
+ WorldServer worldserver = this.worlds.get(m);
|
||||
+ MinecraftServer.LOGGER.info("Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")");
|
||||
+ for (WorldServer worldserver : this.getWorlds()) {
|
||||
+ MinecraftServer.LOGGER.info("Preparing start region for level " + worldserver.dimension + " (Seed: " + worldserver.getSeed() + ")");
|
||||
+ if (!worldserver.getWorld().getKeepSpawnInMemory()) {
|
||||
+ continue;
|
||||
}
|
||||
@@ -306,6 +324,11 @@
|
||||
+ BlockPosition blockposition = worldserver.getSpawn();
|
||||
+ ArrayList arraylist = Lists.newArrayList();
|
||||
+ Set set = Sets.newConcurrentHashSet();
|
||||
+
|
||||
+ for (int i = -192; i <= 192 && this.isRunning(); i += 16) {
|
||||
+ for (int j = -192; j <= 192 && this.isRunning(); j += 16) {
|
||||
+ arraylist.add(new ChunkCoordIntPair(blockposition.getX() + i >> 4, blockposition.getZ() + j >> 4));
|
||||
+ }
|
||||
|
||||
- while (!completablefuture.isDone()) {
|
||||
- try {
|
||||
@@ -316,18 +339,10 @@
|
||||
- if (executionexception.getCause() instanceof RuntimeException) {
|
||||
- throw (RuntimeException) executionexception.getCause();
|
||||
- }
|
||||
+ for (int i = -192; i <= 192 && this.isRunning(); i += 16) {
|
||||
+ for (int j = -192; j <= 192 && this.isRunning(); j += 16) {
|
||||
+ arraylist.add(new ChunkCoordIntPair(blockposition.getX() + i >> 4, blockposition.getZ() + j >> 4));
|
||||
+ }
|
||||
+
|
||||
+ CompletableFuture completablefuture = worldserver.getChunkProviderServer().a((Iterable) arraylist, (chunk) -> {
|
||||
+ set.add(chunk.getPos());
|
||||
+ });
|
||||
|
||||
- throw new RuntimeException(executionexception.getCause());
|
||||
- } catch (TimeoutException timeoutexception) {
|
||||
- this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625);
|
||||
+
|
||||
+ while (!completablefuture.isDone()) {
|
||||
+ try {
|
||||
+ completablefuture.get(1L, TimeUnit.SECONDS);
|
||||
@@ -337,7 +352,10 @@
|
||||
+ if (executionexception.getCause() instanceof RuntimeException) {
|
||||
+ throw (RuntimeException) executionexception.getCause();
|
||||
+ }
|
||||
+
|
||||
|
||||
- throw new RuntimeException(executionexception.getCause());
|
||||
- } catch (TimeoutException timeoutexception) {
|
||||
- this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625);
|
||||
+ throw new RuntimeException(executionexception.getCause());
|
||||
+ } catch (TimeoutException timeoutexception) {
|
||||
+ this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625);
|
||||
@@ -350,34 +368,22 @@
|
||||
+ }
|
||||
}
|
||||
|
||||
+ for (WorldServer world : this.worlds) {
|
||||
+ for (WorldServer world : this.getWorlds()) {
|
||||
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.m();
|
||||
MinecraftServer.LOGGER.info("Time elapsed: {} ms", Long.valueOf(stopwatch.elapsed(TimeUnit.MILLISECONDS)));
|
||||
}
|
||||
@@ -392,14 +550,17 @@
|
||||
protected void m() {
|
||||
Iterator iterator = DimensionManager.b().iterator();
|
||||
|
||||
@@ -419,6 +570,7 @@
|
||||
protected void l() {
|
||||
this.w = null;
|
||||
this.x = 0;
|
||||
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); // CraftBukkit
|
||||
}
|
||||
|
||||
protected void saveChunks(boolean flag) {
|
||||
WorldServer[] aworldserver = this.worldServer;
|
||||
int i = aworldserver.length;
|
||||
|
||||
- for (int j = 0; j < i; ++j) {
|
||||
- WorldServer worldserver = aworldserver[j];
|
||||
+ // CraftBukkit start
|
||||
+ for (int j = 0; j < worlds.size(); ++j) {
|
||||
+ WorldServer worldserver = worlds.get(j);
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (worldserver != null) {
|
||||
if (!flag) {
|
||||
@@ -416,8 +577,24 @@
|
||||
@@ -442,8 +594,24 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -403,41 +409,15 @@
|
||||
if (this.getServerConnection() != null) {
|
||||
this.getServerConnection().b();
|
||||
}
|
||||
@@ -426,6 +603,7 @@
|
||||
@@ -452,6 +620,7 @@
|
||||
MinecraftServer.LOGGER.info("Saving players");
|
||||
this.s.savePlayers();
|
||||
this.s.u();
|
||||
+ try { Thread.sleep(100); } catch (InterruptedException ex) {} // CraftBukkit - SPIGOT-625 - give server at least a chance to send packets
|
||||
}
|
||||
|
||||
if (this.worldServer != null) {
|
||||
@@ -436,8 +614,10 @@
|
||||
int j;
|
||||
WorldServer worldserver;
|
||||
|
||||
- for (j = 0; j < i; ++j) {
|
||||
- worldserver = aworldserver[j];
|
||||
+ // CraftBukkit start
|
||||
+ for (j = 0; j < worlds.size(); ++j) {
|
||||
+ worldserver = worlds.get(j);
|
||||
+ // CraftBukkit end
|
||||
if (worldserver != null) {
|
||||
worldserver.savingDisabled = false;
|
||||
}
|
||||
@@ -447,8 +627,10 @@
|
||||
aworldserver = this.worldServer;
|
||||
i = aworldserver.length;
|
||||
|
||||
- for (j = 0; j < i; ++j) {
|
||||
- worldserver = aworldserver[j];
|
||||
+ // CraftBukkit start
|
||||
+ for (j = 0; j < worlds.size(); ++j) {
|
||||
+ worldserver = worlds.get(j);
|
||||
+ // CraftBukkit end
|
||||
if (worldserver != null) {
|
||||
worldserver.close();
|
||||
}
|
||||
@@ -491,11 +673,13 @@
|
||||
MinecraftServer.LOGGER.info("Saving worlds");
|
||||
@@ -516,11 +685,13 @@
|
||||
if (i > 2000L && this.aa - this.Q >= 15000L) {
|
||||
long j = i / 50L;
|
||||
|
||||
@@ -448,10 +428,10 @@
|
||||
}
|
||||
|
||||
+ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
|
||||
this.v();
|
||||
this.a(this::aT);
|
||||
this.aa += 50L;
|
||||
|
||||
@@ -534,6 +718,12 @@
|
||||
@@ -559,6 +730,12 @@
|
||||
} catch (Throwable throwable1) {
|
||||
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
|
||||
} finally {
|
||||
@@ -461,11 +441,11 @@
|
||||
+ } catch (Exception ignored) {
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.u();
|
||||
this.t();
|
||||
}
|
||||
|
||||
@@ -602,7 +792,7 @@
|
||||
this.n.b().a(agameprofile);
|
||||
@@ -627,7 +804,7 @@
|
||||
this.m.b().a(agameprofile);
|
||||
}
|
||||
|
||||
- if (this.ticks % 900 == 0) {
|
||||
@@ -473,18 +453,19 @@
|
||||
this.methodProfiler.a("save");
|
||||
this.s.savePlayers();
|
||||
this.saveChunks(true);
|
||||
@@ -628,6 +818,7 @@
|
||||
@@ -653,6 +830,7 @@
|
||||
}
|
||||
|
||||
public void w() {
|
||||
public void b(BooleanSupplier booleansupplier) {
|
||||
+ this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit
|
||||
this.methodProfiler.a("jobs");
|
||||
|
||||
FutureTask futuretask;
|
||||
@@ -640,22 +831,40 @@
|
||||
@@ -665,23 +843,40 @@
|
||||
this.getFunctionData().Y_();
|
||||
this.methodProfiler.c("levels");
|
||||
|
||||
- WorldServer worldserver;
|
||||
+ // CraftBukkit start
|
||||
+ // Run tasks that are waiting on processing
|
||||
+ while (!processQueue.isEmpty()) {
|
||||
@@ -501,41 +482,34 @@
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
int i;
|
||||
|
||||
- for (i = 0; i < this.worldServer.length; ++i) {
|
||||
+ for (i = 0; i < this.worlds.size(); ++i) { // CraftBukkit
|
||||
long j = SystemUtils.c();
|
||||
|
||||
- if (i == 0 || this.getAllowNether()) {
|
||||
- WorldServer worldserver = this.worldServer[i];
|
||||
+ if (true || i == 0 || this.getAllowNether()) { // CraftBukkit
|
||||
+ WorldServer worldserver = this.worlds.get(i);
|
||||
+ // WorldServer worldserver; // CraftBukkit - dropped down
|
||||
long i;
|
||||
|
||||
- for (Iterator iterator = this.getWorlds().iterator(); iterator.hasNext();((long[]) this.e.computeIfAbsent(worldserver.worldProvider.getDimensionManager(), (dimensionmanager) -> {
|
||||
- return new long[100];
|
||||
- }))[this.ticks % 100] = SystemUtils.c() - i) {
|
||||
- worldserver = (WorldServer) iterator.next();
|
||||
+ // CraftBukkit - dropTickTime
|
||||
+ for (Iterator iterator = this.getWorlds().iterator(); iterator.hasNext();) {
|
||||
+ WorldServer worldserver = (WorldServer) iterator.next();
|
||||
i = SystemUtils.c();
|
||||
- if (worldserver.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD || this.getAllowNether()) {
|
||||
+ if (true || worldserver.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD || this.getAllowNether()) { // CraftBukkit
|
||||
this.methodProfiler.a(() -> {
|
||||
return worldserver.getWorldData().getName();
|
||||
});
|
||||
+ /* Drop global time updates
|
||||
if (this.ticks % 20 == 0) {
|
||||
this.methodProfiler.a("timeSync");
|
||||
this.s.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))), worldserver.worldProvider.getDimensionManager().getDimensionID());
|
||||
this.s.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))), worldserver.worldProvider.getDimensionManager());
|
||||
this.methodProfiler.e();
|
||||
}
|
||||
+ // CraftBukkit end */
|
||||
|
||||
this.methodProfiler.a("tick");
|
||||
|
||||
@@ -684,7 +893,7 @@
|
||||
this.methodProfiler.e();
|
||||
}
|
||||
|
||||
- this.f[i][this.ticks % 100] = SystemUtils.c() - j;
|
||||
+ // this.f[i][this.ticks % 100] = SystemUtils.c() - j; // CraftBukkit
|
||||
}
|
||||
|
||||
this.methodProfiler.c("connection");
|
||||
@@ -708,10 +917,11 @@
|
||||
this.l.add(itickable);
|
||||
@@ -732,10 +927,11 @@
|
||||
this.k.add(itickable);
|
||||
}
|
||||
|
||||
- public static void main(String[] astring) {
|
||||
@@ -547,7 +521,7 @@
|
||||
boolean flag = true;
|
||||
String s = null;
|
||||
String s1 = ".";
|
||||
@@ -759,13 +969,16 @@
|
||||
@@ -783,13 +979,16 @@
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -565,7 +539,7 @@
|
||||
if (s != null) {
|
||||
dedicatedserver.h(s);
|
||||
}
|
||||
@@ -803,6 +1016,29 @@
|
||||
@@ -827,6 +1026,29 @@
|
||||
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(MinecraftServer.LOGGER));
|
||||
Runtime.getRuntime().addShutdownHook(thread);
|
||||
@@ -595,10 +569,10 @@
|
||||
} catch (Exception exception) {
|
||||
MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception);
|
||||
}
|
||||
@@ -814,11 +1050,13 @@
|
||||
@@ -838,11 +1060,13 @@
|
||||
}
|
||||
|
||||
public void y() {
|
||||
public void v() {
|
||||
+ /* CraftBukkit start - prevent abuse
|
||||
this.serverThread = new Thread(this, "Server thread");
|
||||
this.serverThread.setUncaughtExceptionHandler((thread, throwable) -> {
|
||||
@@ -609,28 +583,7 @@
|
||||
}
|
||||
|
||||
public File c(String s) {
|
||||
@@ -834,11 +1072,18 @@
|
||||
}
|
||||
|
||||
public WorldServer getWorldServer(int i) {
|
||||
- return i == -1 ? this.worldServer[1] : (i == 1 ? this.worldServer[2] : this.worldServer[0]);
|
||||
+ // CraftBukkit start
|
||||
+ for (WorldServer world : worlds) {
|
||||
+ if (world.dimension == i) {
|
||||
+ return world;
|
||||
+ }
|
||||
+ }
|
||||
+ return worlds.get(0);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public WorldServer a(DimensionManager dimensionmanager) {
|
||||
- return dimensionmanager == DimensionManager.NETHER ? this.worldServer[1] : (dimensionmanager == DimensionManager.THE_END ? this.worldServer[2] : this.worldServer[0]);
|
||||
+ return dimensionmanager == DimensionManager.NETHER ? this.worlds.get(1) : (dimensionmanager == DimensionManager.THE_END ? this.worlds.get(2) : this.worlds.get(0)); // CraftBukkit
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
@@ -858,7 +1103,7 @@
|
||||
@@ -882,7 +1106,7 @@
|
||||
}
|
||||
|
||||
public boolean isDebugging() {
|
||||
@@ -639,7 +592,7 @@
|
||||
}
|
||||
|
||||
public void f(String s) {
|
||||
@@ -873,7 +1118,7 @@
|
||||
@@ -897,7 +1121,7 @@
|
||||
}
|
||||
|
||||
public String getServerModName() {
|
||||
@@ -648,52 +601,17 @@
|
||||
}
|
||||
|
||||
public CrashReport b(CrashReport crashreport) {
|
||||
@@ -909,7 +1154,7 @@
|
||||
@@ -933,7 +1157,7 @@
|
||||
}
|
||||
|
||||
public boolean F() {
|
||||
public boolean D() {
|
||||
- return this.universe != null;
|
||||
+ return true; // CraftBukkit
|
||||
}
|
||||
|
||||
public void sendMessage(IChatBaseComponent ichatbasecomponent) {
|
||||
@@ -953,11 +1198,13 @@
|
||||
}
|
||||
|
||||
public void a(EnumDifficulty enumdifficulty) {
|
||||
- WorldServer[] aworldserver = this.worldServer;
|
||||
- int i = aworldserver.length;
|
||||
+ // CraftBukkit start
|
||||
+ // WorldServer[] aworldserver = this.worldServer;
|
||||
+ int i = this.worlds.size();
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
- WorldServer worldserver = aworldserver[j];
|
||||
+ WorldServer worldserver = this.worlds.get(j);
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (worldserver != null) {
|
||||
if (worldserver.getWorldData().isHardcore()) {
|
||||
@@ -1024,13 +1271,11 @@
|
||||
int i = 0;
|
||||
|
||||
if (this.worldServer != null) {
|
||||
- WorldServer[] aworldserver = this.worldServer;
|
||||
- int j = aworldserver.length;
|
||||
-
|
||||
- for (int k = 0; k < j; ++k) {
|
||||
- WorldServer worldserver = aworldserver[k];
|
||||
-
|
||||
+ // CraftBukkit start
|
||||
+ for (int j = 0; j < this.worlds.size(); ++j) {
|
||||
+ WorldServer worldserver = this.worlds.get(j);
|
||||
if (worldserver != null) {
|
||||
+ // CraftBukkit end
|
||||
WorldData worlddata = worldserver.getWorldData();
|
||||
|
||||
mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimensionManager().getDimensionID()));
|
||||
@@ -1056,7 +1301,7 @@
|
||||
public abstract boolean S();
|
||||
@@ -1073,7 +1297,7 @@
|
||||
public abstract boolean Q();
|
||||
|
||||
public boolean getOnlineMode() {
|
||||
- return this.onlineMode;
|
||||
@@ -701,24 +619,7 @@
|
||||
}
|
||||
|
||||
public void setOnlineMode(boolean flag) {
|
||||
@@ -1138,13 +1383,9 @@
|
||||
public abstract boolean af();
|
||||
|
||||
public void setGamemode(EnumGamemode enumgamemode) {
|
||||
- WorldServer[] aworldserver = this.worldServer;
|
||||
- int i = aworldserver.length;
|
||||
-
|
||||
- for (int j = 0; j < i; ++j) {
|
||||
- WorldServer worldserver = aworldserver[j];
|
||||
-
|
||||
- worldserver.getWorldData().setGameType(enumgamemode);
|
||||
+ // CraftBukkit start
|
||||
+ for (int i = 0; i < this.worlds.size(); ++i) {
|
||||
+ worlds.get(i).getWorldData().setGameType(enumgamemode);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1217,7 +1458,7 @@
|
||||
@@ -1233,7 +1457,7 @@
|
||||
|
||||
public <V> ListenableFuture<V> a(Callable<V> callable) {
|
||||
Validate.notNull(callable);
|
||||
@@ -726,17 +627,8 @@
|
||||
+ if (!this.isMainThread()) { // CraftBukkit && !this.isStopped()) {
|
||||
ListenableFutureTask listenablefuturetask = ListenableFutureTask.create(callable);
|
||||
|
||||
this.g.add(listenablefuturetask);
|
||||
@@ -1274,7 +1515,7 @@
|
||||
} else {
|
||||
this.getPlayerList().savePlayers();
|
||||
this.resourcePackRepository.a();
|
||||
- this.a(this.worldServer[0].getWorldData());
|
||||
+ this.a(this.worlds.get(0).getWorldData()); // CraftBukkit
|
||||
this.getPlayerList().reload();
|
||||
}
|
||||
}
|
||||
@@ -1288,8 +1529,8 @@
|
||||
this.f.add(listenablefuturetask);
|
||||
@@ -1304,8 +1528,8 @@
|
||||
|
||||
if (!worlddata.N().contains(resourcepackloader.e()) && !arraylist.contains(resourcepackloader)) {
|
||||
MinecraftServer.LOGGER.info("Found new data pack {}, loading it automatically", resourcepackloader.e());
|
||||
@@ -747,7 +639,7 @@
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
@@ -1298,7 +1539,7 @@
|
||||
@@ -1314,7 +1538,7 @@
|
||||
ArrayList arraylist1 = Lists.newArrayList();
|
||||
|
||||
this.resourcePackRepository.d().forEach((resourcepackloader) -> {
|
||||
@@ -756,25 +648,7 @@
|
||||
});
|
||||
this.ac.a((List) arraylist1);
|
||||
worlddata.O().clear();
|
||||
@@ -1348,7 +1589,7 @@
|
||||
}
|
||||
|
||||
public CommandListenerWrapper getServerCommandListener() {
|
||||
- return new CommandListenerWrapper(this, this.worldServer[0] == null ? Vec3D.a : new Vec3D(this.worldServer[0].getSpawn()), Vec2F.a, this.worldServer[0], 4, "Server", new ChatComponentText("Server"), this, (Entity) null);
|
||||
+ return new CommandListenerWrapper(this, this.worlds.isEmpty() ? Vec3D.a : new Vec3D(this.worlds.get(0).getSpawn()), Vec2F.a, this.worlds.isEmpty() ? null : this.worlds.get(0), 4, "Server", new ChatComponentText("Server"), this, (Entity) null); // CraftBukkit
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
@@ -1376,7 +1617,7 @@
|
||||
}
|
||||
|
||||
public GameRules aQ() {
|
||||
- return this.worldServer[0].getGameRules();
|
||||
+ return this.worlds.get(0).getGameRules(); // CraftBukkit
|
||||
}
|
||||
|
||||
public BossBattleCustomData aR() {
|
||||
@@ -1400,4 +1641,11 @@
|
||||
@@ -1416,4 +1640,11 @@
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user