Add State to ServerKickEvent

This commit is contained in:
mrapple 2013-08-03 16:55:34 -05:00 committed by md_5
parent 14ac2dd308
commit ee8f33c196
3 changed files with 18 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -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() );

View File

@ -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() );