From 190bef375a9e1d28c9e793d6de528dc52a87a9fc Mon Sep 17 00:00:00 2001 From: Alexander Staeding Date: Thu, 30 Jul 2020 21:48:58 +0200 Subject: [PATCH] Add shutdown methods to ProxyServer --- .../com/velocitypowered/api/proxy/ProxyServer.java | 13 +++++++++++++ .../com/velocitypowered/proxy/VelocityServer.java | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java b/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java index 995900c88..7e2e570c4 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java @@ -19,6 +19,7 @@ import java.util.Optional; import java.util.UUID; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; import org.checkerframework.checker.nullness.qual.NonNull; /** @@ -26,6 +27,18 @@ import org.checkerframework.checker.nullness.qual.NonNull; */ public interface ProxyServer extends Audience { + /** + * Shuts down the proxy, kicking players with the specified {@param reason}. + * + * @param reason message to kick online players with + */ + void shutdown(TextComponent reason); + + /** + * Shuts down the proxy, kicking players with the default reason. + */ + void shutdown(); + /** * Retrieves the player currently connected to this proxy by their Minecraft username. The search * is case-insensitive. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index 4372e5604..3e3dbf065 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -453,6 +453,16 @@ public class VelocityServer implements ProxyServer, ForwardingAudience { shutdown(explicitExit, TextComponent.of("Proxy shutting down.")); } + @Override + public void shutdown(TextComponent reason) { + shutdown(true, reason); + } + + @Override + public void shutdown() { + shutdown(true); + } + public AsyncHttpClient getAsyncHttpClient() { return cm.getHttpClient(); }