Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/nms-patches/MinecraftServer.patch

717 Zeilen
29 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
2016-11-17 02:41:03 +01:00
@@ -40,6 +40,13 @@
2016-07-15 12:08:04 +02:00
import org.apache.commons.lang3.Validate;
2016-05-10 13:47:39 +02:00
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
2016-07-15 12:08:04 +02:00
+import jline.console.ConsoleReader;
+import joptsimple.OptionSet;
2016-02-29 22:32:46 +01:00
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.CraftServer;
2016-07-15 12:08:04 +02:00
+import org.bukkit.craftbukkit.Main;
2016-02-29 22:32:46 +01:00
+// CraftBukkit end
2016-07-15 12:08:04 +02:00
2017-05-14 04:00:00 +02:00
public abstract class MinecraftServer implements ICommandListener, Runnable, IAsyncTaskHandler, IMojangStatistics {
2015-02-26 23:41:06 +01:00
2016-11-17 02:41:03 +01:00
@@ -97,19 +104,61 @@
private Thread serverThread;
2016-11-17 02:41:03 +01:00
private long ab = aw();
2016-02-29 22:32:46 +01:00
- public MinecraftServer(File file, Proxy proxy, DataConverterManager dataconvertermanager, 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;
+ public org.bukkit.command.RemoteConsoleCommandSender remoteConsole;
+ public ConsoleReader reader;
+ public static int currentTick = (int) (System.currentTimeMillis() / 50);
+ public final Thread primaryThread;
+ public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
+ public int autosavePeriod;
+ // CraftBukkit end
+
2016-02-29 22:32:46 +01:00
+ public MinecraftServer(OptionSet options, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
2015-02-26 23:41:06 +01:00
this.e = proxy;
2016-11-17 02:41:03 +01:00
this.V = yggdrasilauthenticationservice;
this.W = minecraftsessionservice;
this.X = gameprofilerepository;
this.Y = usercache;
- this.universe = file;
+ // this.universe = file; // CraftBukkit
2016-02-29 22:32:46 +01:00
this.p = new ServerConnection(this);
this.b = this.i();
- this.convertable = new WorldLoaderServer(file, dataconvertermanager);
+ // this.convertable = new WorldLoaderServer(file); // CraftBukkit - moved to DedicatedServer.init
2016-02-29 22:32:46 +01:00
this.dataConverterManager = dataconvertermanager;
+ // CraftBukkit start
+ this.options = options;
+ // Try to see if we're actually running in a terminal, disable jline if not
+ if (System.console() == null && System.getProperty("jline.terminal") == null) {
+ System.setProperty("jline.terminal", "jline.UnsupportedTerminal");
+ Main.useJline = false;
+ }
+
+ try {
+ reader = new ConsoleReader(System.in, System.out);
+ reader.setExpandEvents(false); // Avoid parsing exceptions for uncommonly used event designators
+ } catch (Throwable e) {
+ try {
+ // Try again with jline disabled for Windows users without C++ 2008 Redistributable
+ System.setProperty("jline.terminal", "jline.UnsupportedTerminal");
+ System.setProperty("user.language", "en");
+ Main.useJline = false;
+ reader = new ConsoleReader(System.in, System.out);
+ reader.setExpandEvents(false);
+ } catch (IOException ex) {
+ LOGGER.warn((String) null, ex);
+ }
+ }
+ Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
+
+ this.serverThread = primaryThread = new Thread(this, "Server thread"); // Moved from main
}
+ public abstract PropertyManager getPropertyManager();
+ // CraftBukkit end
+
2016-02-29 22:32:46 +01:00
protected CommandDispatcher i() {
return new CommandDispatcher(this);
}
2016-11-17 02:41:03 +01:00
@@ -147,6 +196,7 @@
this.a(s);
this.b("menu.loadingLevel");
this.worldServer = new WorldServer[3];
+ /* CraftBukkit start - Remove ticktime arrays and worldsettings
2015-02-26 23:41:06 +01:00
this.i = new long[this.worldServer.length][100];
IDataManager idatamanager = this.convertable.a(s, true);
2016-11-17 02:41:03 +01:00
@@ -170,36 +220,108 @@
worlddata.a(s1);
worldsettings = new WorldSettings(worlddata);
}
+ */
+ int worldCount = 3;
- for (int j = 0; j < this.worldServer.length; ++j) {
- byte b0 = 0;
+ for (int j = 0; j < worldCount; ++j) {
+ WorldServer world;
+ byte dimension = 0;
if (j == 1) {
- b0 = -1;
+ if (getAllowNether()) {
+ dimension = -1;
+ } else {
+ continue;
+ }
}
if (j == 2) {
- b0 = 1;
+ if (server.getAllowEnd()) {
+ dimension = 1;
+ } else {
+ continue;
+ }
}
+ String worldType = org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase();
+ String name = (dimension == 0) ? s : s + "_" + worldType;
+
+ org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name);
+ WorldSettings worldsettings = new WorldSettings(i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype);
+ worldsettings.setGeneratorSettings(s2);
+
if (j == 0) {
2016-02-29 22:32:46 +01:00
+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), s1, true, this.dataConverterManager);
+ WorldData worlddata = idatamanager.getWorldData();
+ if (worlddata == null) {
+ worlddata = new WorldData(worldsettings, s1);
+ }
+ 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)
2016-02-29 22:32:46 +01:00
if (this.V()) {
- 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();
}
- this.worldServer[j].a(worldsettings);
+ 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();
+ String dim = "DIM" + dimension;
+
+ File newWorld = new File(new File(name), dim);
+ File oldWorld = new File(new File(s), dim);
+
+ 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.");
+ MinecraftServer.LOGGER.info("We will move this folder for you, but it will mean that you need to move it back should you wish to stop using Bukkit in the future.");
+ MinecraftServer.LOGGER.info("Attempting to move " + oldWorld + " to " + newWorld + "...");
+
+ if (newWorld.exists()) {
+ MinecraftServer.LOGGER.warn("A file or folder already exists at " + newWorld + "!");
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder failed ----");
+ } else if (newWorld.getParentFile().mkdirs()) {
+ if (oldWorld.renameTo(newWorld)) {
+ MinecraftServer.LOGGER.info("Success! To restore " + worldType + " in the future, simply move " + newWorld + " to " + oldWorld);
+ // Migrate world data too.
+ try {
+ com.google.common.io.Files.copy(new File(new File(s), "level.dat"), new File(new File(name), "level.dat"));
+ org.apache.commons.io.FileUtils.copyDirectory(new File(new File(s), "data"), new File(new File(name), "data"));
+ } catch (IOException exception) {
+ MinecraftServer.LOGGER.warn("Unable to migrate world data.");
+ }
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder complete ----");
+ } else {
+ MinecraftServer.LOGGER.warn("Could not move folder " + oldWorld + " to " + newWorld + "!");
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder failed ----");
+ }
+ } else {
+ MinecraftServer.LOGGER.warn("Could not create path for " + newWorld + "!");
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder failed ----");
+ }
+ }
+
2016-02-29 22:32:46 +01:00
+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, true, this.dataConverterManager);
+ // world =, b0 to dimension, s1 to name, added Environment and gen
+ WorldData worlddata = idatamanager.getWorldData();
+ if (worlddata == null) {
+ 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]));
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld()));
+
+ world.addIWorldAccess(new WorldManager(this, world));
2016-02-29 22:32:46 +01:00
if (!this.R()) {
- this.worldServer[j].getWorldData().setGameType(this.getGamemode());
+ world.getWorldData().setGameType(this.getGamemode());
}
2016-02-29 22:32:46 +01:00
- }
+ worlds.add(world);
+ getPlayerList().setPlayerFileData(worlds.toArray(new WorldServer[worlds.size()]));
2016-02-29 22:32:46 +01:00
+ }
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
this.v.setPlayerFileData(this.worldServer);
this.a(this.getDifficulty());
2016-02-29 22:32:46 +01:00
this.l();
2016-11-17 02:41:03 +01:00
@@ -215,25 +337,38 @@
this.b("menu.generatingTerrain");
2016-06-09 03:43:49 +02:00
boolean flag4 = false;
2016-06-09 03:43:49 +02:00
- MinecraftServer.LOGGER.info("Preparing start region for level 0");
- WorldServer worldserver = this.worldServer[0];
- BlockPosition blockposition = worldserver.getSpawn();
2016-11-17 02:41:03 +01:00
- long j = aw();
-
- for (int k = -192; k <= 192 && this.isRunning(); k += 16) {
- for (int l = -192; l <= 192 && this.isRunning(); l += 16) {
2016-11-17 02:41:03 +01:00
- long i1 = aw();
-
- if (i1 - j > 1000L) {
- this.a_("Preparing spawn area", i * 100 / 625);
- j = i1;
- }
+ // CraftBukkit start - fire WorldLoadEvent and handle whether or not to keep the spawn in memory
+ for (int m = 0; m < worlds.size(); m++) {
+ WorldServer worldserver = this.worlds.get(m);
2016-02-29 22:32:46 +01:00
+ MinecraftServer.LOGGER.info("Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")");
+
+ if (!worldserver.getWorld().getKeepSpawnInMemory()) {
+ continue;
+ }
+
+ BlockPosition blockposition = worldserver.getSpawn();
2016-11-17 02:41:03 +01:00
+ long j = aw();
+ i = 0;
+
+ for (int k = -192; k <= 192 && this.isRunning(); k += 16) {
+ for (int l = -192; l <= 192 && this.isRunning(); l += 16) {
2016-11-17 02:41:03 +01:00
+ long i1 = aw();
+
+ if (i1 - j > 1000L) {
+ this.a_("Preparing spawn area", i * 100 / 625);
+ j = i1;
+ }
- ++i;
2016-02-29 22:32:46 +01:00
- worldserver.getChunkProviderServer().getChunkAt(blockposition.getX() + k >> 4, blockposition.getZ() + l >> 4);
+ ++i;
2016-02-29 22:32:46 +01:00
+ worldserver.getChunkProviderServer().getChunkAt(blockposition.getX() + k >> 4, blockposition.getZ() + l >> 4);
+ }
}
}
+ for (WorldServer world : this.worlds) {
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld()));
+ }
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
this.t();
}
2016-11-17 02:41:03 +01:00
@@ -273,14 +408,17 @@
2016-02-29 22:32:46 +01:00
protected void t() {
2015-02-26 23:41:06 +01:00
this.f = null;
this.g = 0;
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); // CraftBukkit
}
2016-02-29 22:32:46 +01:00
protected void saveChunks(boolean flag) {
WorldServer[] aworldserver = this.worldServer;
int i = aworldserver.length;
2015-02-26 23:41:06 +01:00
2016-02-29 22:32:46 +01:00
- 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) {
2016-11-17 02:41:03 +01:00
@@ -289,6 +427,7 @@
2016-02-29 22:32:46 +01:00
try {
worldserver.save(true, (IProgressUpdate) null);
+ worldserver.saveLevel(); // CraftBukkit
} catch (ExceptionWorldConflict exceptionworldconflict) {
MinecraftServer.LOGGER.warn(exceptionworldconflict.getMessage());
}
2016-11-17 02:41:03 +01:00
@@ -297,8 +436,24 @@
2015-02-26 23:41:06 +01:00
}
2015-02-26 23:41:06 +01:00
- protected void stop() {
+ // CraftBukkit start
+ private boolean hasStopped = false;
+ private final Object stopLock = new Object();
+ // CraftBukkit end
+
+ public void stop() throws ExceptionWorldConflict { // CraftBukkit - added throws
+ // CraftBukkit start - prevent double stopping on multiple threads
+ synchronized(stopLock) {
+ if (hasStopped) return;
+ hasStopped = true;
+ }
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
MinecraftServer.LOGGER.info("Stopping server");
+ // CraftBukkit start
+ if (this.server != null) {
+ this.server.disablePlugins();
+ }
+ // CraftBukkit end
2016-11-17 02:41:03 +01:00
if (this.an() != null) {
this.an().b();
}
2016-11-17 02:41:03 +01:00
@@ -307,6 +462,7 @@
2016-02-29 22:32:46 +01:00
MinecraftServer.LOGGER.info("Saving players");
this.v.savePlayers();
this.v.u();
+ try { Thread.sleep(100); } catch (InterruptedException ex) {} // CraftBukkit - SPIGOT-625 - give server at least a chance to send packets
}
2016-02-29 22:32:46 +01:00
if (this.worldServer != null) {
2016-11-17 02:41:03 +01:00
@@ -328,12 +484,14 @@
2016-06-09 03:43:49 +02:00
aworldserver = this.worldServer;
i = aworldserver.length;
2016-02-29 22:32:46 +01:00
+ /* CraftBukkit start - Handled in saveChunks
2016-06-09 03:43:49 +02:00
for (j = 0; j < i; ++j) {
worldserver = aworldserver[j];
if (worldserver != null) {
worldserver.saveLevel();
}
}
2016-02-29 22:32:46 +01:00
+ // CraftBukkit end */
}
2016-02-29 22:32:46 +01:00
if (this.m.d()) {
2016-11-17 02:41:03 +01:00
@@ -373,6 +531,7 @@
long k = j - this.ab;
2016-11-17 02:41:03 +01:00
if (k > 2000L && this.ab - this.R >= 15000L) {
+ if (server.getWarnOnOverload()) // CraftBukkit
2017-05-14 04:00:00 +02:00
MinecraftServer.LOGGER.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", Long.valueOf(k), Long.valueOf(k / 50L));
k = 2000L;
2016-11-17 02:41:03 +01:00
this.R = this.ab;
@@ -385,11 +544,12 @@
i += k;
2016-11-17 02:41:03 +01:00
this.ab = j;
- if (this.worldServer[0].everyoneDeeplySleeping()) {
2015-05-05 22:43:47 +02:00
+ if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit
2016-02-29 22:32:46 +01:00
this.C();
i = 0L;
} else {
while (i > 50L) {
+ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
i -= 50L;
2016-02-29 22:32:46 +01:00
this.C();
}
2016-11-17 02:41:03 +01:00
@@ -427,6 +587,12 @@
} catch (Throwable throwable1) {
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
} finally {
+ // CraftBukkit start - Restore terminal to original settings
+ try {
+ reader.getTerminal().restore();
+ } catch (Exception ignored) {
+ }
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
this.B();
}
2016-11-17 02:41:03 +01:00
@@ -470,7 +636,7 @@
2016-06-09 03:43:49 +02:00
public void B() {}
2016-02-29 22:32:46 +01:00
- protected void C() {
+ protected void C() throws ExceptionWorldConflict { // CraftBukkit - added throws
long i = System.nanoTime();
++this.ticks;
2016-11-17 02:41:03 +01:00
@@ -496,7 +662,7 @@
2016-02-29 22:32:46 +01:00
this.q.b().a(agameprofile);
}
- if (this.ticks % 900 == 0) {
+ if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit
this.methodProfiler.a("save");
this.v.savePlayers();
this.saveChunks(true);
2016-11-17 02:41:03 +01:00
@@ -520,6 +686,7 @@
}
public void D() {
+ this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit
this.methodProfiler.a("jobs");
Queue queue = this.j;
2016-11-17 02:41:03 +01:00
@@ -531,20 +698,38 @@
this.methodProfiler.c("levels");
+ // CraftBukkit start
+ // Run tasks that are waiting on processing
+ while (!processQueue.isEmpty()) {
+ processQueue.remove().run();
+ }
+
+ org.bukkit.craftbukkit.chunkio.ChunkIOExecutor.tick();
+
+ // Send time updates to everyone, it will get the right time from the world the player is in.
+ if (this.ticks % 20 == 0) {
+ for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
+ EntityPlayer entityplayer = (EntityPlayer) this.getPlayerList().players.get(i);
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean("doDaylightCycle"))); // Add support for per player time
+ }
+ }
+
int i;
- for (i = 0; i < this.worldServer.length; ++i) {
2016-02-29 22:32:46 +01:00
+ for (i = 0; i < this.worlds.size(); ++i) { // CraftBukkit
long j = System.nanoTime();
- if (i == 0 || this.getAllowNether()) {
- WorldServer worldserver = this.worldServer[i];
+ // if (i == 0 || this.getAllowNether()) {
+ WorldServer worldserver = this.worlds.get(i);
this.methodProfiler.a(worldserver.getWorldData().getName());
+ /* Drop global time updates
if (this.ticks % 20 == 0) {
this.methodProfiler.a("timeSync");
2016-02-29 22:32:46 +01:00
this.v.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))), worldserver.worldProvider.getDimensionManager().getDimensionID());
this.methodProfiler.b();
}
+ // CraftBukkit end */
this.methodProfiler.a("tick");
2016-11-17 02:41:03 +01:00
@@ -571,9 +756,9 @@
worldserver.getTracker().updatePlayers();
this.methodProfiler.b();
this.methodProfiler.b();
- }
+ // } // CraftBukkit
2015-02-26 23:41:06 +01:00
- this.i[i][this.ticks % 100] = System.nanoTime() - j;
+ // this.i[i][this.ticks % 100] = System.nanoTime() - j; // CraftBukkit
}
this.methodProfiler.c("connection");
2017-05-14 04:00:00 +02:00
@@ -599,10 +784,11 @@
2016-02-29 22:32:46 +01:00
this.o.add(itickable);
}
- public static void main(String[] astring) {
+ public static void main(final OptionSet options) { // CraftBukkit - replaces main(String[] astring)
DispenserRegistry.c();
try {
+ /* CraftBukkit start - Replace everything
boolean flag = true;
String s = null;
String s1 = ".";
2017-05-14 04:00:00 +02:00
@@ -647,13 +833,16 @@
2016-02-29 22:32:46 +01:00
++j;
}
}
+ */ // CraftBukkit end
+ String s1 = "."; // PAIL?
YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString());
MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService();
GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
UserCache usercache = new UserCache(gameprofilerepository, new File(s1, MinecraftServer.a.getName()));
- final DedicatedServer dedicatedserver = new DedicatedServer(new File(s1), DataConverterRegistry.a(), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache);
+ final DedicatedServer dedicatedserver = new DedicatedServer(options, DataConverterRegistry.a(), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache);
+ /* CraftBukkit start
if (s != null) {
dedicatedserver.i(s);
}
2017-05-14 04:00:00 +02:00
@@ -684,6 +873,25 @@
2015-02-26 23:41:06 +01:00
dedicatedserver.stop();
}
});
+ */
+
+ if (options.has("port")) {
+ int port = (Integer) options.valueOf("port");
+ if (port > 0) {
+ dedicatedserver.setPort(port);
+ }
+ }
+
+ if (options.has("universe")) {
+ dedicatedserver.universe = (File) options.valueOf("universe");
+ }
+
+ if (options.has("world")) {
+ dedicatedserver.setWorld((String) options.valueOf("world"));
+ }
+
+ dedicatedserver.primaryThread.start();
+ // CraftBukkit end
} catch (Exception exception) {
MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception);
}
2017-05-14 04:00:00 +02:00
@@ -691,8 +899,10 @@
}
2016-02-29 22:32:46 +01:00
public void F() {
+ /* CraftBukkit start - prevent abuse
this.serverThread = new Thread(this, "Server thread");
this.serverThread.start();
+ // CraftBukkit end */
}
public File d(String s) {
2017-05-14 04:00:00 +02:00
@@ -708,7 +918,14 @@
}
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
}
2016-02-29 22:32:46 +01:00
public String getVersion() {
2017-05-14 04:00:00 +02:00
@@ -732,7 +949,7 @@
}
public boolean isDebugging() {
- return false;
+ return this.getPropertyManager().getBoolean("debug", false); // CraftBukkit - don't hardcode
}
2015-02-26 23:41:06 +01:00
public void g(String s) {
2017-05-14 04:00:00 +02:00
@@ -747,7 +964,7 @@
}
public String getServerModName() {
- return "vanilla";
+ return server.getName(); // CraftBukkit - cb > vanilla!
}
public CrashReport b(CrashReport crashreport) {
2017-05-14 04:00:00 +02:00
@@ -776,6 +993,7 @@
}
2016-05-10 13:47:39 +02:00
public List<String> tabCompleteCommand(ICommandListener icommandlistener, String s, @Nullable BlockPosition blockposition, boolean flag) {
+ /* CraftBukkit start - Allow tab-completion of Bukkit commands
ArrayList arraylist = Lists.newArrayList();
2016-02-29 22:32:46 +01:00
boolean flag1 = s.startsWith("/");
2017-05-14 04:00:00 +02:00
@@ -818,10 +1036,13 @@
return arraylist;
}
+ */
+ return server.tabComplete(icommandlistener, s, blockposition, flag);
+ // CraftBukkit end
}
2016-02-29 22:32:46 +01:00
public boolean M() {
2014-11-29 01:53:49 +01:00
- return this.universe != null;
+ return true; // CraftBukkit
}
public String getName() {
2017-05-14 04:00:00 +02:00
@@ -877,11 +1098,13 @@
}
public void a(EnumDifficulty enumdifficulty) {
2016-06-09 03:43:49 +02:00
- WorldServer[] aworldserver = this.worldServer;
- int i = aworldserver.length;
+ // CraftBukkit start
2016-06-09 03:43:49 +02:00
+ // 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()) {
2017-05-14 04:00:00 +02:00
@@ -948,13 +1171,11 @@
int i = 0;
if (this.worldServer != null) {
2016-06-09 03:43:49 +02:00
- 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);
2016-06-09 03:43:49 +02:00
if (worldserver != null) {
+ // CraftBukkit end
WorldData worlddata = worldserver.getWorldData();
2016-02-29 22:32:46 +01:00
mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimensionManager().getDimensionID()));
2017-05-14 04:00:00 +02:00
@@ -987,7 +1208,7 @@
2016-02-29 22:32:46 +01:00
public abstract boolean aa();
public boolean getOnlineMode() {
- return this.onlineMode;
+ return server.getOnlineMode(); // CraftBukkit
}
public void setOnlineMode(boolean flag) {
2017-05-14 04:00:00 +02:00
@@ -1067,13 +1288,9 @@
}
2016-06-09 03:43:49 +02:00
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) {
2016-06-09 03:43:49 +02:00
+ worlds.get(i).getWorldData().setGameType(enumgamemode);
}
}
2017-05-14 04:00:00 +02:00
@@ -1097,7 +1314,7 @@
}
public World getWorld() {
- return this.worldServer[0];
+ return this.worlds.get(0); // CraftBukkit
}
2017-05-14 04:00:00 +02:00
public int getSpawnProtection() {
@@ -1157,8 +1374,10 @@
2015-02-26 23:41:06 +01:00
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) {
Entity entity = worldserver.getEntity(uuid);
2017-05-14 04:00:00 +02:00
@@ -1173,7 +1392,7 @@
}
public boolean getSendCommandFeedback() {
2016-02-29 22:32:46 +01:00
- return this.worldServer[0].getGameRules().getBoolean("sendCommandFeedback");
+ return worlds.get(0).getGameRules().getBoolean("sendCommandFeedback");
}
2017-05-14 04:00:00 +02:00
public MinecraftServer C_() {
@@ -1186,7 +1405,7 @@
public <V> ListenableFuture<V> a(Callable<V> callable) {
Validate.notNull(callable);
- if (!this.isMainThread() && !this.isStopped()) {
+ if (!this.isMainThread()) { // CraftBukkit && !this.isStopped()) {
ListenableFutureTask listenablefuturetask = ListenableFutureTask.create(callable);
Queue queue = this.j;
2017-05-14 04:00:00 +02:00
@@ -1229,23 +1448,30 @@
}
public AdvancementDataWorld getAdvancementData() {
- return this.worldServer[0].z();
+ return this.worlds.get(0).z(); // CraftBukkit
}
public CustomFunctionData aL() {
- return this.worldServer[0].A();
+ return this.worlds.get(0).A(); // CraftBukkit
}
public void reload() {
if (this.isMainThread()) {
this.getPlayerList().savePlayers();
- this.worldServer[0].getLootTableRegistry().reload();
+ this.worlds.get(0).getLootTableRegistry().reload(); // CraftBukkit
this.getAdvancementData().reload();
this.aL().f();
this.getPlayerList().reload();
} else {
- this.postToMainThread(run<invokedynamic>(this));
+ this.postToMainThread(() -> reload()); // CraftBukkit - decompile error
}
2016-02-29 22:32:46 +01:00
}
+
+ // CraftBukkit start
+ @Deprecated
+ public static MinecraftServer getServer() {
+ return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
2016-02-29 22:32:46 +01:00
+ }
+ // CraftBukkit end
}