From 2b0daa2122e8f3f57e4f99a79a64dcbeac07c8c5 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Wed, 14 Nov 2018 01:07:34 -0500 Subject: [PATCH] Explicitly exit the proxy if required. --- proxy/src/main/java/com/velocitypowered/proxy/Velocity.java | 2 +- .../main/java/com/velocitypowered/proxy/VelocityServer.java | 6 +++++- .../com/velocitypowered/proxy/command/ShutdownCommand.java | 2 +- .../com/velocitypowered/proxy/console/VelocityConsole.java | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java index e91df7d32..0d3b64c15 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java @@ -20,7 +20,7 @@ public class Velocity { VelocityServer server = new VelocityServer(); server.start(); - Runtime.getRuntime().addShutdownHook(new Thread(server::shutdown, "Shutdown thread")); + Runtime.getRuntime().addShutdownHook(new Thread(() -> server.shutdown(false), "Shutdown thread")); double bootTime = (System.currentTimeMillis() - startTime) / 1000d; logger.info("Done ({}s)!", new DecimalFormat("#.##").format(bootTime)); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index 0bc9e16ec..8bc8c0666 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -229,7 +229,7 @@ public class VelocityServer implements ProxyServer { return shutdown; } - public void shutdown() { + public void shutdown(boolean explicitExit) { if (eventManager == null || pluginManager == null || cm == null || scheduler == null) { throw new AssertionError(); } @@ -256,6 +256,10 @@ public class VelocityServer implements ProxyServer { } shutdown = true; + + if (explicitExit) { + System.exit(0); + } } public NettyHttpClient getHttpClient() { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/ShutdownCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/ShutdownCommand.java index 4d396fac8..e3e8d5d6d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/ShutdownCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/ShutdownCommand.java @@ -22,7 +22,7 @@ public class ShutdownCommand implements Command { .sendMessage(TextComponent.of("You are not allowed to use this command.", TextColor.RED)); return; } - server.shutdown(); + server.shutdown(true); } @Override diff --git a/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java b/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java index 5fa1050c9..97e7f84ad 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java @@ -88,7 +88,7 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Comm @Override protected void shutdown() { - this.server.shutdown(); + this.server.shutdown(true); } }