From 8352f7fa70b5eb2beb3a1eaf7fbae66bb4f83fa1 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Wed, 22 Aug 2018 00:47:29 -0400 Subject: [PATCH] Add disconnect API call --- api/src/main/java/com/velocitypowered/api/proxy/Player.java | 2 ++ .../proxy/connection/client/ConnectedPlayer.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/api/src/main/java/com/velocitypowered/api/proxy/Player.java b/api/src/main/java/com/velocitypowered/api/proxy/Player.java index 92871b30e..d4b56cbf3 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/Player.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/Player.java @@ -53,4 +53,6 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage * @return a new connection request */ ConnectionRequestBuilder createConnectionRequest(@NonNull ServerInfo info); + + void disconnect(Component reason); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index 4c47e4565..1de683846 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -134,6 +134,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { return new ConnectionRequestBuilderImpl(info); } + @Override + public void disconnect(Component reason) { + connection.closeWith(Disconnect.create(reason)); + } + public VelocityServerConnection getConnectedServer() { return connectedServer; }