mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-03 13:36:44 +01:00
Ctrl+C saves world before stopping
This commit is contained in:
parent
b37dd48ae5
commit
2ac43ce223
2 changed files with 20 additions and 1 deletions
|
@ -21,6 +21,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.craftbukkit.LoggerOutputStream;
|
import org.bukkit.craftbukkit.LoggerOutputStream;
|
||||||
import org.bukkit.craftbukkit.command.ColouredConsoleSender;
|
import org.bukkit.craftbukkit.command.ColouredConsoleSender;
|
||||||
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||||
|
import org.bukkit.craftbukkit.util.ServerShutdownThread;
|
||||||
import org.bukkit.event.world.WorldSaveEvent;
|
import org.bukkit.event.world.WorldSaveEvent;
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(MinecraftServer.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MinecraftServer.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
Runtime.getRuntime().addShutdownHook(new ServerShutdownThread(this));
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +220,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
private void g() {
|
public void g() { // Craftbukkit: private -> public
|
||||||
a.info("Stopping server");
|
a.info("Stopping server");
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue