diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-03-29 21:01:04 +0100 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-03-29 21:01:04 +0100 |
commit | 2ac43ce2232d0c9b95276ee48ac6f21340a90323 (patch) | |
tree | dde9bf56d184b6ce198dc293e113dc638897f0c8 /src/main | |
parent | b37dd48ae5ec70f1bc763de1e4aa69c4321f18ed (diff) | |
download | craftbukkit-2ac43ce2232d0c9b95276ee48ac6f21340a90323.tar craftbukkit-2ac43ce2232d0c9b95276ee48ac6f21340a90323.tar.gz craftbukkit-2ac43ce2232d0c9b95276ee48ac6f21340a90323.tar.lz craftbukkit-2ac43ce2232d0c9b95276ee48ac6f21340a90323.tar.xz craftbukkit-2ac43ce2232d0c9b95276ee48ac6f21340a90323.zip |
Ctrl+C saves world before stopping
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/net/minecraft/server/MinecraftServer.java | 4 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java | 17 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 78b18503..42b2ba7e 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -21,6 +21,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.LoggerOutputStream; import org.bukkit.craftbukkit.command.ColouredConsoleSender; import org.bukkit.craftbukkit.scheduler.CraftScheduler; +import org.bukkit.craftbukkit.util.ServerShutdownThread; import org.bukkit.event.world.WorldSaveEvent; @@ -64,6 +65,7 @@ public class MinecraftServer implements Runnable, ICommandListener { } catch (IOException ex) { Logger.getLogger(MinecraftServer.class.getName()).log(Level.SEVERE, null, ex); } + Runtime.getRuntime().addShutdownHook(new ServerShutdownThread(this)); // CraftBukkit end } @@ -218,7 +220,7 @@ public class MinecraftServer implements Runnable, ICommandListener { // CraftBukkit end } - private void g() { + public void g() { // Craftbukkit: private -> public a.info("Stopping server"); // CraftBukkit start if (server != null) { diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java new file mode 100644 index 00000000..d15bb782 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java @@ -0,0 +1,17 @@ + +package org.bukkit.craftbukkit.util; + +import net.minecraft.server.MinecraftServer; + +public class ServerShutdownThread extends Thread { + private final MinecraftServer server; + + public ServerShutdownThread(MinecraftServer server) { + this.server = server; + } + + @Override + public void run() { + server.g(); + } +} |