diff --git a/CraftBukkit-Patches/0023-Metrics.patch b/CraftBukkit-Patches/0023-Metrics.patch index 24556cd2ee..f5426214be 100644 --- a/CraftBukkit-Patches/0023-Metrics.patch +++ b/CraftBukkit-Patches/0023-Metrics.patch @@ -1,61 +1,9 @@ -From 2ba22ed3cb7fcfbf52fd7bade08af98b4152e9cb Mon Sep 17 00:00:00 2001 +From 6d588b92bf8282f25ed30e7660a338f160a500bc Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 23 Feb 2013 08:58:35 +1100 Subject: [PATCH] Metrics -diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java -index 2fc33f8..2532aa2 100644 ---- a/src/main/java/org/bukkit/craftbukkit/Spigot.java -+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java -@@ -1,8 +1,10 @@ - package org.bukkit.craftbukkit; - -+import java.io.IOException; - import java.net.InetAddress; - import java.util.ArrayList; - import java.util.List; -+import java.util.logging.Level; - import net.minecraft.server.AxisAlignedBB; - import net.minecraft.server.Chunk; - import net.minecraft.server.Entity; -@@ -29,8 +31,10 @@ import net.minecraft.server.MathHelper; - import net.minecraft.server.MinecraftServer; - import net.minecraft.server.PendingConnection; - import net.minecraft.server.World; -+import org.bukkit.Bukkit; - import org.bukkit.command.SimpleCommandMap; - import org.bukkit.configuration.file.YamlConfiguration; -+import org.spigotmc.Metrics; - - public class Spigot { - -@@ -39,6 +43,8 @@ public class Spigot { - static AxisAlignedBB animalBB = AxisAlignedBB.a(0, 0, 0, 0, 0, 0); - static AxisAlignedBB monsterBB = AxisAlignedBB.a(0, 0, 0, 0, 0, 0); - private static boolean filterIps; -+ public static boolean tabPing = false; -+ private static Metrics metrics; - - public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) { - commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps")); -@@ -62,6 +68,16 @@ public class Spigot { - server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!"); - } - -+ tabPing = configuration.getBoolean("settings.tab-ping", tabPing); -+ -+ if (metrics == null) { -+ try { -+ metrics = new Metrics(); -+ metrics.start(); -+ } catch (IOException ex) { -+ Bukkit.getServer().getLogger().log(Level.SEVERE, "Could not start metrics service", ex); -+ } -+ } - } - - /** diff --git a/src/main/java/org/spigotmc/Metrics.java b/src/main/java/org/spigotmc/Metrics.java new file mode 100644 index 0000000..f1690a2 @@ -708,6 +656,37 @@ index 0000000..f1690a2 + } +} \ No newline at end of file +diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java +index d647943..fde9250 100644 +--- a/src/main/java/org/spigotmc/SpigotConfig.java ++++ b/src/main/java/org/spigotmc/SpigotConfig.java +@@ -29,6 +29,7 @@ public class SpigotConfig + static YamlConfiguration config; + static int version; + /*========================================================================*/ ++ private static Metrics metrics; + + public static void init() + { +@@ -38,6 +39,18 @@ public class SpigotConfig + + version = getInt( "config-version", 1 ); + readConfig( SpigotConfig.class, null ); ++ ++ if ( metrics == null ) ++ { ++ try ++ { ++ metrics = new Metrics(); ++ metrics.start(); ++ } catch ( IOException ex ) ++ { ++ Bukkit.getServer().getLogger().log( Level.SEVERE, "Could not start metrics service", ex ); ++ } ++ } + } + + static void readConfig(Class clazz, Object instance) -- 1.8.1.2 diff --git a/CraftBukkit-Patches/0024-Watchdog-Thread.patch b/CraftBukkit-Patches/0024-Watchdog-Thread.patch index db79b92787..99df00388c 100644 --- a/CraftBukkit-Patches/0024-Watchdog-Thread.patch +++ b/CraftBukkit-Patches/0024-Watchdog-Thread.patch @@ -1,4 +1,4 @@ -From 38b16a25eb92ac69f11bc50e958ad1eaf48471b7 Mon Sep 17 00:00:00 2001 +From c6b9aaf6ba62817a2cff96441552a2df4b91601a Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 23 Feb 2013 12:33:20 +1100 Subject: [PATCH] Watchdog Thread. @@ -24,169 +24,149 @@ index db396b3..d197f06 100644 this.stop(); this.isStopped = true; } catch (Throwable throwable1) { -diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java -index 2532aa2..6a164ca 100644 ---- a/src/main/java/org/bukkit/craftbukkit/Spigot.java -+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java -@@ -1,5 +1,6 @@ - package org.bukkit.craftbukkit; - +diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java +new file mode 100644 +index 0000000..a5c4549 +--- /dev/null ++++ b/src/main/java/org/spigotmc/RestartCommand.java +@@ -0,0 +1,111 @@ ++package org.spigotmc; ++ +import java.io.File; - import java.io.IOException; - import java.net.InetAddress; - import java.util.ArrayList; -@@ -20,6 +21,7 @@ import net.minecraft.server.EntityFireworks; - import net.minecraft.server.EntityHuman; - import net.minecraft.server.EntityLiving; - import net.minecraft.server.EntityMonster; ++import java.util.List; +import net.minecraft.server.EntityPlayer; - import net.minecraft.server.EntityProjectile; - import net.minecraft.server.EntitySheep; - import net.minecraft.server.EntitySlime; -@@ -29,12 +31,15 @@ import net.minecraft.server.EntityWeather; - import net.minecraft.server.EntityWither; - import net.minecraft.server.MathHelper; - import net.minecraft.server.MinecraftServer; ++import net.minecraft.server.MinecraftServer; +import net.minecraft.server.Packet255KickDisconnect; - import net.minecraft.server.PendingConnection; - import net.minecraft.server.World; - import org.bukkit.Bukkit; - import org.bukkit.command.SimpleCommandMap; - import org.bukkit.configuration.file.YamlConfiguration; - import org.spigotmc.Metrics; -+import org.spigotmc.RestartCommand; -+import org.spigotmc.WatchdogThread; - - public class Spigot { - -@@ -48,6 +53,7 @@ public class Spigot { - - public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) { - commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps")); -+ commandMap.register("restart", new RestartCommand("restart")); - - server.whitelistMessage = configuration.getString("settings.whitelist-message", server.whitelistMessage); - server.stopMessage = configuration.getString("settings.stop-message", server.stopMessage); -@@ -56,6 +62,17 @@ public class Spigot { - server.spamGuardExclusions = configuration.getStringList("settings.spam-exclusions"); - filterIps = configuration.getBoolean("settings.filter-unsafe-ips", false); - -+ int configVersion = configuration.getInt("config-version"); -+ switch (configVersion) { -+ case 0: -+ configuration.set("settings.timeout-time", 30); -+ case 1: -+ configuration.set("settings.timeout-time", 60); ++import org.bukkit.command.Command; ++import org.bukkit.command.CommandSender; ++ ++public class RestartCommand extends Command ++{ ++ ++ public RestartCommand(String name) ++ { ++ super( name ); ++ this.description = "Restarts the server"; ++ this.usageMessage = "/restart"; ++ this.setPermission( "bukkit.command.restart" ); ++ } ++ ++ @Override ++ public boolean execute(CommandSender sender, String currentAlias, String[] args) ++ { ++ if ( testPermission( sender ) ) ++ { ++ restart(); + } -+ configuration.set("config-version", 2); ++ return true; ++ } + -+ WatchdogThread.doStart(configuration.getInt("settings.timeout-time", 60), configuration.getBoolean("settings.restart-on-crash", false)); -+ - server.orebfuscatorEnabled = configuration.getBoolean("orebfuscator.enable", false); - server.orebfuscatorEngineMode = configuration.getInt("orebfuscator.engine-mode", 1); - server.orebfuscatorDisabledWorlds = configuration.getStringList("orebfuscator.disabled-worlds"); -@@ -297,6 +314,66 @@ public class Spigot { - return isActive; - } - -+ public static void restart() { -+ try { -+ String startupScript = MinecraftServer.getServer().server.configuration.getString("settings.restart-script-location", ""); -+ final File file = new File(startupScript); -+ if (file.isFile()) { -+ System.out.println("Attempting to restart with " + startupScript); ++ public static void restart() ++ { ++ try ++ { ++ final File file = new File( SpigotConfig.restartScript ); ++ if ( file.isFile() ) ++ { ++ System.out.println( "Attempting to restart with " + SpigotConfig.restartScript ); + + // Kick all players -+ for (EntityPlayer p : (List< EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) { -+ p.playerConnection.networkManager.queue(new Packet255KickDisconnect("Server is restarting")); ++ for ( EntityPlayer p : (List< EntityPlayer>) MinecraftServer.getServer().getPlayerList().players ) ++ { ++ p.playerConnection.networkManager.queue( new Packet255KickDisconnect( "Server is restarting" ) ); + p.playerConnection.networkManager.d(); + } + // Give the socket a chance to send the packets -+ try { -+ Thread.sleep(100); -+ } catch (InterruptedException ex) { ++ try ++ { ++ Thread.sleep( 100 ); ++ } catch ( InterruptedException ex ) ++ { + } + // Close the socket so we can rebind with the new process + MinecraftServer.getServer().ae().a(); + + // Give time for it to kick in -+ try { -+ Thread.sleep(100); -+ } catch (InterruptedException ex) { ++ try ++ { ++ Thread.sleep( 100 ); ++ } catch ( InterruptedException ex ) ++ { + } + + // Actually shutdown -+ try { ++ try ++ { + MinecraftServer.getServer().stop(); -+ } catch (Throwable t) { ++ } catch ( Throwable t ) ++ { + } + + // This will be done AFTER the server has completely halted -+ Thread shutdownHook = new Thread() { ++ Thread shutdownHook = new Thread() ++ { + @Override -+ public void run() { -+ try { -+ String os = System.getProperty("os.name").toLowerCase(); -+ if (os.contains("win")) { -+ Runtime.getRuntime().exec("cmd /c start " + file.getPath()); -+ } else { -+ Runtime.getRuntime().exec(new String[]{"sh", file.getPath()}); ++ public void run() ++ { ++ try ++ { ++ String os = System.getProperty( "os.name" ).toLowerCase(); ++ if ( os.contains( "win" ) ) ++ { ++ Runtime.getRuntime().exec( "cmd /c start " + file.getPath() ); ++ } else ++ { ++ Runtime.getRuntime().exec( new String[] ++ { ++ "sh", file.getPath() ++ } ); + } -+ } catch (Exception e) { ++ } catch ( Exception e ) ++ { + e.printStackTrace(); + } + } + }; + -+ shutdownHook.setDaemon(true); -+ Runtime.getRuntime().addShutdownHook(shutdownHook); -+ } else { -+ System.out.println("Startup script '" + startupScript + "' does not exist! Stopping server."); ++ shutdownHook.setDaemon( true ); ++ Runtime.getRuntime().addShutdownHook( shutdownHook ); ++ } else ++ { ++ System.out.println( "Startup script '" + SpigotConfig.restartScript + "' does not exist! Stopping server." ); + } -+ System.exit(0); -+ } catch (Exception ex) { ++ System.exit( 0 ); ++ } catch ( Exception ex ) ++ { + ex.printStackTrace(); + } + } -+ - public static boolean filterIp(PendingConnection con) { - if (filterIps) { - try { -diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java -new file mode 100644 -index 0000000..2d5c89f ---- /dev/null -+++ b/src/main/java/org/spigotmc/RestartCommand.java -@@ -0,0 +1,23 @@ -+package org.spigotmc; -+ -+import org.bukkit.command.Command; -+import org.bukkit.command.CommandSender; -+import org.bukkit.craftbukkit.Spigot; -+ -+public class RestartCommand extends Command { -+ -+ public RestartCommand(String name) { -+ super(name); -+ this.description = "Restarts the server"; -+ this.usageMessage = "/restart"; -+ this.setPermission("bukkit.command.restart"); -+ } -+ -+ @Override -+ public boolean execute(CommandSender sender, String currentAlias, String[] args) { -+ if (testPermission(sender)) { -+ Spigot.restart(); -+ } -+ return true; -+ } +} +diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java +index fde9250..2fe3a5d 100644 +--- a/src/main/java/org/spigotmc/SpigotConfig.java ++++ b/src/main/java/org/spigotmc/SpigotConfig.java +@@ -119,4 +119,15 @@ public class SpigotConfig + { + preventProxies = getBoolean( "settings.prevent-proxies", preventProxies ); + } ++ ++ public static int timeoutTime = 60; ++ public static boolean restartOnCrash = true; ++ public static String restartScript = "./start.sh"; ++ private static void watchdog() ++ { ++ timeoutTime = getInt( "settings.timeout-time", timeoutTime ); ++ restartOnCrash = getBoolean( "settings.restart-on-crash", restartOnCrash ); ++ restartScript = getString( "settings.restart-script", restartScript ); ++ WatchdogThread.doStart( timeoutTime, restartOnCrash ); ++ } + } diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java new file mode 100644 -index 0000000..10390b8 +index 0000000..38ef9b7 --- /dev/null +++ b/src/main/java/org/spigotmc/WatchdogThread.java -@@ -0,0 +1,93 @@ +@@ -0,0 +1,110 @@ +package org.spigotmc; + +import java.lang.management.ManagementFactory; @@ -195,9 +175,9 @@ index 0000000..10390b8 +import java.util.logging.Level; +import java.util.logging.Logger; +import org.bukkit.Bukkit; -+import org.bukkit.craftbukkit.Spigot; + -+public class WatchdogThread extends Thread { ++public class WatchdogThread extends Thread ++{ + + private static WatchdogThread instance; + private final long timeoutTime; @@ -205,95 +185,98 @@ index 0000000..10390b8 + private volatile long lastTick; + private volatile boolean stopping; + -+ private WatchdogThread(long timeoutTime, boolean restart) { -+ super("Spigot Watchdog Thread"); ++ private WatchdogThread(long timeoutTime, boolean restart) ++ { ++ super( "Spigot Watchdog Thread" ); + this.timeoutTime = timeoutTime; + this.restart = restart; + } + -+ public static void doStart(int timeoutTime, boolean restart) { -+ if (instance == null) { -+ instance = new WatchdogThread(timeoutTime * 1000L, restart); ++ public static void doStart(int timeoutTime, boolean restart) ++ { ++ if ( instance == null ) ++ { ++ instance = new WatchdogThread( timeoutTime * 1000L, restart ); + instance.start(); + } + } + -+ public static void tick() { ++ public static void tick() ++ { + instance.lastTick = System.currentTimeMillis(); + } + -+ public static void doStop() { -+ if (instance != null) { ++ public static void doStop() ++ { ++ if ( instance != null ) ++ { + instance.stopping = true; + } + } + + @Override -+ public void run() { -+ while (!stopping) { ++ public void run() ++ { ++ while ( !stopping ) ++ { + // -+ if (lastTick != 0 && System.currentTimeMillis() > lastTick + timeoutTime) { ++ if ( lastTick != 0 && System.currentTimeMillis() > lastTick + timeoutTime ) ++ { + Logger log = Bukkit.getServer().getLogger(); -+ log.log(Level.SEVERE, "The server has stopped responding!"); -+ log.log(Level.SEVERE, "Please report this to http://www.spigotmc.org/"); -+ log.log(Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports"); -+ log.log(Level.SEVERE, "Spigot version: " + Bukkit.getServer().getVersion()); ++ log.log( Level.SEVERE, "The server has stopped responding!" ); ++ log.log( Level.SEVERE, "Please report this to http://www.spigotmc.org/" ); ++ log.log( Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports" ); ++ log.log( Level.SEVERE, "Spigot version: " + Bukkit.getServer().getVersion() ); + // -+ log.log(Level.SEVERE, "Current Thread State:"); -+ ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true); -+ for (ThreadInfo thread : threads) { -+ if (thread.getThreadState() != State.WAITING) { -+ log.log(Level.SEVERE, "------------------------------"); ++ log.log( Level.SEVERE, "Current Thread State:" ); ++ ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads( true, true ); ++ for ( ThreadInfo thread : threads ) ++ { ++ if ( thread.getThreadState() != State.WAITING ) ++ { ++ log.log( Level.SEVERE, "------------------------------" ); + // -+ log.log(Level.SEVERE, "Current Thread: " + thread.getThreadName()); -+ log.log(Level.SEVERE, "\tPID: " + thread.getThreadId() ++ log.log( Level.SEVERE, "Current Thread: " + thread.getThreadName() ); ++ log.log( Level.SEVERE, "\tPID: " + thread.getThreadId() + + " | Suspended: " + thread.isSuspended() + + " | Native: " + thread.isInNative() -+ + " | State: " + thread.getThreadState()); -+ if (thread.getLockedMonitors().length != 0) { -+ log.log(Level.SEVERE, "\tThread is waiting on monitor(s):"); -+ for (MonitorInfo monitor : thread.getLockedMonitors()) { -+ log.log(Level.SEVERE, "\t\tLocked on:" + monitor.getLockedStackFrame()); ++ + " | State: " + thread.getThreadState() ); ++ if ( thread.getLockedMonitors().length != 0 ) ++ { ++ log.log( Level.SEVERE, "\tThread is waiting on monitor(s):" ); ++ for ( MonitorInfo monitor : thread.getLockedMonitors() ) ++ { ++ log.log( Level.SEVERE, "\t\tLocked on:" + monitor.getLockedStackFrame() ); + } + } -+ log.log(Level.SEVERE, "\tStack:"); ++ log.log( Level.SEVERE, "\tStack:" ); + // + StackTraceElement[] stack = thread.getStackTrace(); -+ for (int line = 0; line < stack.length; line++) { -+ log.log(Level.SEVERE, "\t\t" + stack[line].toString()); ++ for ( int line = 0; line < stack.length; line++ ) ++ { ++ log.log( Level.SEVERE, "\t\t" + stack[line].toString() ); + } + } + } -+ log.log(Level.SEVERE, "------------------------------"); ++ log.log( Level.SEVERE, "------------------------------" ); + -+ if (restart) { -+ Spigot.restart(); ++ if ( restart ) ++ { ++ RestartCommand.restart(); + } + break; + } + -+ try { -+ sleep(10000); -+ } catch (InterruptedException ex) { ++ try ++ { ++ sleep( 10000 ); ++ } catch ( InterruptedException ex ) ++ { + interrupt(); + } + } + } +} -diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml -index 9c64871..3d4272b 100644 ---- a/src/main/resources/configurations/bukkit.yml -+++ b/src/main/resources/configurations/bukkit.yml -@@ -31,6 +31,9 @@ settings: - spam-exclusions: - - /skill - filter-unsafe-ips: false -+ timeout-time: 30 -+ restart-on-crash: false -+ restart-script-location: /path/to/server/start.sh - world-settings: - default: - growth-chunks-per-tick: 650 -- 1.8.1.2 diff --git a/CraftBukkit-Patches/0025-Netty.patch b/CraftBukkit-Patches/0025-Netty.patch index 075eda8306..bd7000a0f3 100644 --- a/CraftBukkit-Patches/0025-Netty.patch +++ b/CraftBukkit-Patches/0025-Netty.patch @@ -1,4 +1,4 @@ -From 5146e6a561c2858de9a0d2a44dadde9db0b7a8a6 Mon Sep 17 00:00:00 2001 +From 184b38aa96c6eb71116c452bff126cd7df9db814 Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 23 Apr 2013 11:47:32 +1000 Subject: [PATCH] Netty @@ -53,7 +53,7 @@ index 8c9f66b..a33020e 100644 diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java -index 10ce69d..e4f1cbe 100644 +index 6668b7e..b2a4229 100644 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/DedicatedServer.java @@ -96,7 +96,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer @@ -131,7 +131,7 @@ index 1862863..5a24f2a 100644 + public void setSocketAddress(SocketAddress address) { k = address; } // Spigot } diff --git a/src/main/java/net/minecraft/server/Packet51MapChunk.java b/src/main/java/net/minecraft/server/Packet51MapChunk.java -index 7711629..9cf625d 100644 +index efe102e..e488fa8 100644 --- a/src/main/java/net/minecraft/server/Packet51MapChunk.java +++ b/src/main/java/net/minecraft/server/Packet51MapChunk.java @@ -42,7 +42,7 @@ public class Packet51MapChunk extends Packet { @@ -144,7 +144,7 @@ index 7711629..9cf625d 100644 this.d = chunkmap.c; this.c = chunkmap.b; diff --git a/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java b/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java -index ce28495..fb34d4a 100644 +index a2cd9b0..f586415 100644 --- a/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java +++ b/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java @@ -24,7 +24,7 @@ public class Packet56MapChunkBulk extends Packet { @@ -210,10 +210,10 @@ index 17cfacc..a945892 100644 this.b = true; } catch (Exception exception) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 82dfef1..2485ef9 100644 +index 2567bde..7f5f3ea 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1389,4 +1389,20 @@ public final class CraftServer implements Server { +@@ -1367,4 +1367,20 @@ public final class CraftServer implements Server { public CraftScoreboardManager getScoreboardManager() { return scoreboardManager; } @@ -1500,7 +1500,7 @@ index 0000000..d3a9cab + DATA; +} diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml -index 3d4272b..53db120 100644 +index 61a95e3..e65758d 100644 --- a/src/main/resources/configurations/bukkit.yml +++ b/src/main/resources/configurations/bukkit.yml @@ -13,6 +13,9 @@