From 9740c0a07bec7281760b13db165a1a66994e56de Mon Sep 17 00:00:00 2001 From: Outfluencer <48880402+Outfluencer@users.noreply.github.com> Date: Wed, 17 Apr 2024 21:05:26 +1000 Subject: [PATCH] #3656: Improve online mode support where IP forwarding is disabled --- proxy/src/main/java/net/md_5/bungee/ServerConnector.java | 4 ++-- proxy/src/main/java/net/md_5/bungee/UserConnection.java | 5 +++++ .../java/net/md_5/bungee/connection/InitialHandler.java | 5 ++++- .../java/net/md_5/bungee/connection/UpstreamBridge.java | 4 ++-- .../java/net/md_5/bungee/entitymap/EntityMap_1_10.java | 8 ++++---- .../java/net/md_5/bungee/entitymap/EntityMap_1_11.java | 8 ++++---- .../java/net/md_5/bungee/entitymap/EntityMap_1_12.java | 8 ++++---- .../java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java | 8 ++++---- .../java/net/md_5/bungee/entitymap/EntityMap_1_13.java | 8 ++++---- .../java/net/md_5/bungee/entitymap/EntityMap_1_14.java | 8 ++++---- .../java/net/md_5/bungee/entitymap/EntityMap_1_15.java | 8 ++++---- .../java/net/md_5/bungee/entitymap/EntityMap_1_16.java | 8 ++++---- .../java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java | 8 ++++---- .../java/net/md_5/bungee/entitymap/EntityMap_1_8.java | 8 ++++---- .../java/net/md_5/bungee/entitymap/EntityMap_1_9.java | 8 ++++---- .../java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java | 8 ++++---- proxy/src/main/java/net/md_5/bungee/tab/TabList.java | 4 ++-- 17 files changed, 63 insertions(+), 55 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index abdbfd1dccd..d7359891270 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -130,7 +130,7 @@ public void connected(ChannelWrapper channel) throws Exception channel.write( copiedHandshake ); channel.setProtocol( Protocol.LOGIN ); - channel.write( new LoginRequest( user.getName(), null, user.getUniqueId() ) ); + channel.write( new LoginRequest( user.getName(), null, user.getRewriteId() ) ); } @Override @@ -365,7 +365,7 @@ private void cutThrough(ServerConnection server) } else { LoginResult loginProfile = user.getPendingConnection().getLoginProfile(); - user.unsafe().sendPacket( new LoginSuccess( user.getUniqueId(), user.getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) ); + user.unsafe().sendPacket( new LoginSuccess( user.getRewriteId(), user.getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) ); user.getCh().setEncodeProtocol( Protocol.CONFIGURATION ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index 9edec4107a0..41670a1629a 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -642,6 +642,11 @@ public UUID getUniqueId() return getPendingConnection().getUniqueId(); } + public UUID getRewriteId() + { + return getPendingConnection().getRewriteId(); + } + public void setSettings(ClientSettings settings) { this.settings = settings; diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 9965cf361a7..1d9a9ee5de5 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -126,6 +126,8 @@ public void sendPacket(DefinedPacket packet) @Getter private UUID offlineId; @Getter + private UUID rewriteId; + @Getter private LoginResult loginProfile; @Getter private boolean legacy; @@ -556,6 +558,7 @@ private void finish() { uniqueId = offlineId; } + rewriteId = ( bungee.config.isIpForward() ) ? uniqueId : offlineId; if ( BungeeCord.getInstance().config.isEnforceSecureProfile() ) { @@ -635,7 +638,7 @@ public void run() if ( getVersion() < ProtocolConstants.MINECRAFT_1_20_2 ) { - unsafe.sendPacket( new LoginSuccess( getUniqueId(), getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) ); + unsafe.sendPacket( new LoginSuccess( getRewriteId(), getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) ); ch.setProtocol( Protocol.GAME ); } finish2(); diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java index f80515d4c3e..4dc0315f09a 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java @@ -85,7 +85,7 @@ public void disconnected(ChannelWrapper channel) throws Exception PlayerListItem oldPacket = new PlayerListItem(); oldPacket.setAction( PlayerListItem.Action.REMOVE_PLAYER ); PlayerListItem.Item item = new PlayerListItem.Item(); - item.setUuid( con.getUniqueId() ); + item.setUuid( con.getRewriteId() ); oldPacket.setItems( new PlayerListItem.Item[] { item @@ -94,7 +94,7 @@ public void disconnected(ChannelWrapper channel) throws Exception PlayerListItemRemove newPacket = new PlayerListItemRemove(); newPacket.setUuids( new UUID[] { - con.getUniqueId() + con.getRewriteId() } ); for ( ProxiedPlayer player : con.getServer().getInfo().getPlayers() ) diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java index 6db530c3aed..f42dc722442 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java @@ -121,13 +121,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId) DefinedPacket.readVarInt( packet ); // Entity ID int idLength = packet.readerIndex() - readerIndex - packetIdLength; UUID uuid = DefinedPacket.readUUID( packet ); - ProxiedPlayer player; + UserConnection player; if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) { int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength + idLength ); - DefinedPacket.writeUUID( player.getUniqueId(), packet ); + DefinedPacket.writeUUID( player.getRewriteId(), packet ); packet.writerIndex( previous ); } break; @@ -164,7 +164,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int packetId = DefinedPacket.readVarInt( packet ); int packetIdLength = packet.readerIndex() - readerIndex; - if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ ) { UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player; @@ -173,7 +173,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength ); - DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet ); packet.writerIndex( previous ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java index 36822127509..dc711f34020 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java @@ -121,13 +121,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId) DefinedPacket.readVarInt( packet ); // Entity ID int idLength = packet.readerIndex() - readerIndex - packetIdLength; UUID uuid = DefinedPacket.readUUID( packet ); - ProxiedPlayer player; + UserConnection player; if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) { int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength + idLength ); - DefinedPacket.writeUUID( player.getUniqueId(), packet ); + DefinedPacket.writeUUID( player.getRewriteId(), packet ); packet.writerIndex( previous ); } break; @@ -165,7 +165,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int packetId = DefinedPacket.readVarInt( packet ); int packetIdLength = packet.readerIndex() - readerIndex; - if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ ) { UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player; @@ -174,7 +174,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength ); - DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet ); packet.writerIndex( previous ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java index 38e12ce400d..c15ab1a1c8c 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java @@ -121,13 +121,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId) DefinedPacket.readVarInt( packet ); // Entity ID int idLength = packet.readerIndex() - readerIndex - packetIdLength; UUID uuid = DefinedPacket.readUUID( packet ); - ProxiedPlayer player; + UserConnection player; if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) { int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength + idLength ); - DefinedPacket.writeUUID( player.getUniqueId(), packet ); + DefinedPacket.writeUUID( player.getRewriteId(), packet ); packet.writerIndex( previous ); } break; @@ -165,7 +165,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int packetId = DefinedPacket.readVarInt( packet ); int packetIdLength = packet.readerIndex() - readerIndex; - if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ ) { UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player; @@ -174,7 +174,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength ); - DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet ); packet.writerIndex( previous ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java index 5f296839480..c3e6f8c7d73 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java @@ -121,13 +121,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId) DefinedPacket.readVarInt( packet ); // Entity ID int idLength = packet.readerIndex() - readerIndex - packetIdLength; UUID uuid = DefinedPacket.readUUID( packet ); - ProxiedPlayer player; + UserConnection player; if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) { int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength + idLength ); - DefinedPacket.writeUUID( player.getUniqueId(), packet ); + DefinedPacket.writeUUID( player.getRewriteId(), packet ); packet.writerIndex( previous ); } break; @@ -165,7 +165,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int packetId = DefinedPacket.readVarInt( packet ); int packetIdLength = packet.readerIndex() - readerIndex; - if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ ) { UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player; @@ -174,7 +174,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength ); - DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet ); packet.writerIndex( previous ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java index f3372f08850..c653d664b4a 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java @@ -121,13 +121,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protoco DefinedPacket.readVarInt( packet ); // Entity ID int idLength = packet.readerIndex() - readerIndex - packetIdLength; UUID uuid = DefinedPacket.readUUID( packet ); - ProxiedPlayer player; + UserConnection player; if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) { int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength + idLength ); - DefinedPacket.writeUUID( player.getUniqueId(), packet ); + DefinedPacket.writeUUID( player.getRewriteId(), packet ); packet.writerIndex( previous ); } break; @@ -165,7 +165,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int packetId = DefinedPacket.readVarInt( packet ); int packetIdLength = packet.readerIndex() - readerIndex; - if ( packetId == 0x28 /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + if ( packetId == 0x28 /* Spectate : PacketPlayInSpectate */ ) { UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player; @@ -174,7 +174,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength ); - DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet ); packet.writerIndex( previous ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java index 8210b0a7e34..e9b28f0df14 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java @@ -120,13 +120,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protoco DefinedPacket.readVarInt( packet ); // Entity ID int idLength = packet.readerIndex() - readerIndex - packetIdLength; UUID uuid = DefinedPacket.readUUID( packet ); - ProxiedPlayer player; + UserConnection player; if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) { int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength + idLength ); - DefinedPacket.writeUUID( player.getUniqueId(), packet ); + DefinedPacket.writeUUID( player.getRewriteId(), packet ); packet.writerIndex( previous ); } break; @@ -169,7 +169,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int packetId = DefinedPacket.readVarInt( packet ); int packetIdLength = packet.readerIndex() - readerIndex; - if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ ) { UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player; @@ -178,7 +178,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength ); - DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet ); packet.writerIndex( previous ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java index c2cf810f348..eafca587d1f 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java @@ -120,13 +120,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protoco DefinedPacket.readVarInt( packet ); // Entity ID int idLength = packet.readerIndex() - readerIndex - packetIdLength; UUID uuid = DefinedPacket.readUUID( packet ); - ProxiedPlayer player; + UserConnection player; if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) { int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength + idLength ); - DefinedPacket.writeUUID( player.getUniqueId(), packet ); + DefinedPacket.writeUUID( player.getRewriteId(), packet ); packet.writerIndex( previous ); } break; @@ -169,7 +169,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int packetId = DefinedPacket.readVarInt( packet ); int packetIdLength = packet.readerIndex() - readerIndex; - if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ ) { UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player; @@ -178,7 +178,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength ); - DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet ); packet.writerIndex( previous ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16.java index c8b067071da..98b1a155310 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16.java @@ -120,13 +120,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protoco DefinedPacket.readVarInt( packet ); // Entity ID int idLength = packet.readerIndex() - readerIndex - packetIdLength; UUID uuid = DefinedPacket.readUUID( packet ); - ProxiedPlayer player; + UserConnection player; if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) { int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength + idLength ); - DefinedPacket.writeUUID( player.getUniqueId(), packet ); + DefinedPacket.writeUUID( player.getRewriteId(), packet ); packet.writerIndex( previous ); } break; @@ -169,7 +169,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int packetId = DefinedPacket.readVarInt( packet ); int packetIdLength = packet.readerIndex() - readerIndex; - if ( packetId == 0x2C /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + if ( packetId == 0x2C /* Spectate : PacketPlayInSpectate */ ) { UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player; @@ -178,7 +178,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength ); - DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet ); packet.writerIndex( previous ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java index 6e0cae636c1..0ed7ad64231 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java @@ -41,13 +41,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protoco DefinedPacket.readVarInt( packet ); // Entity ID int idLength = packet.readerIndex() - readerIndex - packetIdLength; UUID uuid = DefinedPacket.readUUID( packet ); - ProxiedPlayer player; + UserConnection player; if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) { int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength + idLength ); - DefinedPacket.writeUUID( player.getUniqueId(), packet ); + DefinedPacket.writeUUID( player.getRewriteId(), packet ); packet.writerIndex( previous ); } } @@ -62,7 +62,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int packetId = DefinedPacket.readVarInt( packet ); int packetIdLength = packet.readerIndex() - readerIndex; - if ( packetId == spectateId && !BungeeCord.getInstance().getConfig().isIpForward() ) + if ( packetId == spectateId ) { UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player; @@ -71,7 +71,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength ); - DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet ); packet.writerIndex( previous ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java index 8e2dbe69929..42a53153908 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java @@ -121,13 +121,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId) DefinedPacket.readVarInt( packet ); // Entity ID int idLength = packet.readerIndex() - readerIndex - packetIdLength; UUID uuid = DefinedPacket.readUUID( packet ); - ProxiedPlayer player; + UserConnection player; if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) { int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength + idLength ); - DefinedPacket.writeUUID( player.getUniqueId(), packet ); + DefinedPacket.writeUUID( player.getRewriteId(), packet ); packet.writerIndex( previous ); } } else if ( packetId == 0x42 /* Combat Event */ ) @@ -158,7 +158,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int packetId = DefinedPacket.readVarInt( packet ); int packetIdLength = packet.readerIndex() - readerIndex; - if ( packetId == 0x18 /* Spectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + if ( packetId == 0x18 /* Spectate */ ) { UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player; @@ -167,7 +167,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength ); - DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet ); packet.writerIndex( previous ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java index d61dc0cbaf0..657e584612a 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java @@ -121,13 +121,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId) DefinedPacket.readVarInt( packet ); // Entity ID int idLength = packet.readerIndex() - readerIndex - packetIdLength; UUID uuid = DefinedPacket.readUUID( packet ); - ProxiedPlayer player; + UserConnection player; if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) { int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength + idLength ); - DefinedPacket.writeUUID( player.getUniqueId(), packet ); + DefinedPacket.writeUUID( player.getRewriteId(), packet ); packet.writerIndex( previous ); } break; @@ -164,7 +164,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int packetId = DefinedPacket.readVarInt( packet ); int packetIdLength = packet.readerIndex() - readerIndex; - if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ ) { UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player; @@ -173,7 +173,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength ); - DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet ); packet.writerIndex( previous ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java index bfbc84327c8..11d8e0e3383 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java @@ -121,13 +121,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId) DefinedPacket.readVarInt( packet ); // Entity ID int idLength = packet.readerIndex() - readerIndex - packetIdLength; UUID uuid = DefinedPacket.readUUID( packet ); - ProxiedPlayer player; + UserConnection player; if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) { int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength + idLength ); - DefinedPacket.writeUUID( player.getUniqueId(), packet ); + DefinedPacket.writeUUID( player.getRewriteId(), packet ); packet.writerIndex( previous ); } break; @@ -164,7 +164,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int packetId = DefinedPacket.readVarInt( packet ); int packetIdLength = packet.readerIndex() - readerIndex; - if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ ) { UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player; @@ -173,7 +173,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength ); - DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet ); packet.writerIndex( previous ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/tab/TabList.java b/proxy/src/main/java/net/md_5/bungee/tab/TabList.java index a0baa388447..a982655dd3b 100644 --- a/proxy/src/main/java/net/md_5/bungee/tab/TabList.java +++ b/proxy/src/main/java/net/md_5/bungee/tab/TabList.java @@ -46,7 +46,7 @@ public static PlayerListItemRemove rewrite(PlayerListItemRemove playerListItem) UserConnection player = BungeeCord.getInstance().getPlayerByOfflineUUID( playerListItem.getUuids()[i] ); if ( player != null ) { - playerListItem.getUuids()[i] = player.getUniqueId(); + playerListItem.getUuids()[i] = player.getRewriteId(); } } @@ -72,7 +72,7 @@ private static void rewrite(PlayerListItem.Item item) UserConnection player = BungeeCord.getInstance().getPlayerByOfflineUUID( item.getUuid() ); if ( player != null ) { - item.setUuid( player.getUniqueId() ); + item.setUuid( player.getRewriteId() ); if ( item.getProperties() != null ) {