mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-16 04:33:56 -07:00
Update for 1.0.0
This commit is contained in:
@@ -32,28 +32,34 @@ import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.PluginLoadOrder;
|
||||
// CraftBukkit end
|
||||
|
||||
public class MinecraftServer implements Runnable, ICommandListener {
|
||||
public class MinecraftServer implements Runnable, ICommandListener, IMinecraftServer {
|
||||
|
||||
public static Logger log = Logger.getLogger("Minecraft");
|
||||
public static HashMap trackerList = new HashMap();
|
||||
private String s;
|
||||
private int t;
|
||||
public NetworkListenThread networkListenThread;
|
||||
public PropertyManager propertyManager;
|
||||
// public WorldServer[] worldServer; // CraftBukkit - removed!
|
||||
public long[] f = new long[100];
|
||||
public long[][] g;
|
||||
public ServerConfigurationManager serverConfigurationManager;
|
||||
public ConsoleCommandHandler consoleCommandHandler; // CraftBukkit - made public
|
||||
private boolean isRunning = true;
|
||||
public boolean isStopped = false;
|
||||
int ticks = 0;
|
||||
public String i;
|
||||
public int j;
|
||||
private List s = new ArrayList();
|
||||
private List t = Collections.synchronizedList(new ArrayList());
|
||||
// public EntityTracker[] tracker = new EntityTracker[2]; // CraftBukkit - removed!
|
||||
public String k;
|
||||
public int l;
|
||||
private List w = new ArrayList();
|
||||
private List x = Collections.synchronizedList(new ArrayList());
|
||||
// public EntityTracker[] tracker = new EntityTracker[3]; // CraftBukkit - removed!
|
||||
public boolean onlineMode;
|
||||
public boolean spawnAnimals;
|
||||
public boolean pvpMode;
|
||||
public boolean allowFlight;
|
||||
public String p;
|
||||
public String r;
|
||||
private RemoteStatusListener y;
|
||||
private RemoteControlListener z;
|
||||
|
||||
// CraftBukkit start
|
||||
public List<WorldServer> worlds = new ArrayList<WorldServer>();
|
||||
@@ -91,7 +97,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
System.setErr(new PrintStream(new LoggerOutputStream(log, Level.SEVERE), true));
|
||||
// CraftBukkit end
|
||||
|
||||
log.info("Starting minecraft server version Beta 1.8.1");
|
||||
log.info("Starting minecraft server version 1.0.0");
|
||||
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) {
|
||||
log.warning("**** NOT ENOUGH RAM!");
|
||||
log.warning("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\"");
|
||||
@@ -99,26 +105,24 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
|
||||
log.info("Loading properties");
|
||||
this.propertyManager = new PropertyManager(this.options); // CraftBukkit - CLI argument support
|
||||
String s = this.propertyManager.getString("server-ip", "");
|
||||
|
||||
this.s = this.propertyManager.getString("server-ip", "");
|
||||
this.onlineMode = this.propertyManager.getBoolean("online-mode", true);
|
||||
this.spawnAnimals = this.propertyManager.getBoolean("spawn-animals", true);
|
||||
this.pvpMode = this.propertyManager.getBoolean("pvp", true);
|
||||
this.allowFlight = this.propertyManager.getBoolean("allow-flight", false);
|
||||
this.p = this.propertyManager.getString("motd", "A Minecraft Server");
|
||||
this.p.replace('\u00a7', '$');
|
||||
this.r = this.propertyManager.getString("motd", "A Minecraft Server");
|
||||
this.r.replace('\u00a7', '$');
|
||||
InetAddress inetaddress = null;
|
||||
|
||||
if (s.length() > 0) {
|
||||
inetaddress = InetAddress.getByName(s);
|
||||
if (this.s.length() > 0) {
|
||||
inetaddress = InetAddress.getByName(this.s);
|
||||
}
|
||||
|
||||
int i = this.propertyManager.getInt("server-port", 25565);
|
||||
|
||||
log.info("Starting Minecraft server on " + (s.length() == 0 ? "*" : s) + ":" + i);
|
||||
this.t = this.propertyManager.getInt("server-port", 25565);
|
||||
log.info("Starting Minecraft server on " + (this.s.length() == 0 ? "*" : this.s) + ":" + this.t);
|
||||
|
||||
try {
|
||||
this.networkListenThread = new NetworkListenThread(this, inetaddress, i);
|
||||
this.networkListenThread = new NetworkListenThread(this, inetaddress, this.t);
|
||||
} catch (Throwable ioexception) { // CraftBukkit - IOException -> Throwable
|
||||
log.warning("**** FAILED TO BIND TO PORT!");
|
||||
log.log(Level.WARNING, "The exception was: " + ioexception.toString());
|
||||
@@ -135,33 +139,53 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
|
||||
this.serverConfigurationManager = new ServerConfigurationManager(this);
|
||||
// CraftBukkit - removed trackers
|
||||
long j = System.nanoTime();
|
||||
String s1 = this.propertyManager.getString("level-name", "world");
|
||||
String s2 = this.propertyManager.getString("level-seed", "");
|
||||
long k = (new Random()).nextLong();
|
||||
long i = System.nanoTime();
|
||||
String s = this.propertyManager.getString("level-name", "world");
|
||||
String s1 = this.propertyManager.getString("level-seed", "");
|
||||
long j = (new Random()).nextLong();
|
||||
|
||||
if (s2.length() > 0) {
|
||||
if (s1.length() > 0) {
|
||||
try {
|
||||
k = Long.parseLong(s2);
|
||||
long k = Long.parseLong(s1);
|
||||
|
||||
if (k != 0L) {
|
||||
j = k;
|
||||
}
|
||||
} catch (NumberFormatException numberformatexception) {
|
||||
k = (long) s2.hashCode();
|
||||
j = (long) s1.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Preparing level \"" + s1 + "\"");
|
||||
this.a(new WorldLoaderServer(new File(".")), s1, k);
|
||||
log.info("Preparing level \"" + s + "\"");
|
||||
this.a(new WorldLoaderServer(new File(".")), s, j);
|
||||
|
||||
// CraftBukkit start
|
||||
long elapsed = System.nanoTime() - j;
|
||||
long elapsed = System.nanoTime() - i;
|
||||
String time = String.format("%.3fs", elapsed / 10000000000.0D);
|
||||
log.info("Done (" + time + ")! For help, type \"help\" or \"?\"");
|
||||
// CratBukkit end
|
||||
|
||||
if (this.propertyManager.getBoolean("enable-query", false)) {
|
||||
log.info("Starting GS4 status listener");
|
||||
this.y = new RemoteStatusListener(this);
|
||||
this.y.a();
|
||||
}
|
||||
|
||||
if (this.propertyManager.getBoolean("enable-rcon", false)) {
|
||||
log.info("Starting remote control listener");
|
||||
this.z = new RemoteControlListener(this);
|
||||
this.z.a();
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
if (this.propertyManager.properties.containsKey("spawn-protection")) {
|
||||
log.info("'spawn-protection' in server.properties has been moved to 'settings.spawn-radius' in bukkit.yml. I will move your config for you.");
|
||||
this.server.setSpawnRadius(this.propertyManager.getInt("spawn-protection", 16));
|
||||
this.propertyManager.properties.remove("spawn-protection");
|
||||
this.propertyManager.savePropertiesFile();
|
||||
}
|
||||
// CratBukkit end
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -171,21 +195,36 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
convertable.convert(s, new ConvertProgressUpdater(this));
|
||||
}
|
||||
|
||||
// CraftBukkit - removed world array
|
||||
// CraftBukkit - removed world and ticktime arrays
|
||||
int j = this.propertyManager.getInt("gamemode", 0);
|
||||
|
||||
j = WorldSettings.a(j);
|
||||
log.info("Default game type: " + j);
|
||||
|
||||
// CraftBukkit start (+ removed worldsettings and servernbtmanager)
|
||||
for (int k = 0; k < (this.propertyManager.getBoolean("allow-nether", true) ? 2 : 1); ++k) {
|
||||
int worldCount = 2;
|
||||
|
||||
if (this.propertyManager.getBoolean("allow-nether", true)) {
|
||||
worldCount++;
|
||||
}
|
||||
|
||||
for (int k = 0; k < worldCount; ++k) {
|
||||
WorldServer world;
|
||||
int dimension = k == 0 ? 0 : -1;
|
||||
int dimension = 0;
|
||||
|
||||
if (k == 1) {
|
||||
dimension = -1;
|
||||
}
|
||||
|
||||
if (k == 2) {
|
||||
dimension = 1;
|
||||
}
|
||||
|
||||
String worldType = Environment.getEnvironment(dimension).toString().toLowerCase();
|
||||
String name = (dimension == 0) ? s : s + "_" + worldType;
|
||||
|
||||
ChunkGenerator gen = this.server.getGenerator(name);
|
||||
WorldSettings settings = new WorldSettings(i, j, true);
|
||||
WorldSettings settings = new WorldSettings(i, j, true, false);
|
||||
|
||||
if (k == 0) {
|
||||
world = new WorldServer(this, new ServerNBTManager(server.getWorldContainer(), s, true), s, dimension, settings, org.bukkit.World.Environment.getEnvironment(dimension), gen); // CraftBukkit
|
||||
@@ -231,7 +270,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
world.addIWorldAccess(new WorldManager(this, world));
|
||||
world.difficulty = this.propertyManager.getInt("difficulty", 1);
|
||||
world.setSpawnFlags(this.propertyManager.getBoolean("spawn-monsters", true), this.spawnAnimals);
|
||||
world.p().setGameType(j);
|
||||
world.r().setGameType(j);
|
||||
this.worlds.add(world);
|
||||
this.serverConfigurationManager.setPlayerFileData(this.worlds.toArray(new WorldServer[0]));
|
||||
}
|
||||
@@ -261,13 +300,13 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
int i2 = (short1 * 2 + 1) * (short1 * 2 + 1);
|
||||
int j2 = (j1 + short1) * (short1 * 2 + 1) + k1 + 1;
|
||||
|
||||
this.a("Preparing spawn area", j2 * 100 / i2);
|
||||
this.b("Preparing spawn area", j2 * 100 / i2);
|
||||
l = l1;
|
||||
}
|
||||
|
||||
worldserver.chunkProviderServer.getChunkAt(chunkcoordinates.x + j1 >> 4, chunkcoordinates.z + k1 >> 4);
|
||||
|
||||
while (worldserver.v() && this.isRunning) {
|
||||
while (worldserver.x() && this.isRunning) {
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -281,18 +320,18 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
this.e();
|
||||
this.t();
|
||||
}
|
||||
|
||||
private void a(String s, int i) {
|
||||
this.i = s;
|
||||
this.j = i;
|
||||
private void b(String s, int i) {
|
||||
this.k = s;
|
||||
this.l = i;
|
||||
log.info(s + ": " + i + "%");
|
||||
}
|
||||
|
||||
private void e() {
|
||||
this.i = null;
|
||||
this.j = 0;
|
||||
private void t() {
|
||||
this.k = null;
|
||||
this.l = 0;
|
||||
|
||||
this.server.enablePlugins(PluginLoadOrder.POSTWORLD); // CraftBukkit
|
||||
}
|
||||
@@ -365,13 +404,13 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
j += l;
|
||||
i = k;
|
||||
if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit
|
||||
this.h();
|
||||
this.w();
|
||||
j = 0L;
|
||||
} else {
|
||||
while (j > 50L) {
|
||||
MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
|
||||
j -= 50L;
|
||||
this.h();
|
||||
this.w();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -411,25 +450,26 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void h() {
|
||||
private void w() {
|
||||
long i = System.nanoTime();
|
||||
ArrayList arraylist = new ArrayList();
|
||||
Iterator iterator = trackerList.keySet().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String s = (String) iterator.next();
|
||||
int i = ((Integer) trackerList.get(s)).intValue();
|
||||
int j = ((Integer) trackerList.get(s)).intValue();
|
||||
|
||||
if (i > 0) {
|
||||
trackerList.put(s, Integer.valueOf(i - 1));
|
||||
if (j > 0) {
|
||||
trackerList.put(s, Integer.valueOf(j - 1));
|
||||
} else {
|
||||
arraylist.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
int j;
|
||||
int k;
|
||||
|
||||
for (j = 0; j < arraylist.size(); ++j) {
|
||||
trackerList.remove(arraylist.get(j));
|
||||
for (k = 0; k < arraylist.size(); ++k) {
|
||||
trackerList.remove(arraylist.get(k));
|
||||
}
|
||||
|
||||
AxisAlignedBB.a();
|
||||
@@ -442,15 +482,16 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
|
||||
// Send timeupdates 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.serverConfigurationManager.players.size(); ++i) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) this.serverConfigurationManager.players.get(i);
|
||||
for ( k = 0; k < this.serverConfigurationManager.players.size(); ++k) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) this.serverConfigurationManager.players.get(k);
|
||||
entityplayer.netServerHandler.sendPacket(new Packet4UpdateTime(entityplayer.getPlayerTime())); // Add support for per player time
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < this.worlds.size(); ++j) {
|
||||
// if (j == 0 || this.propertyManager.getBoolean("allow-nether", true)) {
|
||||
WorldServer worldserver = this.worlds.get(j);
|
||||
for (k = 0; k < this.worlds.size(); ++k) {
|
||||
long l = System.nanoTime();
|
||||
// if (k == 0 || this.propertyManager.getBoolean("allow-nether", true)) {
|
||||
WorldServer worldserver = this.worlds.get(k);
|
||||
|
||||
/* Drop global timeupdates
|
||||
if (this.ticks % 20 == 0) {
|
||||
@@ -460,25 +501,28 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
|
||||
worldserver.doTick();
|
||||
|
||||
while (worldserver.v()) {
|
||||
;
|
||||
while (true) {
|
||||
if (!worldserver.x()) {
|
||||
worldserver.tickEntities();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
worldserver.tickEntities();
|
||||
}
|
||||
|
||||
// this.g[k][this.ticks % 100] = System.nanoTime() - l; // CraftBukkit
|
||||
// } // CraftBukkit
|
||||
|
||||
this.networkListenThread.a();
|
||||
this.serverConfigurationManager.b();
|
||||
|
||||
// CraftBukkit start
|
||||
for (j = 0; j < this.worlds.size(); ++j) {
|
||||
this.worlds.get(j).tracker.updatePlayers();
|
||||
for (k = 0; k < this.worlds.size(); ++k) {
|
||||
this.worlds.get(k).tracker.updatePlayers();
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
for (j = 0; j < this.s.size(); ++j) {
|
||||
((IUpdatePlayerListBox) this.s.get(j)).a();
|
||||
for (k = 0; k < this.w.size(); ++k) {
|
||||
((IUpdatePlayerListBox) this.w.get(k)).a();
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -486,15 +530,17 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
} catch (Exception exception) {
|
||||
log.log(Level.WARNING, "Unexpected exception while parsing console command", exception);
|
||||
}
|
||||
|
||||
this.f[this.ticks % 100] = System.nanoTime() - i;
|
||||
}
|
||||
|
||||
public void issueCommand(String s, ICommandListener icommandlistener) {
|
||||
this.t.add(new ServerCommand(s, icommandlistener));
|
||||
this.x.add(new ServerCommand(s, icommandlistener));
|
||||
}
|
||||
|
||||
public void b() {
|
||||
while (this.t.size() > 0) {
|
||||
ServerCommand servercommand = (ServerCommand) this.t.remove(0);
|
||||
while (this.x.size() > 0) {
|
||||
ServerCommand servercommand = (ServerCommand) this.x.remove(0);
|
||||
|
||||
// CraftBukkit start - ServerCommand for preprocessing
|
||||
ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command);
|
||||
@@ -508,7 +554,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
}
|
||||
|
||||
public void a(IUpdatePlayerListBox iupdateplayerlistbox) {
|
||||
this.s.add(iupdateplayerlistbox);
|
||||
this.w.add(iupdateplayerlistbox);
|
||||
}
|
||||
|
||||
public static void main(final OptionSet options) { // CraftBukkit - replaces main(String args[])
|
||||
@@ -533,7 +579,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
log.info(s);
|
||||
}
|
||||
|
||||
public void c(String s) {
|
||||
public void warning(String s) {
|
||||
log.warning(s);
|
||||
}
|
||||
|
||||
@@ -557,6 +603,94 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||
return this.getWorldServer(i).tracker; // CraftBukkit
|
||||
}
|
||||
|
||||
public int getProperty(String s, int i) {
|
||||
return this.propertyManager.getInt(s, i);
|
||||
}
|
||||
|
||||
public String a(String s, String s1) {
|
||||
return this.propertyManager.getString(s, s1);
|
||||
}
|
||||
|
||||
public void a(String s, Object object) {
|
||||
this.propertyManager.a(s, object);
|
||||
}
|
||||
|
||||
public void c() {
|
||||
this.propertyManager.savePropertiesFile();
|
||||
}
|
||||
|
||||
public String getPropertiesFile() {
|
||||
File file1 = this.propertyManager.c();
|
||||
|
||||
return file1 != null ? file1.getAbsolutePath() : "No settings file";
|
||||
}
|
||||
|
||||
public String getMotd() {
|
||||
return this.s;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return this.t;
|
||||
}
|
||||
|
||||
public String getServerAddress() {
|
||||
return this.r;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "1.0.0";
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
return this.serverConfigurationManager.j();
|
||||
}
|
||||
|
||||
public int getMaxPlayers() {
|
||||
return this.serverConfigurationManager.k();
|
||||
}
|
||||
|
||||
public String[] getPlayers() {
|
||||
return this.serverConfigurationManager.d();
|
||||
}
|
||||
|
||||
public String getWorldName() {
|
||||
return this.propertyManager.getString("level-name", "world");
|
||||
}
|
||||
|
||||
public String getPlugins() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public void o() {}
|
||||
|
||||
public String d(String s) {
|
||||
RemoteControlCommandListener.a.a();
|
||||
this.consoleCommandHandler.handle(new ServerCommand(s, RemoteControlCommandListener.a));
|
||||
return RemoteControlCommandListener.a.b();
|
||||
}
|
||||
|
||||
public boolean isDebugging() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void severe(String s) {
|
||||
log.log(Level.SEVERE, s);
|
||||
}
|
||||
|
||||
public void debug(String s) {
|
||||
if (this.isDebugging()) {
|
||||
log.log(Level.INFO, s);
|
||||
}
|
||||
}
|
||||
|
||||
public String[] q() {
|
||||
return (String[]) this.serverConfigurationManager.f().toArray(new String[0]);
|
||||
}
|
||||
|
||||
public String[] r() {
|
||||
return (String[]) this.serverConfigurationManager.e().toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static boolean isRunning(MinecraftServer minecraftserver) {
|
||||
return minecraftserver.isRunning;
|
||||
}
|
||||
|
Reference in New Issue
Block a user