From ee8f33c1968477ddce02f4914c0c292af8598951 Mon Sep 17 00:00:00 2001 From: mrapple Date: Sat, 3 Aug 2013 16:55:34 -0500 Subject: [PATCH] Add State to ServerKickEvent --- .../md_5/bungee/api/event/ServerKickEvent.java | 16 ++++++++++++++++ .../java/net/md_5/bungee/ServerConnector.java | 2 +- .../md_5/bungee/connection/DownstreamBridge.java | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/event/ServerKickEvent.java b/api/src/main/java/net/md_5/bungee/api/event/ServerKickEvent.java index 69029048..bd5b6d5d 100644 --- a/api/src/main/java/net/md_5/bungee/api/event/ServerKickEvent.java +++ b/api/src/main/java/net/md_5/bungee/api/event/ServerKickEvent.java @@ -33,11 +33,27 @@ public class ServerKickEvent extends Event implements Cancellable * Server to send player to if this event is cancelled. */ private ServerInfo cancelServer; + /** + * State in which the kick occured. + */ + private State state; + + public enum State + { + + CONNECTING, CONNECTED, UNKNOWN; + } public ServerKickEvent(ProxiedPlayer player, String kickReason, ServerInfo cancelServer) + { + this(player, kickReason, cancelServer, State.UNKNOWN); + } + + public ServerKickEvent(ProxiedPlayer player, String kickReason, ServerInfo cancelServer, State state) { this.player = player; this.kickReason = kickReason; this.cancelServer = cancelServer; + this.state = state; } } diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index 231893c2..e3d31247 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -256,7 +256,7 @@ public class ServerConnector extends PacketHandler { def = null; } - ServerKickEvent event = bungee.getPluginManager().callEvent( new ServerKickEvent( user, kick.getMessage(), def ) ); + ServerKickEvent event = bungee.getPluginManager().callEvent( new ServerKickEvent( user, kick.getMessage(), def, ServerKickEvent.State.CONNECTING ) ); if ( event.isCancelled() && event.getCancelServer() != null ) { user.connect( event.getCancelServer() ); diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java index 4399f516..c45555db 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java @@ -325,7 +325,7 @@ public class DownstreamBridge extends PacketHandler { def = null; } - ServerKickEvent event = bungee.getPluginManager().callEvent( new ServerKickEvent( con, kick.getMessage(), def ) ); + ServerKickEvent event = bungee.getPluginManager().callEvent( new ServerKickEvent( con, kick.getMessage(), def, ServerKickEvent.State.CONNECTED ) ); if ( event.isCancelled() && event.getCancelServer() != null ) { con.connectNow( event.getCancelServer() );