From 2726696652179a5ead7dc07dd39edf7dfda687f7 Mon Sep 17 00:00:00 2001 From: mbax Date: Mon, 4 Nov 2013 07:07:38 -0600 Subject: Update CraftBukkit to Minecraft 1.7.2 --- .../java/net/minecraft/server/DedicatedServer.java | 182 +++++++++++---------- 1 file changed, 99 insertions(+), 83 deletions(-) (limited to 'src/main/java/net/minecraft/server/DedicatedServer.java') diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java index f871b739..03585b7a 100644 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/DedicatedServer.java @@ -3,15 +3,19 @@ package net.minecraft.server; import java.io.File; import java.io.IOException; import java.net.InetAddress; +import java.net.Proxy; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Random; import java.util.concurrent.Callable; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + // CraftBukkit start import java.io.PrintStream; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import org.bukkit.craftbukkit.LoggerOutputStream; import org.bukkit.event.server.ServerCommandEvent; @@ -19,43 +23,51 @@ import org.bukkit.event.server.ServerCommandEvent; public class DedicatedServer extends MinecraftServer implements IMinecraftServer { - private final List l = Collections.synchronizedList(new ArrayList()); - private final IConsoleLogManager m; - private RemoteStatusListener n; - private RemoteControlListener o; + private static final Logger h = LogManager.getLogger(); + private final List i = Collections.synchronizedList(new ArrayList()); + private RemoteStatusListener j; + private RemoteControlListener k; public PropertyManager propertyManager; // CraftBukkit - private -> public private boolean generateStructures; - private EnumGamemode r; - private ServerConnection s; - private boolean t; + private EnumGamemode n; + private boolean o; // CraftBukkit start - Signature changed public DedicatedServer(joptsimple.OptionSet options) { - super(options); + super(options, Proxy.NO_PROXY); + // super(file1, Proxy.NO_PROXY); // CraftBukkit end - this.m = new ConsoleLogManager("Minecraft-Server", (String) null, (String) null); // CraftBukkit - null last argument - new ThreadSleepForever(this); + new ThreadSleepForever(this, "Server Infinisleeper"); } protected boolean init() throws java.net.UnknownHostException { // CraftBukkit - throws UnknownHostException - ThreadCommandReader threadcommandreader = new ThreadCommandReader(this); + ThreadCommandReader threadcommandreader = new ThreadCommandReader(this, "Server console handler"); threadcommandreader.setDaemon(true); threadcommandreader.start(); - // CraftBukkit start - System.setOut(new PrintStream(new LoggerOutputStream(this.getLogger().getLogger(), Level.INFO), true)); - System.setErr(new PrintStream(new LoggerOutputStream(this.getLogger().getLogger(), Level.SEVERE), true)); + // CraftBukkit start - TODO: See if this needs fixing + final org.apache.logging.log4j.core.Logger realLogger = ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()); + for (org.apache.logging.log4j.core.Appender appender : realLogger.getAppenders().values()) { + if (appender instanceof org.apache.logging.log4j.core.appender.ConsoleAppender) { + realLogger.removeAppender(appender); + } + } + + new Thread(new org.bukkit.craftbukkit.util.TerminalConsoleWriterThread(System.out, this.reader)).start(); + + System.setOut(new PrintStream(new LoggerOutputStream(realLogger, Level.INFO), true)); + System.setErr(new PrintStream(new LoggerOutputStream(realLogger, Level.WARN), true)); // CraftBukkit end - this.getLogger().info("Starting minecraft server version 1.6.4"); + h.info("Starting minecraft server version 1.7.2"); if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { - this.getLogger().warning("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); + h.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); } - this.getLogger().info("Loading properties"); - this.propertyManager = new PropertyManager(this.options, this.getLogger()); // CraftBukkit - CLI argument support - if (this.K()) { + h.info("Loading properties"); + this.propertyManager = new PropertyManager(this.options); // CraftBukkit - CLI argument support + if (this.L()) { this.c("127.0.0.1"); } else { this.setOnlineMode(this.propertyManager.getBoolean("online-mode", true)); @@ -66,10 +78,10 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer this.setSpawnNPCs(this.propertyManager.getBoolean("spawn-npcs", true)); this.setPvP(this.propertyManager.getBoolean("pvp", true)); this.setAllowFlight(this.propertyManager.getBoolean("allow-flight", false)); - this.setTexturePack(this.propertyManager.getString("texture-pack", "")); + this.setTexturePack(this.propertyManager.getString("resource-pack", "")); this.setMotd(this.propertyManager.getString("motd", "A Minecraft Server")); this.setForceGamemode(this.propertyManager.getBoolean("force-gamemode", false)); - this.e(this.propertyManager.getInt("player-idle-timeout", 0)); + this.d(this.propertyManager.getInt("player-idle-timeout", 0)); if (this.propertyManager.getInt("difficulty", 1) < 0) { this.propertyManager.a("difficulty", Integer.valueOf(0)); } else if (this.propertyManager.getInt("difficulty", 1) > 3) { @@ -79,45 +91,45 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer this.generateStructures = this.propertyManager.getBoolean("generate-structures", true); int i = this.propertyManager.getInt("gamemode", EnumGamemode.SURVIVAL.a()); - this.r = WorldSettings.a(i); - this.getLogger().info("Default game type: " + this.r); + this.n = WorldSettings.a(i); + h.info("Default game type: " + this.n); InetAddress inetaddress = null; if (this.getServerIp().length() > 0) { inetaddress = InetAddress.getByName(this.getServerIp()); } - if (this.I() < 0) { + if (this.J() < 0) { this.setPort(this.propertyManager.getInt("server-port", 25565)); } - this.getLogger().info("Generating keypair"); + h.info("Generating keypair"); this.a(MinecraftEncryption.b()); - this.getLogger().info("Starting Minecraft server on " + (this.getServerIp().length() == 0 ? "*" : this.getServerIp()) + ":" + this.I()); + h.info("Starting Minecraft server on " + (this.getServerIp().length() == 0 ? "*" : this.getServerIp()) + ":" + this.J()); try { - this.s = new DedicatedServerConnection(this, inetaddress, this.I()); + this.ag().a(inetaddress, this.J()); } catch (Throwable ioexception) { // CraftBukkit - IOException -> Throwable - this.getLogger().warning("**** FAILED TO BIND TO PORT!"); - this.getLogger().warning("The exception was: {0}", new Object[] { ioexception.toString()}); - this.getLogger().warning("Perhaps a server is already running on that port?"); + h.warn("**** FAILED TO BIND TO PORT!"); + h.warn("The exception was: {}", new Object[] { ioexception.toString()}); + h.warn("Perhaps a server is already running on that port?"); return false; } this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit if (!this.getOnlineMode()) { - this.getLogger().warning("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); - this.getLogger().warning("The server will make no attempt to authenticate usernames. Beware."); - this.getLogger().warning("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); - this.getLogger().warning("To change this, set \"online-mode\" to \"true\" in the server.properties file."); + h.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); + h.warn("The server will make no attempt to authenticate usernames. Beware."); + h.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); + h.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); } // this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit - moved up this.convertable = new WorldLoaderServer(server.getWorldContainer()); // CraftBukkit - moved from MinecraftServer constructor long j = System.nanoTime(); - if (this.L() == null) { + if (this.M() == null) { this.k(this.propertyManager.getString("level-name", "world")); } @@ -144,32 +156,36 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer worldtype = WorldType.NORMAL; } - this.d(this.propertyManager.getInt("max-build-height", 256)); - this.d((this.getMaxBuildHeight() + 8) / 16 * 16); - this.d(MathHelper.a(this.getMaxBuildHeight(), 64, 256)); + this.ar(); + this.getEnableCommandBlock(); + this.l(); + this.getSnooperEnabled(); + this.c(this.propertyManager.getInt("max-build-height", 256)); + this.c((this.getMaxBuildHeight() + 8) / 16 * 16); + this.c(MathHelper.a(this.getMaxBuildHeight(), 64, 256)); this.propertyManager.a("max-build-height", Integer.valueOf(this.getMaxBuildHeight())); - this.getLogger().info("Preparing level \"" + this.L() + "\""); - this.a(this.L(), this.L(), k, worldtype, s2); + h.info("Preparing level \"" + this.M() + "\""); + this.a(this.M(), this.M(), k, worldtype, s2); long i1 = System.nanoTime() - j; String s3 = String.format("%.3fs", new Object[] { Double.valueOf((double) i1 / 1.0E9D)}); - this.getLogger().info("Done (" + s3 + ")! For help, type \"help\" or \"?\""); + h.info("Done (" + s3 + ")! For help, type \"help\" or \"?\""); if (this.propertyManager.getBoolean("enable-query", false)) { - this.getLogger().info("Starting GS4 status listener"); - this.n = new RemoteStatusListener(this); - this.n.a(); + h.info("Starting GS4 status listener"); + this.j = new RemoteStatusListener(this); + this.j.a(); } if (this.propertyManager.getBoolean("enable-rcon", false)) { - this.getLogger().info("Starting remote control listener"); - this.o = new RemoteControlListener(this); - this.o.a(); + h.info("Starting remote control listener"); + this.k = new RemoteControlListener(this); + this.k.a(); this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(); // CraftBukkit } // CraftBukkit start if (this.server.getBukkitSpawnRadius() > -1) { - this.getLogger().info("'settings.spawn-radius' in bukkit.yml has been moved to 'spawn-protection' in server.properties. I will move your config for you."); + h.info("'settings.spawn-radius' in bukkit.yml has been moved to 'spawn-protection' in server.properties. I will move your config for you."); this.propertyManager.properties.remove("spawn-protection"); this.propertyManager.getInt("spawn-protection", this.server.getBukkitSpawnRadius()); this.server.removeBukkitSpawnRadius(); @@ -189,11 +205,11 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer } public EnumGamemode getGamemode() { - return this.r; + return this.n; } - public int getDifficulty() { - return Math.max(0, Math.min(3, this.propertyManager.getInt("difficulty", 1))); // CraftBukkit - clamp values + public EnumDifficulty getDifficulty() { + return EnumDifficulty.a(this.propertyManager.getInt("difficulty", 1)); } public boolean isHardcore() { @@ -202,12 +218,12 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer protected void a(CrashReport crashreport) { while (this.isRunning()) { - this.as(); + this.aw(); try { Thread.sleep(10L); } catch (InterruptedException interruptedexception) { - interruptedexception.printStackTrace(); + ; } } } @@ -219,13 +235,13 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer return crashreport; } - protected void r() { + protected void s() { System.exit(0); } - public void t() { // CraftBukkit - protected -> public - super.t(); - this.as(); + public void u() { // CraftBukkit - protected -> public + super.u(); + this.aw(); } public boolean getAllowNether() { @@ -237,8 +253,8 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer } public void a(MojangStatisticsGenerator mojangstatisticsgenerator) { - mojangstatisticsgenerator.a("whitelist_enabled", Boolean.valueOf(this.at().getHasWhitelist())); - mojangstatisticsgenerator.a("whitelist_count", Integer.valueOf(this.at().getWhitelisted().size())); + mojangstatisticsgenerator.a("whitelist_enabled", Boolean.valueOf(this.ax().getHasWhitelist())); + mojangstatisticsgenerator.a("whitelist_count", Integer.valueOf(this.ax().getWhitelisted().size())); super.a(mojangstatisticsgenerator); } @@ -247,12 +263,12 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer } public void issueCommand(String s, ICommandListener icommandlistener) { - this.l.add(new ServerCommand(s, icommandlistener)); + this.i.add(new ServerCommand(s, icommandlistener)); } - public void as() { - while (!this.l.isEmpty()) { - ServerCommand servercommand = (ServerCommand) this.l.remove(0); + public void aw() { + while (!this.i.isEmpty()) { + ServerCommand servercommand = (ServerCommand) this.i.remove(0); // CraftBukkit start - ServerCommand for preprocessing ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command); @@ -269,14 +285,10 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer return true; } - public DedicatedPlayerList at() { + public DedicatedPlayerList ax() { return (DedicatedPlayerList) super.getPlayerList(); } - public ServerConnection ag() { - return this.s; - } - public int a(String s, int i) { return this.propertyManager.getInt(s, i); } @@ -297,19 +309,19 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer this.propertyManager.savePropertiesFile(); } - public String b_() { + public String b() { File file1 = this.propertyManager.c(); return file1 != null ? file1.getAbsolutePath() : "No settings file"; } - public void au() { + public void ay() { ServerGUI.a(this); - this.t = true; + this.o = true; } public boolean ai() { - return this.t; + return this.o; } public String a(EnumGamemode enumgamemode, boolean flag) { @@ -327,9 +339,9 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { if (world.worldProvider.dimension != 0) { return false; - } else if (this.at().getOPs().isEmpty()) { + } else if (this.ax().getOPs().isEmpty()) { return false; - } else if (this.at().isOp(entityhuman.getName())) { + } else if (this.ax().isOp(entityhuman.getName())) { return false; } else if (this.getSpawnProtection() <= 0) { return false; @@ -343,21 +355,25 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer } } - public IConsoleLogManager getLogger() { - return this.m; - } - - public int k() { + public int l() { return this.propertyManager.getInt("op-permission-level", 4); } - public void e(int i) { - super.e(i); + public void d(int i) { + super.d(i); this.propertyManager.a("player-idle-timeout", Integer.valueOf(i)); this.a(); } + public boolean ar() { + return this.propertyManager.getBoolean("announce-player-achievements", true); + } + public PlayerList getPlayerList() { - return this.at(); + return this.ax(); + } + + static Logger az() { + return h; } } -- cgit v1.2.3