From 5a638f22902e920722283db73e1296e28121972e Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 16 Apr 2014 11:01:41 +1000 Subject: [PATCH] Enable 14w11 support, changing servers is a bit iffy though due to EntityMap not being complete. --- .../main/java/net/md_5/bungee/api/score/Objective.java | 6 +++++- api/src/main/java/net/md_5/bungee/api/score/Team.java | 2 ++ .../main/java/net/md_5/bungee/protocol/Protocol.java | 2 +- proxy/src/main/java/net/md_5/bungee/EntityMap.java | 2 +- .../net/md_5/bungee/connection/DownstreamBridge.java | 10 ++++++++-- .../net/md_5/bungee/connection/InitialHandler.java | 2 +- .../net/md_5/bungee/connection/UpstreamBridge.java | 6 +++++- 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/score/Objective.java b/api/src/main/java/net/md_5/bungee/api/score/Objective.java index 07a4d4a5..f1309fca 100644 --- a/api/src/main/java/net/md_5/bungee/api/score/Objective.java +++ b/api/src/main/java/net/md_5/bungee/api/score/Objective.java @@ -16,5 +16,9 @@ public class Objective /** * Value of the objective. */ - private final String value; // displayName + private final String value; + /** + * Type; integer or hearts + */ + private final String type; } diff --git a/api/src/main/java/net/md_5/bungee/api/score/Team.java b/api/src/main/java/net/md_5/bungee/api/score/Team.java index 6d9193f0..c60ed320 100644 --- a/api/src/main/java/net/md_5/bungee/api/score/Team.java +++ b/api/src/main/java/net/md_5/bungee/api/score/Team.java @@ -17,6 +17,8 @@ public class Team private String prefix; private String suffix; private byte friendlyFire; + private String unknown; + private byte unknown2; private Set players = new HashSet<>(); public Collection getPlayers() diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java index d6bd2746..fe1ae22b 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java @@ -94,7 +94,7 @@ public enum Protocol }; /*========================================================================*/ public static final int MAX_PACKET_ID = 0xFF; - public static List supportedVersions = Arrays.asList( ProtocolConstants.MINECRAFT_1_7_2, ProtocolConstants.MINECRAFT_1_7_6 ); + public static List supportedVersions = Arrays.asList( ProtocolConstants.MINECRAFT_1_7_2, ProtocolConstants.MINECRAFT_1_7_6, ProtocolConstants.MINECRAFT_14_11_a ); /*========================================================================*/ public final DirectionData TO_SERVER = new DirectionData( ProtocolConstants.Direction.TO_SERVER ); public final DirectionData TO_CLIENT = new DirectionData( ProtocolConstants.Direction.TO_CLIENT ); 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 4faad9ed..bc1b67ea 100644 --- a/proxy/src/main/java/net/md_5/bungee/EntityMap.java +++ b/proxy/src/main/java/net/md_5/bungee/EntityMap.java @@ -54,7 +54,7 @@ public class EntityMap serverboundInts[0x0A] = true; // Animation serverboundInts[0x0B] = true; // Entity Action - if ( version >= 7 ) + if ( version >= ProtocolConstants.MINECRAFT_14_11_a ) { migrateIntToVarint( clientboundInts, clientboundVarInts ); migrateIntToVarint( serverboundInts, serverboundVarInts ); diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java index 30255c05..4603d74e 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java @@ -24,6 +24,7 @@ import net.md_5.bungee.chat.ComponentSerializer; 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.PlayerListItem; import net.md_5.bungee.protocol.packet.ScoreboardObjective; @@ -85,7 +86,10 @@ public class DownstreamBridge extends PacketHandler { if ( !server.isObsolete() ) { - con.getEntityRewrite().rewriteClientbound( packet.buf, con.getServerEntityId(), con.getClientEntityId() ); + if ( con.getPendingConnection().getVersion() <= ProtocolConstants.MINECRAFT_1_7_6 ) + { + con.getEntityRewrite().rewriteClientbound( packet.buf, con.getServerEntityId(), con.getClientEntityId() ); + } con.sendPacket( packet ); } } @@ -114,7 +118,7 @@ public class DownstreamBridge extends PacketHandler switch ( objective.getAction() ) { case 0: - serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue() ) ); + serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue(), objective.getType() ) ); break; case 1: serverScoreboard.removeObjective( objective.getName() ); @@ -177,6 +181,8 @@ public class DownstreamBridge extends PacketHandler t.setPrefix( team.getPrefix() ); t.setSuffix( team.getSuffix() ); t.setFriendlyFire( team.getFriendlyFire() ); + t.setUnknown( team.getUnknown() ); + t.setUnknown2( team.getUnknown2() ); } if ( team.getPlayers() != null ) { 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 cc20cd7e..317e4983 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 @@ -383,7 +383,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection uniqueId = offlineId; } - if ( getVersion() == ProtocolConstants.MINECRAFT_1_7_6 ) + if ( getVersion() >= ProtocolConstants.MINECRAFT_1_7_6 ) { unsafe.sendPacket( new LoginSuccess( getUniqueId().toString(), getName() ) ); // With dashes in between } else 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 e5e402ff..6f721564 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 @@ -20,6 +20,7 @@ import net.md_5.bungee.protocol.packet.ClientSettings; import net.md_5.bungee.protocol.packet.PluginMessage; import java.util.ArrayList; import java.util.List; +import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.packet.TabCompleteResponse; public class UpstreamBridge extends PacketHandler @@ -62,7 +63,10 @@ public class UpstreamBridge extends PacketHandler @Override public void handle(PacketWrapper packet) throws Exception { - con.getEntityRewrite().rewriteServerbound( packet.buf, con.getClientEntityId(), con.getServerEntityId() ); + if ( con.getPendingConnection().getVersion() <= ProtocolConstants.MINECRAFT_1_7_6 ) + { + con.getEntityRewrite().rewriteServerbound( packet.buf, con.getClientEntityId(), con.getServerEntityId() ); + } if ( con.getServer() != null ) { con.getServer().getCh().write( packet );