From c8eb6aec7bac82fd309fa6d6113b8a0418317b01 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sat, 21 Jul 2018 18:13:02 +0100 Subject: [PATCH] Handle 1.13 scoreboard objectives/teams properly --- .../0048-1.13-protocol-support.patch | 87 ++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/BungeeCord-Patches/0048-1.13-protocol-support.patch b/BungeeCord-Patches/0048-1.13-protocol-support.patch index 17f7a20..da92eac 100644 --- a/BungeeCord-Patches/0048-1.13-protocol-support.patch +++ b/BungeeCord-Patches/0048-1.13-protocol-support.patch @@ -1,4 +1,4 @@ -From 1c6a8a78d2269b815bfc4b54cacea7f3f2054be8 Mon Sep 17 00:00:00 2001 +From 154cd2101ae0e8d48b7e1ff1878ab43242d48ace Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sat, 21 Jul 2018 17:14:39 +0100 Subject: [PATCH] 1.13 protocol support @@ -72,6 +72,91 @@ index bba6cb2d..b2dc9423 100644 public static final List SUPPORTED_VERSIONS = Arrays.asList( "1.8.x", "1.9.x", +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java +index 6279d9f3..edcc59a1 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java +@@ -1,5 +1,7 @@ + package net.md_5.bungee.protocol.packet; + ++import net.md_5.bungee.api.chat.TextComponent; // Waterfall - 1.13 ++import net.md_5.bungee.chat.ComponentSerializer; // Waterfall - 1.13 + import net.md_5.bungee.protocol.DefinedPacket; + import io.netty.buffer.ByteBuf; + import java.util.Locale; +@@ -35,9 +37,12 @@ public class ScoreboardObjective extends DefinedPacket + value = readString( buf ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) + { ++ String valueJson = readString( buf ); // Waterfall - 1.13 ++ value = TextComponent.toLegacyText(ComponentSerializer.parse(valueJson)); // Waterfall - 1.13 + type = HealthDisplay.values()[readVarInt( buf )]; + } else + { ++ value = readString( buf ); // Waterfall - 1.13 + type = HealthDisplay.fromString( readString( buf ) ); + } + } +@@ -50,12 +55,14 @@ public class ScoreboardObjective extends DefinedPacket + buf.writeByte( action ); + if ( action == 0 || action == 2 ) + { +- writeString( value, buf ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) + { ++ String valueJson = ComponentSerializer.toString(TextComponent.fromLegacyText(value)); // Waterfall - 1.13 ++ writeString( valueJson, buf ); // Waterfall - 1.13 + writeVarInt( type.ordinal(), buf ); + } else + { ++ writeString( value, buf ); // Waterfall - 1.13 + writeString( type.toString(), buf ); + } + } +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java +index f93508d9..4c6f15d9 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java +@@ -1,5 +1,7 @@ + package net.md_5.bungee.protocol.packet; + ++import net.md_5.bungee.api.chat.TextComponent; ++import net.md_5.bungee.chat.ComponentSerializer; + import net.md_5.bungee.protocol.DefinedPacket; + import io.netty.buffer.ByteBuf; + import lombok.AllArgsConstructor; +@@ -61,8 +63,12 @@ public class Team extends DefinedPacket + color = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? readVarInt( buf ) : buf.readByte(); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) + { +- prefix = readString( buf ); +- suffix = readString( buf ); ++ // Waterfall start - 1.13 ++ String prefixJson = readString( buf ); ++ String suffixJson = readString( buf ); ++ prefix = TextComponent.toLegacyText(ComponentSerializer.parse(prefixJson)); ++ suffix = TextComponent.toLegacyText(ComponentSerializer.parse(suffixJson)); ++ // Waterfall end + } + } + if ( mode == 0 || mode == 3 || mode == 4 ) +@@ -98,9 +104,14 @@ public class Team extends DefinedPacket + + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) + { ++ // Waterfall start - 1.13 ++ String prefixJson = ComponentSerializer.toString(TextComponent.fromLegacyText(prefix)); ++ String suffixJson = ComponentSerializer.toString(TextComponent.fromLegacyText(suffix)); ++ + writeVarInt( color, buf ); +- writeString( prefix, buf ); +- writeString( suffix, buf ); ++ writeString( prefixJson, buf ); ++ writeString( suffixJson, buf ); ++ // Waterfall end - 1.13 + } else + { + buf.writeByte( color ); -- 2.18.0