summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/MinecraftServer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/minecraft/server/MinecraftServer.java')
-rw-r--r--src/main/java/net/minecraft/server/MinecraftServer.java560
1 files changed, 312 insertions, 248 deletions
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 029131d2..cdc41b41 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1,17 +1,33 @@
package net.minecraft.server;
import java.awt.GraphicsEnvironment;
+import java.awt.image.BufferedImage;
import java.io.File;
import java.net.Proxy;
import java.security.KeyPair;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
+import java.util.Random;
+import java.util.UUID;
import java.util.concurrent.Callable;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import javax.imageio.ImageIO;
+
+import net.minecraft.util.com.google.common.base.Charsets;
+import net.minecraft.util.com.mojang.authlib.GameProfile;
+import net.minecraft.util.com.mojang.authlib.minecraft.MinecraftSessionService;
+import net.minecraft.util.com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
+import net.minecraft.util.io.netty.buffer.ByteBuf;
+import net.minecraft.util.io.netty.buffer.ByteBufOutputStream;
+import net.minecraft.util.io.netty.buffer.Unpooled;
+import net.minecraft.util.io.netty.handler.codec.base64.Base64;
+import net.minecraft.util.org.apache.commons.lang3.Validate;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
// CraftBukkit start
import java.io.IOException;
@@ -27,13 +43,17 @@ import org.bukkit.event.world.WorldSaveEvent;
public abstract class MinecraftServer implements ICommandListener, Runnable, IMojangStatistics {
- private static MinecraftServer l;
+ private static final Logger h = LogManager.getLogger();
+ private static MinecraftServer i;
public Convertable convertable; // CraftBukkit - private final -> public
- private final MojangStatisticsGenerator n = new MojangStatisticsGenerator("server", this, aq());
+ private final MojangStatisticsGenerator k = new MojangStatisticsGenerator("server", this, ap());
public File universe; // CraftBukkit - private final -> public
- private final List p = new ArrayList();
- private final ICommandHandler q;
+ private final List m = new ArrayList();
+ private final ICommandHandler n;
public final MethodProfiler methodProfiler = new MethodProfiler();
+ private final ServerConnection o;
+ private final ServerPing p = new ServerPing();
+ private final Random q = new Random();
private String serverIp;
private int s = -1;
public WorldServer[] worldServer;
@@ -41,7 +61,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
private boolean isRunning = true;
private boolean isStopped;
private int ticks;
- protected Proxy c;
+ protected final Proxy c;
public String d;
public int e;
private boolean onlineMode;
@@ -51,29 +71,23 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
private boolean allowFlight;
private String motd;
private int D;
- private int E;
- private long F;
- private long G;
- private long H;
- private long I;
- public final long[] f;
- public final long[] g;
- public final long[] h;
- public final long[] i;
- public final long[] j;
- public long[][] k;
- private KeyPair J;
- private String K;
- private String L;
+ private int E = 0;
+ public final long[] f = new long[100];
+ public long[][] g;
+ private KeyPair F;
+ private String G;
+ private String H;
private boolean demoMode;
- private boolean O;
- private boolean P;
- private String Q;
+ private boolean K;
+ private boolean L;
+ private String M = "";
+ private boolean N;
+ private long O;
+ private String P;
+ private boolean Q;
private boolean R;
- private long S;
- private String T;
- private boolean U;
- private boolean V;
+ private final MinecraftSessionService S;
+ private long T = 0L;
// CraftBukkit start
public List<WorldServer> worlds = new ArrayList<WorldServer>();
@@ -88,20 +102,14 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
public int autosavePeriod;
// CraftBukkit end
- public MinecraftServer(OptionSet options) { // CraftBukkit - signature file -> OptionSet
- this.c = Proxy.NO_PROXY;
- this.E = 0;
- this.f = new long[100];
- this.g = new long[100];
- this.h = new long[100];
- this.i = new long[100];
- this.j = new long[100];
- this.Q = "";
- l = this;
+ public MinecraftServer(OptionSet options, Proxy proxy) { // CraftBukkit - signature file -> OptionSet
+ i = this;
+ this.c = proxy;
// this.universe = file1; // CraftBukkit
- this.q = new CommandDispatcher();
- // this.convertable = new WorldLoaderServer(server.getWorldContainer()); // CraftBukkit - moved to DedicatedServer.init
- this.as();
+ this.o = new ServerConnection(this);
+ this.n = new CommandDispatcher();
+ // this.convertable = new WorldLoaderServer(file1); // CraftBukkit - moved to DedicatedServer.init
+ this.S = (new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
// CraftBukkit start
this.options = options;
@@ -117,7 +125,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.reader = new ConsoleReader(System.in, System.out);
this.reader.setExpandEvents(false);
} catch (IOException ex) {
- Logger.getLogger(MinecraftServer.class.getName()).log(Level.SEVERE, null, ex);
+ h.warn((String) null, ex);
}
}
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
@@ -128,32 +136,41 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
public abstract PropertyManager getPropertyManager();
// CraftBukkit end
- private void as() {
- DispenserRegistry.a();
- }
-
protected abstract boolean init() throws java.net.UnknownHostException; // CraftBukkit - throws UnknownHostException
protected void a(String s) {
if (this.getConvertable().isConvertable(s)) {
- this.getLogger().info("Converting map!");
+ h.info("Converting map!");
this.b("menu.convertingLevel");
this.getConvertable().convert(s, new ConvertProgressUpdater(this));
}
}
protected synchronized void b(String s) {
- this.T = s;
+ this.P = s;
}
protected void a(String s, String s1, long i, WorldType worldtype, String s2) {
this.a(s);
this.b("menu.loadingLevel");
this.worldServer = new WorldServer[3];
- // CraftBukkit - Removed ticktime arrays
- IDataManager idatamanager = this.convertable.a(s, true);
- WorldData worlddata = idatamanager.getWorldData();
- // CraftBukkit start - Removed worldsettings
+ // this.g = new long[this.worldServer.length][100]; // CraftBukkit - Removed ticktime arrays
+ // IDataManager idatamanager = this.convertable.a(s, true);
+ // WorldData worlddata = idatamanager.getWorldData();
+ /* CraftBukkit start - Removed worldsettings
+ WorldSettings worldsettings;
+
+ if (worlddata == null) {
+ worldsettings = new WorldSettings(i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype);
+ worldsettings.a(s2);
+ } else {
+ worldsettings = new WorldSettings(worlddata);
+ }
+
+ if (this.K) {
+ worldsettings.a();
+ }
+ // */
int worldCount = 3;
for (int j = 0; j < worldCount; ++j) {
@@ -184,13 +201,14 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
worldsettings.a(s2);
if (j == 0) {
- if (this.O()) { // Strip out DEMO?
- // CraftBukkit
- world = new DemoWorldServer(this, new ServerNBTManager(server.getWorldContainer(), s1, true), s1, dimension, this.methodProfiler, this.getLogger());
+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), s1, true);
+ if (this.P()) {
+ world = new DemoWorldServer(this, idatamanager, s1, dimension, this.methodProfiler);
} else {
- // CraftBukkit
- world = new WorldServer(this, new ServerNBTManager(server.getWorldContainer(), s1, true), s1, dimension, worldsettings, this.methodProfiler, this.getLogger(), Environment.getEnvironment(dimension), gen);
+ // world =, b0 to dimension, added Environment and gen
+ world = new WorldServer(this, idatamanager, s1, dimension, worldsettings, this.methodProfiler, Environment.getEnvironment(dimension), gen);
}
+ this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard());
} else {
String dim = "DIM" + dimension;
@@ -198,61 +216,60 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
File oldWorld = new File(new File(s), dim);
if ((!newWorld.isDirectory()) && (oldWorld.isDirectory())) {
- final IConsoleLogManager log = this.getLogger();
- log.info("---- Migration of old " + worldType + " folder required ----");
- log.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.");
- log.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.");
- log.info("Attempting to move " + oldWorld + " to " + newWorld + "...");
+ h.info("---- Migration of old " + worldType + " folder required ----");
+ h.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.");
+ h.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.");
+ h.info("Attempting to move " + oldWorld + " to " + newWorld + "...");
if (newWorld.exists()) {
- log.severe("A file or folder already exists at " + newWorld + "!");
- log.info("---- Migration of old " + worldType + " folder failed ----");
+ h.warn("A file or folder already exists at " + newWorld + "!");
+ h.info("---- Migration of old " + worldType + " folder failed ----");
} else if (newWorld.getParentFile().mkdirs()) {
if (oldWorld.renameTo(newWorld)) {
- log.info("Success! To restore " + worldType + " in the future, simply move " + newWorld + " to " + oldWorld);
+ h.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"));
} catch (IOException exception) {
- log.severe("Unable to migrate world data.");
+ h.warn("Unable to migrate world data.");
}
- log.info("---- Migration of old " + worldType + " folder complete ----");
+ h.info("---- Migration of old " + worldType + " folder complete ----");
} else {
- log.severe("Could not move folder " + oldWorld + " to " + newWorld + "!");
- log.info("---- Migration of old " + worldType + " folder failed ----");
+ h.warn("Could not move folder " + oldWorld + " to " + newWorld + "!");
+ h.info("---- Migration of old " + worldType + " folder failed ----");
}
} else {
- log.severe("Could not create path for " + newWorld + "!");
- log.info("---- Migration of old " + worldType + " folder failed ----");
+ h.warn("Could not create path for " + newWorld + "!");
+ h.info("---- Migration of old " + worldType + " folder failed ----");
}
}
- // CraftBukkit
- world = new SecondaryWorldServer(this, new ServerNBTManager(server.getWorldContainer(), name, true), name, dimension, worldsettings, this.worlds.get(0), this.methodProfiler, this.getLogger(), Environment.getEnvironment(dimension), gen);
+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, true);
+ // world =, b0 to dimension, s1 to name, added Environment and gen
+ world = new SecondaryWorldServer(this, idatamanager, name, dimension, worldsettings, this.worlds.get(0), this.methodProfiler, Environment.getEnvironment(dimension), gen);
}
if (gen != null) {
world.getWorld().getPopulators().addAll(gen.getDefaultPopulators(world.getWorld()));
}
- this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard());
-
this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld()));
world.addIWorldAccess(new WorldManager(this, world));
- if (!this.K()) {
+ if (!this.L()) {
world.getWorldData().setGameType(this.getGamemode());
}
+
this.worlds.add(world);
this.t.setPlayerFileData(this.worlds.toArray(new WorldServer[this.worlds.size()]));
// CraftBukkit end
}
- this.c(this.getDifficulty());
- this.f();
+ this.a(this.getDifficulty());
+ this.g();
}
- protected void f() {
+ protected void g() {
boolean flag = true;
boolean flag1 = true;
boolean flag2 = true;
@@ -265,18 +282,18 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
// CraftBukkit start
for (int m = 0; m < this.worlds.size(); ++m) {
WorldServer worldserver = this.worlds.get(m);
- this.getLogger().info("Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")");
+ h.info("Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")");
if (!worldserver.getWorld().getKeepSpawnInMemory()) {
continue;
}
ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
- long j = aq();
+ long j = ap();
i = 0;
for (int k = -192; k <= 192 && this.isRunning(); k += 16) {
for (int l = -192; l <= 192 && this.isRunning(); l += 16) {
- long i1 = aq();
+ long i1 = ap();
if (i1 - j > 1000L) {
this.a_("Preparing spawn area", i * 100 / 625);
@@ -289,26 +306,26 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
}
// CraftBukkit end
- this.l();
+ this.m();
}
public abstract boolean getGenerateStructures();
public abstract EnumGamemode getGamemode();
- public abstract int getDifficulty();
+ public abstract EnumDifficulty getDifficulty();
public abstract boolean isHardcore();
- public abstract int k();
+ public abstract int l();
protected void a_(String s, int i) {
this.d = s;
this.e = i;
- this.getLogger().info(s + ": " + i + "%");
+ h.info(s + ": " + i + "%");
}
- protected void l() {
+ protected void m() {
this.d = null;
this.e = 0;
@@ -316,14 +333,17 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
protected void saveChunks(boolean flag) throws ExceptionWorldConflict { // CraftBukkit - added throws
- if (!this.P) {
+ if (!this.L) {
// CraftBukkit start
- for (int j = 0; j < this.worlds.size(); ++j) {
+ // WorldServer[] aworldserver = this.worldServer;
+ int i = this.worlds.size();
+
+ for (int j = 0; j < i; ++j) {
WorldServer worldserver = this.worlds.get(j);
if (worldserver != null) {
if (!flag) {
- this.getLogger().info("Saving chunks for level \'" + worldserver.getWorldData().getName() + "\'/" + worldserver.worldProvider.getName());
+ h.info("Saving chunks for level \'" + worldserver.getWorldData().getName() + "\'/" + worldserver.worldProvider.getName());
}
worldserver.save(true, (IProgressUpdate) null);
@@ -331,15 +351,15 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
WorldSaveEvent event = new WorldSaveEvent(worldserver.getWorld());
this.server.getPluginManager().callEvent(event);
+ // CraftBukkit end
}
}
- // CraftBukkit end
}
}
public void stop() throws ExceptionWorldConflict { // CraftBukkit - added throws
- if (!this.P) {
- this.getLogger().info("Stopping server");
+ if (!this.L) {
+ h.info("Stopping server");
// CraftBukkit start
if (this.server != null) {
this.server.disablePlugins();
@@ -347,16 +367,16 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
// CraftBukkit end
if (this.ag() != null) {
- this.ag().a();
+ this.ag().b();
}
if (this.t != null) {
- this.getLogger().info("Saving players");
+ h.info("Saving players");
this.t.savePlayers();
this.t.r();
}
- this.getLogger().info("Saving worlds");
+ h.info("Saving worlds");
this.saveChunks(false);
/* CraftBukkit start - Handled in saveChunks
@@ -366,8 +386,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
worldserver.saveLevel();
}
// CraftBukkit end */
- if (this.n != null && this.n.d()) {
- this.n.e();
+
+ if (this.k.d()) {
+ this.k.e();
}
}
}
@@ -391,45 +412,50 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
public void run() {
try {
if (this.init()) {
- long i = aq();
+ long i = ap();
+ long j = 0L;
+
+ this.p.setMOTD(new ChatComponentText(this.motd));
+ this.p.setServerInfo(new ServerPingServerData("1.7.2", 4));
+ this.a(this.p);
- for (long j = 0L; this.isRunning; this.R = true) {
- long k = aq();
+ while (this.isRunning) {
+ long k = ap();
long l = k - i;
- if (l > 2000L && i - this.S >= 15000L) {
+ if (l > 2000L && i - this.O >= 15000L) {
if (this.server.getWarnOnOverload()) // CraftBukkit - Added option to suppress warning messages
- this.getLogger().warning("Can\'t keep up! Did the system time change, or is the server overloaded?");
+ h.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", new Object[] { Long.valueOf(l), Long.valueOf(l / 50L)});
l = 2000L;
- this.S = i;
+ this.O = i;
}
if (l < 0L) {
- this.getLogger().warning("Time ran backwards! Did the system time change?");
+ h.warn("Time ran backwards! Did the system time change?");
l = 0L;
}
j += l;
i = k;
if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit
- this.s();
+ this.t();
j = 0L;
} else {
while (j > 50L) {
MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
j -= 50L;
- this.s();
+ this.t();
}
}
Thread.sleep(1L);
+ this.N = true;
}
} else {
this.a((CrashReport) null);
}
} catch (Throwable throwable) {
- throwable.printStackTrace();
- this.getLogger().severe("Encountered an unexpected exception " + throwable.getClass().getSimpleName(), throwable);
+ h.error("Encountered an unexpected exception", throwable);
CrashReport crashreport = null;
if (throwable instanceof ReportedException) {
@@ -438,12 +464,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
crashreport = this.b(new CrashReport("Exception in server tick loop", throwable));
}
- File file1 = new File(new File(this.q(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt");
+ File file1 = new File(new File(this.r(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt");
- if (crashreport.a(file1, this.getLogger())) {
- this.getLogger().severe("This crash report has been saved to: " + file1.getAbsolutePath());
+ if (crashreport.a(file1)) {
+ h.error("This crash report has been saved to: " + file1.getAbsolutePath());
} else {
- this.getLogger().severe("We were unable to save this crash report to disk.");
+ h.error("We were unable to save this crash report to disk.");
}
this.a(crashreport);
@@ -452,7 +478,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.stop();
this.isStopped = true;
} catch (Throwable throwable1) {
- throwable1.printStackTrace();
+ h.error("Exception stopping the server", throwable1);
} finally {
// CraftBukkit start - Restore terminal to original settings
try {
@@ -460,32 +486,67 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
} catch (Exception e) {
}
// CraftBukkit end
- this.r();
+ this.s();
+ }
+ }
+ }
+
+ private void a(ServerPing serverping) {
+ File file1 = this.d("server-icon.png");
+
+ if (file1.isFile()) {
+ ByteBuf bytebuf = Unpooled.buffer();
+
+ try {
+ BufferedImage bufferedimage = ImageIO.read(file1);
+
+ Validate.validState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide", new Object[0]);
+ Validate.validState(bufferedimage.getHeight() == 64, "Must be 64 pixels high", new Object[0]);
+ ImageIO.write(bufferedimage, "PNG", new ByteBufOutputStream(bytebuf));
+ ByteBuf bytebuf1 = Base64.encode(bytebuf);
+
+ serverping.setFavicon("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8));
+ } catch (Exception exception) {
+ h.error("Couldn\'t load server icon", exception);
}
}
}
- protected File q() {
+ protected File r() {
return new File(".");
}
protected void a(CrashReport crashreport) {}
- protected void r() {}
+ protected void s() {}
- protected void s() throws ExceptionWorldConflict { // CraftBukkit - added throws
+ protected void t() throws ExceptionWorldConflict { // CraftBukkit - added throws
long i = System.nanoTime();
AxisAlignedBB.a().a();
++this.ticks;
- if (this.U) {
- this.U = false;
+ if (this.Q) {
+ this.Q = false;
this.methodProfiler.a = true;
this.methodProfiler.a();
}
this.methodProfiler.a("root");
- this.t();
+ this.u();
+ if (i - this.T >= 5000000000L) {
+ this.T = i;
+ this.p.setPlayerSample(new ServerPingPlayerSample(this.C(), this.B()));
+ GameProfile[] agameprofile = new GameProfile[Math.min(this.B(), 12)];
+ int j = MathHelper.nextInt(this.q, 0, this.B() - agameprofile.length);
+
+ for (int k = 0; k < agameprofile.length; ++k) {
+ agameprofile[k] = ((EntityPlayer) this.t.players.get(j + k)).getProfile();
+ }
+
+ Collections.shuffle(Arrays.asList(agameprofile));
+ this.p.b().a(agameprofile);
+ }
+
if ((this.autosavePeriod > 0) && ((this.ticks % this.autosavePeriod) == 0)) { // CraftBukkit
this.methodProfiler.a("save");
this.t.savePlayers();
@@ -494,30 +555,22 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
this.methodProfiler.a("tallying");
- this.j[this.ticks % 100] = System.nanoTime() - i;
- this.f[this.ticks % 100] = Packet.q - this.F;
- this.F = Packet.q;
- this.g[this.ticks % 100] = Packet.r - this.G;
- this.G = Packet.r;
- this.h[this.ticks % 100] = Packet.o - this.H;
- this.H = Packet.o;
- this.i[this.ticks % 100] = Packet.p - this.I;
- this.I = Packet.p;
+ this.f[this.ticks % 100] = System.nanoTime() - i;
this.methodProfiler.b();
this.methodProfiler.a("snooper");
- if (!this.n.d() && this.ticks > 100) {
- this.n.a();
+ if (!this.k.d() && this.ticks > 100) {
+ this.k.a();
}
if (this.ticks % 6000 == 0) {
- this.n.b();
+ this.k.b();
}
this.methodProfiler.b();
this.methodProfiler.b();
}
- public void t() {
+ public void u() {
this.methodProfiler.a("levels");
// CraftBukkit start
@@ -534,7 +587,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
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 Packet4UpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean("doDaylightCycle"))); // Add support for per player time
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean("doDaylightCycle"))); // Add support for per player time
}
}
@@ -553,7 +606,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
/* Drop global time updates
if (this.ticks % 20 == 0) {
this.methodProfiler.a("timeSync");
- this.t.a(new Packet4UpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle")), worldserver.worldProvider.dimension);
+ this.t.a(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle")), worldserver.worldProvider.dimension);
this.methodProfiler.b();
}
// CraftBukkit end */
@@ -585,17 +638,17 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.methodProfiler.b();
// } // CraftBukkit
- // this.k[i][this.ticks % 100] = System.nanoTime() - j; // CraftBukkit
+ // this.g[i][this.ticks % 100] = System.nanoTime() - j; // CraftBukkit
}
this.methodProfiler.c("connection");
- this.ag().b();
+ this.ag().c();
this.methodProfiler.c("players");
this.t.tick();
this.methodProfiler.c("tickables");
- for (i = 0; i < this.p.size(); ++i) {
- ((IUpdatePlayerListBox) this.p.get(i)).a();
+ for (i = 0; i < this.m.size(); ++i) {
+ ((IUpdatePlayerListBox) this.m.get(i)).a();
}
this.methodProfiler.b();
@@ -606,12 +659,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
public void a(IUpdatePlayerListBox iupdateplayerlistbox) {
- this.p.add(iupdateplayerlistbox);
+ this.m.add(iupdateplayerlistbox);
}
public static void main(final OptionSet options) { // CraftBukkit - replaces main(String[] astring)
- StatisticList.a();
- IConsoleLogManager iconsolelogmanager = null;
+ DispenserRegistry.b();
try {
/* CraftBukkit start - Replace everything
@@ -659,26 +711,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
++j;
}
}
- // */
- DedicatedServer dedicatedserver = new DedicatedServer(options);
+ DedicatedServer dedicatedserver = new DedicatedServer(new File(s1));
- iconsolelogmanager = dedicatedserver.getLogger();
- 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.k((String) options.valueOf("world"));
- }
- /*
if (s != null) {
dedicatedserver.j(s);
}
@@ -700,36 +735,49 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
if (flag) {
- dedicatedserver.au();
+ dedicatedserver.ay();
+ }
+ // */
+
+ DedicatedServer dedicatedserver = new DedicatedServer(options);
+
+ 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.k((String) options.valueOf("world"));
}
- */
dedicatedserver.primaryThread.start();
- // Runtime.getRuntime().addShutdownHook(new ThreadShutdown(dedicatedserver));
+ // Runtime.getRuntime().addShutdownHook(new ThreadShutdown("Server Shutdown Thread", dedicatedserver));
// CraftBukkit end
} catch (Exception exception) {
- if (iconsolelogmanager != null) {
- iconsolelogmanager.severe("Failed to start the minecraft server", exception);
- } else {
- Logger.getAnonymousLogger().log(Level.SEVERE, "Failed to start the minecraft server", exception);
- }
+ h.fatal("Failed to start the minecraft server", exception);
}
}
- public void v() {
+ public void w() {
// (new ThreadServerApplication(this, "Server thread")).start(); // CraftBukkit - prevent abuse
}
public File d(String s) {
- return new File(this.q(), s);
+ return new File(this.r(), s);
}
public void info(String s) {
- this.getLogger().info(s);
+ h.info(s);
}
public void warning(String s) {
- this.getLogger().warning(s);
+ h.warn(s);
}
public WorldServer getWorldServer(int i) {
@@ -744,27 +792,27 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
// CraftBukkit end
}
- public String w() {
+ public String x() {
return this.serverIp;
}
- public int x() {
+ public int y() {
return this.s;
}
- public String y() {
+ public String z() {
return this.motd;
}
public String getVersion() {
- return "1.6.4";
+ return "1.7.2";
}
- public int A() {
+ public int B() {
return this.t.getPlayerCount();
}
- public int B() {
+ public int C() {
return this.t.getMaxPlayers();
}
@@ -800,19 +848,19 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
// CraftBukkit start
- public String g(final String s) { // CraftBukkit - final parameter
+ public String g(final String s) { // final parameter
Waitable<String> waitable = new Waitable<String>() {
@Override
protected String evaluate() {
- RemoteControlCommandListener.instance.d();
+ RemoteControlCommandListener.instance.e();
// Event changes start
RemoteServerCommandEvent event = new RemoteServerCommandEvent(MinecraftServer.this.remoteConsole, s);
MinecraftServer.this.server.getPluginManager().callEvent(event);
// Event changes end
ServerCommand servercommand = new ServerCommand(event.getCommand(), RemoteControlCommandListener.instance);
- // this.p.a(RemoteControlCommandListener.instance, s);
MinecraftServer.this.server.dispatchServerCommand(MinecraftServer.this.remoteConsole, servercommand); // CraftBukkit
- return RemoteControlCommandListener.instance.e();
+ // this.n.a(RemoteControlCommandListener.instance, s);
+ return RemoteControlCommandListener.instance.f();
}};
processQueue.add(waitable);
try {
@@ -831,12 +879,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
public void h(String s) {
- this.getLogger().severe(s);
+ h.error(s);
}
public void i(String s) {
if (this.isDebugging()) {
- this.getLogger().info(s);
+ h.info(s);
}
}
@@ -865,7 +913,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
if (s.startsWith("/")) {
s = s.substring(1);
boolean flag = !s.contains(" ");
- List list = this.p.b(icommandlistener, s);
+ List list = this.n.b(icommandlistener, s);
if (list != null) {
Iterator iterator = list.iterator();
@@ -885,7 +933,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
} else {
String[] astring = s.split(" ", -1);
String s2 = astring[astring.length - 1];
- String[] astring1 = this.s.d();
+ String[] astring1 = this.t.d();
int i = astring1.length;
for (int j = 0; j < i; ++j) {
@@ -904,15 +952,15 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
public static MinecraftServer getServer() {
- return l;
+ return i;
}
public String getName() {
return "Server";
}
- public void sendMessage(ChatMessage chatmessage) {
- this.getLogger().info(chatmessage.toString());
+ public void sendMessage(IChatBaseComponent ichatbasecomponent) {
+ h.info(ichatbasecomponent.c());
}
public boolean a(int i, String s) {
@@ -920,14 +968,14 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
public ICommandHandler getCommandHandler() {
- return this.q;
+ return this.n;
}
- public KeyPair H() {
- return this.J;
+ public KeyPair I() {
+ return this.F;
}
- public int I() {
+ public int J() {
return this.s;
}
@@ -935,31 +983,31 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.s = i;
}
- public String J() {
- return this.K;
+ public String K() {
+ return this.G;
}
public void j(String s) {
- this.K = s;
+ this.G = s;
}
- public boolean K() {
- return this.K != null;
+ public boolean L() {
+ return this.G != null;
}
- public String L() {
- return this.L;
+ public String M() {
+ return this.H;
}
public void k(String s) {
- this.L = s;
+ this.H = s;
}
public void a(KeyPair keypair) {
- this.J = keypair;
+ this.F = keypair;
}
- public void c(int i) {
+ public void a(EnumDifficulty enumdifficulty) {
// CraftBukkit start
for (int j = 0; j < this.worlds.size(); ++j) {
WorldServer worldserver = this.worlds.get(j);
@@ -967,13 +1015,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
if (worldserver != null) {
if (worldserver.getWorldData().isHardcore()) {
- worldserver.difficulty = 3;
+ worldserver.difficulty = EnumDifficulty.HARD;
worldserver.setSpawnFlags(true, true);
- } else if (this.K()) {
- worldserver.difficulty = i;
- worldserver.setSpawnFlags(worldserver.difficulty > 0, true);
+ } else if (this.L()) {
+ worldserver.difficulty = enumdifficulty;
+ worldserver.setSpawnFlags(worldserver.difficulty != EnumDifficulty.PEACEFUL, true);
} else {
- worldserver.difficulty = i;
+ worldserver.difficulty = enumdifficulty;
worldserver.setSpawnFlags(this.getSpawnMonsters(), this.spawnAnimals);
}
}
@@ -984,7 +1032,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
return true;
}
- public boolean O() {
+ public boolean P() {
return this.demoMode;
}
@@ -993,18 +1041,18 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
public void c(boolean flag) {
- this.O = flag;
+ this.K = flag;
}
public Convertable getConvertable() {
return this.convertable;
}
- public void R() {
- this.P = true;
+ public void S() {
+ this.L = true;
this.getConvertable().d();
- // CraftBukkit start - This needs review, what does it do? (it's new)
+ // CraftBukkit start
for (int i = 0; i < this.worlds.size(); ++i) {
WorldServer worldserver = this.worlds.get(i);
// CraftBukkit end
@@ -1018,54 +1066,50 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.safeShutdown();
}
- public String getTexturePack() {
- return this.Q;
+ public String getResourcePack() {
+ return this.M;
}
public void setTexturePack(String s) {
- this.Q = s;
+ this.M = s;
}
public void a(MojangStatisticsGenerator mojangstatisticsgenerator) {
mojangstatisticsgenerator.a("whitelist_enabled", Boolean.valueOf(false));
mojangstatisticsgenerator.a("whitelist_count", Integer.valueOf(0));
- mojangstatisticsgenerator.a("players_current", Integer.valueOf(this.A()));
- mojangstatisticsgenerator.a("players_max", Integer.valueOf(this.B()));
+ mojangstatisticsgenerator.a("players_current", Integer.valueOf(this.B()));
+ mojangstatisticsgenerator.a("players_max", Integer.valueOf(this.C()));
mojangstatisticsgenerator.a("players_seen", Integer.valueOf(this.t.getSeenPlayers().length));
mojangstatisticsgenerator.a("uses_auth", Boolean.valueOf(this.onlineMode));
mojangstatisticsgenerator.a("gui_state", this.ai() ? "enabled" : "disabled");
- mojangstatisticsgenerator.a("run_time", Long.valueOf((aq() - mojangstatisticsgenerator.g()) / 60L * 1000L));
- mojangstatisticsgenerator.a("avg_tick_ms", Integer.valueOf((int) (MathHelper.a(this.j) * 1.0E-6D)));
- mojangstatisticsgenerator.a("avg_sent_packet_count", Integer.valueOf((int) MathHelper.a(this.f)));
- mojangstatisticsgenerator.a("avg_sent_packet_size", Integer.valueOf((int) MathHelper.a(this.g)));
- mojangstatisticsgenerator.a("avg_rec_packet_count", Integer.valueOf((int) MathHelper.a(this.h)));
- mojangstatisticsgenerator.a("avg_rec_packet_size", Integer.valueOf((int) MathHelper.a(this.i)));
+ mojangstatisticsgenerator.a("run_time", Long.valueOf((ap() - mojangstatisticsgenerator.g()) / 60L * 1000L));
+ mojangstatisticsgenerator.a("avg_tick_ms", Integer.valueOf((int) (MathHelper.a(this.f) * 1.0E-6D)));
int i = 0;
// CraftBukkit start
for (int j = 0; j < this.worlds.size(); ++j) {
- // if (this.worldServer[j] != null) {
- WorldServer worldserver = this.worlds.get(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.dimension));
mojangstatisticsgenerator.a("world[" + i + "][mode]", worlddata.getGameType());
- mojangstatisticsgenerator.a("world[" + i + "][difficulty]", Integer.valueOf(worldserver.difficulty));
+ mojangstatisticsgenerator.a("world[" + i + "][difficulty]", worldserver.difficulty);
mojangstatisticsgenerator.a("world[" + i + "][hardcore]", Boolean.valueOf(worlddata.isHardcore()));
mojangstatisticsgenerator.a("world[" + i + "][generator_name]", worlddata.getType().name());
mojangstatisticsgenerator.a("world[" + i + "][generator_version]", Integer.valueOf(worlddata.getType().getVersion()));
mojangstatisticsgenerator.a("world[" + i + "][height]", Integer.valueOf(this.D));
- mojangstatisticsgenerator.a("world[" + i + "][chunks_loaded]", Integer.valueOf(worldserver.L().getLoadedChunks()));
+ mojangstatisticsgenerator.a("world[" + i + "][chunks_loaded]", Integer.valueOf(worldserver.K().getLoadedChunks()));
++i;
- // } // CraftBukkit
+ }
}
mojangstatisticsgenerator.a("worlds", Integer.valueOf(i));
}
public void b(MojangStatisticsGenerator mojangstatisticsgenerator) {
- mojangstatisticsgenerator.a("singleplayer", Boolean.valueOf(this.K()));
+ mojangstatisticsgenerator.a("singleplayer", Boolean.valueOf(this.L()));
mojangstatisticsgenerator.a("server_brand", this.getServerModName());
mojangstatisticsgenerator.a("gui_supported", GraphicsEnvironment.isHeadless() ? "headless" : "supported");
mojangstatisticsgenerator.a("dedicated", Boolean.valueOf(this.V()));
@@ -1075,10 +1119,6 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
return true;
}
- public int U() {
- return 16;
- }
-
public abstract boolean V();
public boolean getOnlineMode() {
@@ -1135,7 +1175,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
return this.D;
}
- public void d(int i) {
+ public void c(int i) {
this.D = i;
}
@@ -1159,7 +1199,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
}
- public abstract ServerConnection ag();
+ public ServerConnection ag() {
+ return this.o;
+ }
public boolean ai() {
return false;
@@ -1172,14 +1214,14 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
public void ak() {
- this.U = true;
+ this.Q = true;
}
- public ChunkCoordinates b() {
+ public ChunkCoordinates getChunkCoordinates() {
return new ChunkCoordinates(0, 0, 0);
}
- public World f_() {
+ public World getWorld() {
return this.worlds.get(0); // CraftBukkit
}
@@ -1191,32 +1233,54 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
return false;
}
- public abstract IConsoleLogManager getLogger();
-
public void setForceGamemode(boolean flag) {
- this.V = flag;
+ this.R = flag;
}
public boolean getForceGamemode() {
- return this.V;
+ return this.R;
}
- public Proxy ap() {
+ public Proxy ao() {
return this.c;
}
- public static long aq() {
+ public static long ap() {
return System.currentTimeMillis();
}
- public int ar() {
+ public int aq() {
return this.E;
}
- public void e(int i) {
+ public void d(int i) {
this.E = i;
}
+ public IChatBaseComponent getScoreboardDisplayName() {
+ return new ChatComponentText(this.getName());
+ }
+
+ public boolean ar() {
+ return true;
+ }
+
+ public MinecraftSessionService as() {
+ return this.S;
+ }
+
+ public ServerPing at() {
+ return this.p;
+ }
+
+ public void au() {
+ this.T = 0L;
+ }
+
+ public static Logger av() {
+ return h;
+ }
+
public static PlayerList a(MinecraftServer minecraftserver) {
return minecraftserver.t;
}