Fix 1.7.7 support

This commit is contained in:
Thinkofdeath 2014-04-10 13:34:08 +01:00
parent 747628f40c
commit 153bca00be
5 changed files with 41 additions and 52 deletions

View File

@ -105,11 +105,6 @@ public class BungeeCord extends ProxyServer
*/ */
private final Map<String, UserConnection> connections = new CaseInsensitiveMap<>(); private final Map<String, UserConnection> connections = new CaseInsensitiveMap<>();
private final ReadWriteLock connectionLock = new ReentrantReadWriteLock(); private final ReadWriteLock connectionLock = new ReentrantReadWriteLock();
/**
* Skin support for servers that don't support ip-forwarding
*/
private final Map<String, String> uuidMap = new HashMap<>();
private final ReadWriteLock uuidLock = new ReentrantReadWriteLock();
/** /**
* Plugin manager. * 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 @Override
public CustomTabList customTabList(ProxiedPlayer player) public CustomTabList customTabList(ProxiedPlayer player)
{ {

View File

@ -1,8 +1,10 @@
package net.md_5.bungee; package net.md_5.bungee;
import io.netty.buffer.ByteBuf; 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.DefinedPacket;
import net.md_5.bungee.protocol.packet.LoginRequest;
/** /**
* Class to rewrite integers within packets. * Class to rewrite integers within packets.
@ -146,15 +148,32 @@ public class EntityMap
DefinedPacket.readVarInt( packet ); DefinedPacket.readVarInt( packet );
int idLength = packet.readerIndex() - readerIndex - packetIdLength; int idLength = packet.readerIndex() - readerIndex - packetIdLength;
String uuid = DefinedPacket.readString( packet ); String uuid = DefinedPacket.readString( packet );
if ( uuid.length() == 36 ) { String username = DefinedPacket.readString( packet );
String actualUUID = BungeeCord.getInstance().getActualUUID( uuid ); int props = DefinedPacket.readVarInt( packet );
if ( actualUUID != null ) if ( props == 0 )
{ {
UserConnection player = (UserConnection) BungeeCord.getInstance().getPlayer( username );
if ( player != null )
{
LoginResult profile = player.getPendingConnection().getLoginProfile();
if ( profile != null && profile.getProperties() != null
&& profile.getProperties().length >= 1 )
{
ByteBuf rest = packet.slice().copy();
packet.readerIndex( readerIndex ); packet.readerIndex( readerIndex );
int writerIndex = packet.writerIndex();
packet.writerIndex( readerIndex + packetIdLength + idLength ); packet.writerIndex( readerIndex + packetIdLength + idLength );
DefinedPacket.writeString( actualUUID, packet ); DefinedPacket.writeString( player.getUniqueId().toString(), packet );
packet.writerIndex( writerIndex ); 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();
}
} }
} }
} }

View File

@ -87,6 +87,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
private UUID uniqueId; private UUID uniqueId;
@Getter @Getter
private UUID offlineId; private UUID offlineId;
@Getter
private LoginResult loginProfile;
private enum State private enum State
{ {
@ -326,6 +328,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
LoginResult obj = BungeeCord.getInstance().gson.fromJson( result, LoginResult.class ); LoginResult obj = BungeeCord.getInstance().gson.fromJson( result, LoginResult.class );
if ( obj != null ) if ( obj != null )
{ {
loginProfile = obj;
uniqueId = Util.getUUID( obj.getId() ); uniqueId = Util.getUUID( obj.getId() );
finish(); finish();
return; return;
@ -377,7 +380,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{ {
uniqueId = offlineId; 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. // Version 5 == 1.7.6. This is a screwup as 1.7.6 was also a snapshot.
if ( getVersion() == 5 ) if ( getVersion() == 5 )
{ {

View File

@ -9,4 +9,14 @@ public class LoginResult
{ {
private String id; private String id;
private Property[] properties;
@Data
@AllArgsConstructor
public static class Property {
private String name;
private String value;
private String signature;
}
} }

View File

@ -52,7 +52,6 @@ public class UpstreamBridge extends PacketHandler
bungee.getPluginManager().callEvent( event ); bungee.getPluginManager().callEvent( event );
con.getTabList().onDisconnect(); con.getTabList().onDisconnect();
BungeeCord.getInstance().removeConnection( con ); BungeeCord.getInstance().removeConnection( con );
BungeeCord.getInstance().removeUUID( con.getPendingConnection().getOfflineId().toString() );
if ( con.getServer() != null ) if ( con.getServer() != null )
{ {