forked from xjboss/KCauldronX
Initial commit (Forge 1291).
This commit is contained in:
@ -0,0 +1,249 @@
|
||||
--- ../src-base/minecraft/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ ../src-work/minecraft/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -34,9 +34,19 @@
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.WorldType;
|
||||
+import net.minecraft.world.chunk.storage.AnvilSaveConverter;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.io.PrintStream;
|
||||
+import org.apache.logging.log4j.Level;
|
||||
+
|
||||
+import org.bukkit.craftbukkit.LoggerOutputStream;
|
||||
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
||||
+import org.bukkit.event.server.ServerCommandEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
@SideOnly(Side.SERVER)
|
||||
public class DedicatedServer extends MinecraftServer implements IServer
|
||||
{
|
||||
@@ -44,7 +54,7 @@
|
||||
public final List pendingCommandList = Collections.synchronizedList(new ArrayList());
|
||||
private RConThreadQuery theRConThreadQuery;
|
||||
private RConThreadMain theRConThreadMain;
|
||||
- private PropertyManager settings;
|
||||
+ public PropertyManager settings; // CraftBukkit - private -> public
|
||||
private ServerEula field_154332_n;
|
||||
private boolean canSpawnStructures;
|
||||
private WorldSettings.GameType gameType;
|
||||
@@ -52,9 +62,12 @@
|
||||
public static boolean allowPlayerLogins = false;
|
||||
private static final String __OBFID = "CL_00001784";
|
||||
|
||||
- public DedicatedServer(File p_i1508_1_)
|
||||
+ // CraftBukkit start - Signature changed
|
||||
+ public DedicatedServer(joptsimple.OptionSet options)
|
||||
{
|
||||
- super(p_i1508_1_, Proxy.NO_PROXY);
|
||||
+ super(options, Proxy.NO_PROXY);
|
||||
+ // super(p_i1508_1_, Proxy.NO_PROXY);
|
||||
+ // CraftBukkit end
|
||||
Thread thread = new Thread("Server Infinisleeper")
|
||||
{
|
||||
private static final String __OBFID = "CL_00001787";
|
||||
@@ -82,31 +95,77 @@
|
||||
};
|
||||
}
|
||||
|
||||
- protected boolean startServer() throws IOException
|
||||
+ protected boolean startServer() throws java.net.UnknownHostException // CraftBukkit - throws UnknownHostException
|
||||
{
|
||||
Thread thread = new Thread("Server console handler")
|
||||
{
|
||||
private static final String __OBFID = "CL_00001786";
|
||||
+ final DedicatedServer server = DedicatedServer.this;
|
||||
public void run()
|
||||
{
|
||||
- BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in));
|
||||
- String s4;
|
||||
+ // CraftBukkit start
|
||||
+ if (!useConsole)
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+ jline.console.ConsoleReader bufferedreader = this.server.reader; // CraftBukkit
|
||||
+ String s;
|
||||
+
|
||||
try
|
||||
{
|
||||
- while (!DedicatedServer.this.isServerStopped() && DedicatedServer.this.isServerRunning() && (s4 = bufferedreader.readLine()) != null)
|
||||
+ // CraftBukkit start - JLine disabling compatibility
|
||||
+ while (!this.server.isServerStopped() && this.server.isServerRunning())
|
||||
{
|
||||
- DedicatedServer.this.addPendingCommand(s4, DedicatedServer.this);
|
||||
+ if (useJline)
|
||||
+ {
|
||||
+ s = bufferedreader.readLine(">", null);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ s = bufferedreader.readLine();
|
||||
+ }
|
||||
+ if (s != null)
|
||||
+ {
|
||||
+ this.server.addPendingCommand(s, this.server);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
+
|
||||
}
|
||||
- catch (IOException ioexception1)
|
||||
+ catch (IOException ioexception)
|
||||
{
|
||||
- DedicatedServer.field_155771_h.error("Exception handling console input", ioexception1);
|
||||
+ DedicatedServer.field_155771_h.error("Exception handling console input", ioexception);
|
||||
}
|
||||
}
|
||||
};
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
+ // CraftBukkit start - TODO: handle command-line logging arguments
|
||||
+ java.util.logging.Logger global = java.util.logging.Logger.getLogger("");
|
||||
+ global.setUseParentHandlers(false);
|
||||
+
|
||||
+ for (java.util.logging.Handler handler : global.getHandlers())
|
||||
+ {
|
||||
+ global.removeHandler(handler);
|
||||
+ }
|
||||
+
|
||||
+ global.addHandler(new org.bukkit.craftbukkit.util.ForwardLogHandler());
|
||||
+ final org.apache.logging.log4j.core.Logger logger = ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger());
|
||||
+
|
||||
+ for (org.apache.logging.log4j.core.Appender appender : logger.getAppenders().values())
|
||||
+ {
|
||||
+ if (appender instanceof org.apache.logging.log4j.core.appender.ConsoleAppender)
|
||||
+ {
|
||||
+ logger.removeAppender(appender);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ new Thread(new org.bukkit.craftbukkit.util.TerminalConsoleWriterThread(System.out, this.reader)).start();
|
||||
+ System.setOut(new PrintStream(new LoggerOutputStream(logger, Level.INFO), true));
|
||||
+ System.setErr(new PrintStream(new LoggerOutputStream(logger, Level.WARN), true));
|
||||
+ // CraftBukkit end
|
||||
field_155771_h.info("Starting minecraft server version 1.7.10");
|
||||
|
||||
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L)
|
||||
@@ -117,7 +176,7 @@
|
||||
FMLCommonHandler.instance().onServerStart(this);
|
||||
|
||||
field_155771_h.info("Loading properties");
|
||||
- this.settings = new PropertyManager(new File("server.properties"));
|
||||
+ this.settings = new PropertyManager(this.options); // CraftBukkit - CLI argument support
|
||||
this.field_154332_n = new ServerEula(new File("eula.txt"));
|
||||
|
||||
if (!this.field_154332_n.func_154346_a())
|
||||
@@ -172,6 +231,16 @@
|
||||
this.setServerPort(this.settings.getIntProperty("server-port", 25565));
|
||||
}
|
||||
|
||||
+ // Spigot start
|
||||
+ this.func_152361_a((ServerConfigurationManager) (new DedicatedPlayerList(this)));
|
||||
+ org.spigotmc.SpigotConfig.init();
|
||||
+ org.spigotmc.SpigotConfig.registerCommands();
|
||||
+ // Spigot end
|
||||
+ // Cauldron start
|
||||
+ this.cauldronConfig.registerCommands();
|
||||
+ this.tileEntityConfig.registerCommands();
|
||||
+ // Cauldron end
|
||||
+
|
||||
field_155771_h.info("Generating keypair");
|
||||
this.setKeyPair(CryptManager.createNewKeyPair());
|
||||
field_155771_h.info("Starting Minecraft server on " + (this.getServerHostname().length() == 0 ? "*" : this.getServerHostname()) + ":" + this.getServerPort());
|
||||
@@ -180,7 +249,7 @@
|
||||
{
|
||||
this.func_147137_ag().addLanEndpoint(inetaddress, this.getServerPort());
|
||||
}
|
||||
- catch (IOException ioexception)
|
||||
+ catch (Throwable ioexception) // CraftBukkit - IOException -> Throwable
|
||||
{
|
||||
field_155771_h.warn("**** FAILED TO BIND TO PORT!");
|
||||
field_155771_h.warn("The exception was: {}", new Object[] {ioexception.toString()});
|
||||
@@ -196,10 +265,17 @@
|
||||
field_155771_h.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
|
||||
}
|
||||
|
||||
- if (this.func_152368_aE())
|
||||
+ try
|
||||
{
|
||||
- this.func_152358_ax().func_152658_c();
|
||||
+ if (this.func_152368_aE())
|
||||
+ {
|
||||
+ this.func_152358_ax().func_152658_c();
|
||||
+ }
|
||||
}
|
||||
+ catch (IOException e)
|
||||
+ {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
|
||||
if (!PreYggdrasilConverter.func_152714_a(this.settings))
|
||||
{
|
||||
@@ -208,7 +284,8 @@
|
||||
else
|
||||
{
|
||||
FMLCommonHandler.instance().onServerStarted();
|
||||
- this.func_152361_a(new DedicatedPlayerList(this));
|
||||
+ // this.func_152361_a(new DedicatedPlayerList(this)); // CraftBukkit - moved up
|
||||
+ this.anvilConverterForAnvilFile = new AnvilSaveConverter(server.getWorldContainer()); // CraftBukkit - moved from MinecraftServer constructor
|
||||
long j = System.nanoTime();
|
||||
|
||||
if (this.getFolderName() == null)
|
||||
@@ -274,11 +351,30 @@
|
||||
this.theRConThreadMain.startThread();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (this.server.getBukkitSpawnRadius() > -1)
|
||||
+ {
|
||||
+ field_155771_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.settings.serverProperties.remove("spawn-protection");
|
||||
+ this.settings.getIntProperty("spawn-protection", this.server.getBukkitSpawnRadius());
|
||||
+ this.server.removeBukkitSpawnRadius();
|
||||
+ this.settings.saveProperties();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
return FMLCommonHandler.instance().handleServerStarting(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public PropertyManager getPropertyManager()
|
||||
+ {
|
||||
+ return this.settings;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public boolean canStructuresSpawn()
|
||||
{
|
||||
return this.canSpawnStructures;
|
||||
@@ -364,11 +460,19 @@
|
||||
|
||||
public void executePendingCommands()
|
||||
{
|
||||
+ SpigotTimings.serverCommandTimer.startTiming(); // Spigot
|
||||
while (!this.pendingCommandList.isEmpty())
|
||||
{
|
||||
- ServerCommand servercommand = (ServerCommand)this.pendingCommandList.remove(0);
|
||||
- this.getCommandManager().executeCommand(servercommand.sender, servercommand.command);
|
||||
+ ServerCommand servercommand = (ServerCommand) this.pendingCommandList.remove(0);
|
||||
+ // CraftBukkit start - ServerCommand for preprocessing
|
||||
+ ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command);
|
||||
+ this.server.getPluginManager().callEvent(event);
|
||||
+ servercommand = new ServerCommand(event.getCommand(), servercommand.sender);
|
||||
+ // this.getCommandManager().executeCommand(servercommand.sender, servercommand.command); // Called in dispatchServerCommand
|
||||
+ this.server.dispatchServerCommand(this.console, servercommand);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
+ SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
|
||||
}
|
||||
|
||||
public boolean isDedicatedServer()
|
@ -0,0 +1,98 @@
|
||||
--- ../src-base/minecraft/net/minecraft/server/dedicated/PropertyManager.java
|
||||
+++ ../src-work/minecraft/net/minecraft/server/dedicated/PropertyManager.java
|
||||
@@ -10,11 +10,13 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+import joptsimple.OptionSet; // CraftBukkit
|
||||
+
|
||||
@SideOnly(Side.SERVER)
|
||||
public class PropertyManager
|
||||
{
|
||||
private static final Logger field_164440_a = LogManager.getLogger();
|
||||
- private final Properties serverProperties = new Properties();
|
||||
+ public final Properties serverProperties = new Properties(); // CraftBukkit - private -> public
|
||||
private final File serverPropertiesFile;
|
||||
private static final String __OBFID = "CL_00001782";
|
||||
|
||||
@@ -58,6 +60,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private OptionSet options = null;
|
||||
+
|
||||
+ public PropertyManager(final OptionSet options)
|
||||
+ {
|
||||
+ this((File) options.valueOf("config"));
|
||||
+ this.options = options;
|
||||
+ }
|
||||
+
|
||||
+ private <T> T getOverride(String name, T value)
|
||||
+ {
|
||||
+ if ((this.options != null) && (this.options.has(name)))
|
||||
+ {
|
||||
+ return (T) this.options.valueOf(name);
|
||||
+ }
|
||||
+
|
||||
+ return value;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void generateNewProperties()
|
||||
{
|
||||
field_164440_a.info("Generating new properties file");
|
||||
@@ -70,6 +92,13 @@
|
||||
|
||||
try
|
||||
{
|
||||
+ // CraftBukkit start - Don't attempt writing to file if it's read only
|
||||
+ if (this.serverPropertiesFile.exists() && !this.serverPropertiesFile.canWrite())
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
fileoutputstream = new FileOutputStream(this.serverPropertiesFile);
|
||||
this.serverProperties.store(fileoutputstream, "Minecraft server properties");
|
||||
}
|
||||
@@ -108,20 +137,20 @@
|
||||
this.saveProperties();
|
||||
}
|
||||
|
||||
- return this.serverProperties.getProperty(p_73671_1_, p_73671_2_);
|
||||
+ return this.getOverride(p_73671_1_, this.serverProperties.getProperty(p_73671_1_, p_73671_2_)); // CraftBukkit
|
||||
}
|
||||
|
||||
public int getIntProperty(String p_73669_1_, int p_73669_2_)
|
||||
{
|
||||
try
|
||||
{
|
||||
- return Integer.parseInt(this.getStringProperty(p_73669_1_, "" + p_73669_2_));
|
||||
+ return this.getOverride(p_73669_1_, Integer.parseInt(this.getStringProperty(p_73669_1_, "" + p_73669_2_))); // CraftBukkit
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
this.serverProperties.setProperty(p_73669_1_, "" + p_73669_2_);
|
||||
this.saveProperties();
|
||||
- return p_73669_2_;
|
||||
+ return this.getOverride(p_73669_1_, p_73669_2_); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,13 +158,13 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
- return Boolean.parseBoolean(this.getStringProperty(p_73670_1_, "" + p_73670_2_));
|
||||
+ return this.getOverride(p_73670_1_, Boolean.parseBoolean(this.getStringProperty(p_73670_1_, "" + p_73670_2_))); // CraftBukkit
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
this.serverProperties.setProperty(p_73670_1_, "" + p_73670_2_);
|
||||
this.saveProperties();
|
||||
- return p_73670_2_;
|
||||
+ return this.getOverride(p_73670_1_, p_73670_2_); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user