diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java index 659482575..671cf96ff 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java @@ -103,26 +103,30 @@ public class BungeeServerInfo implements ServerInfo sendData( channel, data, true ); } - // TODO: Don't like this method @Override public boolean sendData(String channel, byte[] data, boolean queue) { Preconditions.checkNotNull( channel, "channel" ); Preconditions.checkNotNull( data, "data" ); - synchronized ( packetQueue ) + Server server; + synchronized ( players ) { - Server server = ( players.isEmpty() ) ? null : players.iterator().next().getServer(); - if ( server != null ) - { - server.sendData( channel, data ); - return true; - } else if ( queue ) + server = ( players.isEmpty() ) ? null : players.iterator().next().getServer(); + } + + if ( server != null ) + { + server.sendData( channel, data ); + return true; + } else if ( queue ) + { + synchronized ( packetQueue ) { packetQueue.add( new PluginMessage( channel, data, false ) ); } - return false; } + return false; } private long lastPing;