From 941800ce96a84108cab201d298735f4bec786493 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 30 Dec 2019 23:20:25 -0700 Subject: [PATCH] Add VelocityServer#shutdown(boolean, TextComponent) --- .../velocitypowered/proxy/VelocityServer.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index 2f260cce6..ad80a9161 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -360,11 +360,12 @@ public class VelocityServer implements ProxyServer { } /** - * Shuts down the proxy. + * Shuts down the proxy, kicking players with the specified {@param reason}. * * @param explicitExit whether the user explicitly shut down the proxy + * @param reason message to kick online players with */ - public void shutdown(boolean explicitExit) { + public void shutdown(boolean explicitExit, TextComponent reason) { if (eventManager == null || pluginManager == null || cm == null || scheduler == null) { throw new AssertionError(); } @@ -382,7 +383,7 @@ public class VelocityServer implements ProxyServer { ImmutableList players = ImmutableList.copyOf(connectionsByUuid.values()); for (ConnectedPlayer player : players) { - player.disconnect(TextComponent.of("Proxy shutting down.")); + player.disconnect(reason); } try { @@ -425,6 +426,15 @@ public class VelocityServer implements ProxyServer { thread.start(); } + /** + * Calls {@link #shutdown(boolean, TextComponent)} with the default reason "Proxy shutting down." + * + * @param explicitExit whether the user explicitly shut down the proxy + */ + public void shutdown(boolean explicitExit) { + shutdown(explicitExit, TextComponent.of("Proxy shutting down.")); + } + public AsyncHttpClient getAsyncHttpClient() { return ensureInitialized(cm).getHttpClient(); }