Optimize throwing of CancelSendSignal's by storing a single instance.
This commit is contained in:
parent
4abffa9f24
commit
2eb2953442
@ -90,7 +90,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
ch.setProtocol( Protocol.GAME );
|
ch.setProtocol( Protocol.GAME );
|
||||||
thisState = State.LOGIN;
|
thisState = State.LOGIN;
|
||||||
|
|
||||||
throw new CancelSendSignal();
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -182,7 +182,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
|
|
||||||
thisState = State.FINISHED;
|
thisState = State.FINISHED;
|
||||||
|
|
||||||
throw new CancelSendSignal();
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -203,7 +203,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
if ( event.isCancelled() && event.getCancelServer() != null )
|
if ( event.isCancelled() && event.getCancelServer() != null )
|
||||||
{
|
{
|
||||||
user.connect( event.getCancelServer() );
|
user.connect( event.getCancelServer() );
|
||||||
throw new CancelSendSignal();
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
String message = bungee.getTranslation( "connect_kick" ) + target.getName() + ": " + event.getKickReason();
|
String message = bungee.getTranslation( "connect_kick" ) + target.getName() + ": " + event.getKickReason();
|
||||||
@ -215,7 +215,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
user.sendMessage( message );
|
user.sendMessage( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new CancelSendSignal();
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
package net.md_5.bungee.connection;
|
package net.md_5.bungee.connection;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class CancelSendSignal extends Error
|
public class CancelSendSignal extends Error
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static final CancelSendSignal INSTANCE = CancelSendSignal.INSTANCE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Throwable initCause(Throwable cause)
|
public Throwable initCause(Throwable cause)
|
||||||
{
|
{
|
||||||
|
@ -97,7 +97,7 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
|
|
||||||
if ( !con.getTabList().onListUpdate( playerList.getUsername(), playerList.isOnline(), playerList.getPing() ) )
|
if ( !con.getTabList().onListUpdate( playerList.getUsername(), playerList.isOnline(), playerList.getPing() ) )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
|
|
||||||
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
|
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
|
||||||
@ -365,7 +365,7 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
con.disconnect0( event.getKickReasonComponent() ); // TODO: Prefix our own stuff.
|
con.disconnect0( event.getKickReasonComponent() ); // TODO: Prefix our own stuff.
|
||||||
}
|
}
|
||||||
server.setObsolete( true );
|
server.setObsolete( true );
|
||||||
throw new CancelSendSignal();
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,7 +90,7 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
con.getServer().unsafe().sendPacket( chat );
|
con.getServer().unsafe().sendPacket( chat );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new CancelSendSignal();
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -104,7 +104,7 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
if ( !results.isEmpty() )
|
if ( !results.isEmpty() )
|
||||||
{
|
{
|
||||||
con.unsafe().sendPacket( new TabCompleteResponse( results.toArray( new String[ results.size() ] ) ) );
|
con.unsafe().sendPacket( new TabCompleteResponse( results.toArray( new String[ results.size() ] ) ) );
|
||||||
throw new CancelSendSignal();
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,18 +120,18 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
{
|
{
|
||||||
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
|
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
// Hack around Forge race conditions
|
// Hack around Forge race conditions
|
||||||
if ( pluginMessage.getTag().equals( "FML" ) && pluginMessage.getStream().readUnsignedByte() == 1 )
|
if ( pluginMessage.getTag().equals( "FML" ) && pluginMessage.getStream().readUnsignedByte() == 1 )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginMessageEvent event = new PluginMessageEvent( con, con.getServer(), pluginMessage.getTag(), pluginMessage.getData().clone() );
|
PluginMessageEvent event = new PluginMessageEvent( con, con.getServer(), pluginMessage.getTag(), pluginMessage.getData().clone() );
|
||||||
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user