From 153bca00be22c10f7e69cae518c96fd20360b1b9 Mon Sep 17 00:00:00 2001 From: Thinkofdeath Date: Thu, 10 Apr 2014 13:34:08 +0100 Subject: [PATCH] Fix 1.7.7 support --- .../main/java/net/md_5/bungee/BungeeCord.java | 41 ------------------- .../main/java/net/md_5/bungee/EntityMap.java | 37 +++++++++++++---- .../bungee/connection/InitialHandler.java | 4 +- .../md_5/bungee/connection/LoginResult.java | 10 +++++ .../bungee/connection/UpstreamBridge.java | 1 - 5 files changed, 41 insertions(+), 52 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index d8993b2e..13d84250 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -105,11 +105,6 @@ public class BungeeCord extends ProxyServer */ private final Map connections = new CaseInsensitiveMap<>(); private final ReadWriteLock connectionLock = new ReentrantReadWriteLock(); - /** - * Skin support for servers that don't support ip-forwarding - */ - private final Map uuidMap = new HashMap<>(); - private final ReadWriteLock uuidLock = new ReentrantReadWriteLock(); /** * Plugin manager. */ @@ -550,42 +545,6 @@ public class BungeeCord extends ProxyServer } } - public void addUUID(String offlineUUID, String actualUUID) - { - uuidLock.writeLock().lock(); - try - { - uuidMap.put( offlineUUID, actualUUID ); - } finally - { - uuidLock.writeLock().unlock(); - } - } - - public void removeUUID(String offlineUUID) - { - uuidLock.writeLock().lock(); - try - { - uuidMap.remove( offlineUUID ); - } finally - { - uuidLock.writeLock().unlock(); - } - } - - public String getActualUUID(String offlineUUID) - { - uuidLock.readLock().lock(); - try - { - return uuidMap.get( offlineUUID ); - } finally - { - uuidLock.readLock().unlock(); - } - } - @Override public CustomTabList customTabList(ProxiedPlayer player) { diff --git a/proxy/src/main/java/net/md_5/bungee/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/EntityMap.java index bdeb728d..46f9376e 100644 --- a/proxy/src/main/java/net/md_5/bungee/EntityMap.java +++ b/proxy/src/main/java/net/md_5/bungee/EntityMap.java @@ -1,8 +1,10 @@ package net.md_5.bungee; import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.connection.LoginResult; import net.md_5.bungee.protocol.DefinedPacket; +import net.md_5.bungee.protocol.packet.LoginRequest; /** * Class to rewrite integers within packets. @@ -146,15 +148,32 @@ public class EntityMap DefinedPacket.readVarInt( packet ); int idLength = packet.readerIndex() - readerIndex - packetIdLength; String uuid = DefinedPacket.readString( packet ); - if ( uuid.length() == 36 ) { - String actualUUID = BungeeCord.getInstance().getActualUUID( uuid ); - if ( actualUUID != null ) + String username = DefinedPacket.readString( packet ); + int props = DefinedPacket.readVarInt( packet ); + if ( props == 0 ) + { + UserConnection player = (UserConnection) BungeeCord.getInstance().getPlayer( username ); + if ( player != null ) { - packet.readerIndex( readerIndex ); - int writerIndex = packet.writerIndex(); - packet.writerIndex( readerIndex + packetIdLength + idLength ); - DefinedPacket.writeString( actualUUID, packet ); - packet.writerIndex( writerIndex ); + LoginResult profile = player.getPendingConnection().getLoginProfile(); + if ( profile != null && profile.getProperties() != null + && profile.getProperties().length >= 1 ) + { + ByteBuf rest = packet.slice().copy(); + packet.readerIndex( readerIndex ); + packet.writerIndex( readerIndex + packetIdLength + idLength ); + DefinedPacket.writeString( player.getUniqueId().toString(), packet ); + DefinedPacket.writeString( username, packet); + DefinedPacket.writeVarInt( profile.getProperties().length, packet ); + for ( LoginResult.Property property : profile.getProperties() ) + { + DefinedPacket.writeString( property.getName(), packet ); + DefinedPacket.writeString( property.getValue(), packet ); + DefinedPacket.writeString( property.getSignature(), packet ); + } + packet.writeBytes( rest ); + rest.release(); + } } } } 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 d41dbf0d..5557ad90 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 @@ -87,6 +87,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection private UUID uniqueId; @Getter private UUID offlineId; + @Getter + private LoginResult loginProfile; private enum State { @@ -326,6 +328,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection LoginResult obj = BungeeCord.getInstance().gson.fromJson( result, LoginResult.class ); if ( obj != null ) { + loginProfile = obj; uniqueId = Util.getUUID( obj.getId() ); finish(); return; @@ -377,7 +380,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection { uniqueId = offlineId; } - BungeeCord.getInstance().addUUID( offlineId.toString(), uniqueId.toString() ); // Version 5 == 1.7.6. This is a screwup as 1.7.6 was also a snapshot. if ( getVersion() == 5 ) { diff --git a/proxy/src/main/java/net/md_5/bungee/connection/LoginResult.java b/proxy/src/main/java/net/md_5/bungee/connection/LoginResult.java index e0b4060c..e2bbb580 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/LoginResult.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/LoginResult.java @@ -9,4 +9,14 @@ public class LoginResult { private String id; + private Property[] properties; + + @Data + @AllArgsConstructor + public static class Property { + + private String name; + private String value; + private String signature; + } } 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 42882fc5..e5e402ff 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 @@ -52,7 +52,6 @@ public class UpstreamBridge extends PacketHandler bungee.getPluginManager().callEvent( event ); con.getTabList().onDisconnect(); BungeeCord.getInstance().removeConnection( con ); - BungeeCord.getInstance().removeUUID( con.getPendingConnection().getOfflineId().toString() ); if ( con.getServer() != null ) {