#3797: Expose sendPacketQueued to unsafe interface
This commit is contained in:
@@ -156,7 +156,7 @@ public class BungeeTitle implements Title
|
||||
{
|
||||
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_17 )
|
||||
{
|
||||
( (UserConnection) player ).sendPacketQueued( packet.newPacket );
|
||||
player.unsafe().sendPacketQueued( packet.newPacket );
|
||||
} else
|
||||
{
|
||||
player.unsafe().sendPacket( packet.oldPacket );
|
||||
|
@@ -14,6 +14,7 @@ import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@@ -40,6 +41,18 @@ public class ServerConnection implements Server
|
||||
{
|
||||
ch.write( packet );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketQueued(DefinedPacket packet)
|
||||
{
|
||||
if ( ch.getEncodeVersion() >= ProtocolConstants.MINECRAFT_1_20_2 )
|
||||
{
|
||||
ServerConnection.this.sendPacketQueued( packet );
|
||||
} else
|
||||
{
|
||||
sendPacket( packet );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void sendPacketQueued(DefinedPacket packet)
|
||||
@@ -53,6 +66,8 @@ public class ServerConnection implements Server
|
||||
Protocol encodeProtocol = ch.getEncodeProtocol();
|
||||
if ( !encodeProtocol.TO_SERVER.hasPacket( packet.getClass(), ch.getEncodeVersion() ) )
|
||||
{
|
||||
// we should limit this so bad api usage won't oom the server.
|
||||
Preconditions.checkState( packetQueue.size() <= 4096, "too many queued packets" );
|
||||
packetQueue.add( packet );
|
||||
} else
|
||||
{
|
||||
|
@@ -150,6 +150,18 @@ public final class UserConnection implements ProxiedPlayer
|
||||
{
|
||||
ch.write( packet );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketQueued(DefinedPacket packet)
|
||||
{
|
||||
if ( pendingConnection.getVersion() >= ProtocolConstants.MINECRAFT_1_20_2 )
|
||||
{
|
||||
UserConnection.this.sendPacketQueued( packet );
|
||||
} else
|
||||
{
|
||||
sendPacket( packet );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public boolean init()
|
||||
@@ -191,6 +203,8 @@ public final class UserConnection implements ProxiedPlayer
|
||||
Protocol encodeProtocol = ch.getEncodeProtocol();
|
||||
if ( !encodeProtocol.TO_CLIENT.hasPacket( packet.getClass(), getPendingConnection().getVersion() ) )
|
||||
{
|
||||
// we should limit this so bad api usage won't oom the server.
|
||||
Preconditions.checkState( packetQueue.size() <= 4096, "too many queued packets" );
|
||||
packetQueue.add( packet );
|
||||
} else
|
||||
{
|
||||
|
@@ -122,6 +122,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
{
|
||||
ch.write( packet );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketQueued(DefinedPacket packet)
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported" );
|
||||
}
|
||||
};
|
||||
@Getter
|
||||
private boolean onlineMode = BungeeCord.getInstance().config.isOnlineMode();
|
||||
|
@@ -103,7 +103,7 @@ public class UpstreamBridge extends PacketHandler
|
||||
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_19_3 )
|
||||
{
|
||||
// need to queue, because players in config state could receive it
|
||||
( (UserConnection) player ).sendPacketQueued( newPacket );
|
||||
player.unsafe().sendPacketQueued( newPacket );
|
||||
} else
|
||||
{
|
||||
player.unsafe().sendPacket( oldPacket );
|
||||
|
Reference in New Issue
Block a user