Add shutdown flag.

This commit is contained in:
Andrew Steinborn 2018-08-07 10:14:34 -04:00
parent 05693425bf
commit a7a227ed05

View File

@ -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<UUID, ConnectedPlayer> connectionsByUuid = new ConcurrentHashMap<>();
private final Map<String, ConnectedPlayer> 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();
}