#1945: Relay MC|Brand messages
This commit is contained in:
parent
98e3c70460
commit
5c809c2499
@ -1,6 +1,7 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Predicate;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.ByteArrayInputStream;
|
||||
@ -20,6 +21,15 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
public class PluginMessage extends DefinedPacket
|
||||
{
|
||||
|
||||
public static final Predicate<PluginMessage> SHOULD_RELAY = new Predicate<PluginMessage>()
|
||||
{
|
||||
@Override
|
||||
public boolean apply(PluginMessage input)
|
||||
{
|
||||
return input.getTag().equals( "REGISTER" ) || input.getTag().equals( "MC|Brand" );
|
||||
}
|
||||
};
|
||||
//
|
||||
private String tag;
|
||||
private byte[] data;
|
||||
|
||||
|
@ -30,7 +30,6 @@ import net.md_5.bungee.netty.HandlerBoss;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
import net.md_5.bungee.protocol.packet.BossBar;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||
import net.md_5.bungee.protocol.packet.Handshake;
|
||||
import net.md_5.bungee.protocol.packet.Kick;
|
||||
@ -170,7 +169,7 @@ public class ServerConnector extends PacketHandler
|
||||
}
|
||||
}
|
||||
|
||||
for ( PluginMessage message : user.getPendingConnection().getRegisterMessages() )
|
||||
for ( PluginMessage message : user.getPendingConnection().getRelayMessages() )
|
||||
{
|
||||
ch.write( message );
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
private LoginRequest loginRequest;
|
||||
private EncryptionRequest request;
|
||||
@Getter
|
||||
private final List<PluginMessage> registerMessages = new BoundedArrayList<>( 128 );
|
||||
private final List<PluginMessage> relayMessages = new BoundedArrayList<>( 128 );
|
||||
private State thisState = State.HANDSHAKE;
|
||||
private final Unsafe unsafe = new Unsafe()
|
||||
{
|
||||
@ -126,9 +126,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
public void handle(PluginMessage pluginMessage) throws Exception
|
||||
{
|
||||
// TODO: Unregister?
|
||||
if ( pluginMessage.getTag().equals( "REGISTER" ) )
|
||||
if ( PluginMessage.SHOULD_RELAY.apply( pluginMessage ) )
|
||||
{
|
||||
registerMessages.add( pluginMessage );
|
||||
relayMessages.add( pluginMessage );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ import net.md_5.bungee.api.event.TabCompleteEvent;
|
||||
import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.packet.KeepAlive;
|
||||
import net.md_5.bungee.protocol.packet.Chat;
|
||||
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
||||
@ -191,9 +190,9 @@ public class UpstreamBridge extends PacketHandler
|
||||
}
|
||||
|
||||
// TODO: Unregister as well?
|
||||
if ( pluginMessage.getTag().equals( "REGISTER" ) )
|
||||
if ( PluginMessage.SHOULD_RELAY.apply( pluginMessage ) )
|
||||
{
|
||||
con.getPendingConnection().getRegisterMessages().add( pluginMessage );
|
||||
con.getPendingConnection().getRelayMessages().add( pluginMessage );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user