Make connect event implement cancellable, closes #338

This commit is contained in:
md_5
2013-05-15 19:04:22 +10:00
parent ff32d29e09
commit a48ef137bd
2 changed files with 16 additions and 3 deletions

View File

@@ -143,7 +143,10 @@ public final class UserConnection implements ProxiedPlayer
public void connect(ServerInfo info, final boolean retry)
{
ServerConnectEvent event = new ServerConnectEvent( this, info );
ProxyServer.getInstance().getPluginManager().callEvent( event );
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
{
return;
}
Preconditions.checkArgument( event.getTarget() instanceof BungeeServerInfo, "BungeeCord can only connect to BungeeServerInfo instances" );
final BungeeServerInfo target = (BungeeServerInfo) event.getTarget(); // Update in case the event changed target