From a7a227ed0553bcbf338ab1ff9b7b0603307d0478 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Tue, 7 Aug 2018 10:14:34 -0400 Subject: [PATCH] Add shutdown flag. --- .../java/com/velocitypowered/proxy/VelocityServer.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index a6f365b22..43c0365ec 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -49,6 +49,7 @@ public class VelocityServer implements ProxyServer { private KeyPair serverKeyPair; private final ServerMap servers = new ServerMap(); private final CommandManager commandManager = new CommandManager(); + private boolean shutdown = false; private final Map connectionsByUuid = new ConcurrentHashMap<>(); private final Map connectionsByName = new ConcurrentHashMap<>(); @@ -134,7 +135,16 @@ public class VelocityServer implements ProxyServer { return this.cm.createWorker(); } + public boolean isShutdown() { + return shutdown; + } + public void shutdown() { + Preconditions.checkState(!shutdown, "Server already shut down"); + shutdown = true; + + logger.info("Shutting down the proxy..."); + this.cm.shutdown(); }