More scoreboard fixes

This commit is contained in:
Shane Freeder 2018-07-22 01:27:47 +01:00
parent d12ec7493c
commit d1b91271e0

View File

@ -1,4 +1,4 @@
From c99bbab386d19267a2b6b23d9d380006845b9745 Mon Sep 17 00:00:00 2001 From 21ac4d87d54a63506f190bc9f7e49b6d6595534a Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com> From: Shane Freeder <theboyetronic@gmail.com>
Date: Sat, 21 Jul 2018 17:14:39 +0100 Date: Sat, 21 Jul 2018 17:14:39 +0100
Subject: [PATCH] 1.13 protocol support Subject: [PATCH] 1.13 protocol support
@ -73,7 +73,7 @@ index bba6cb2d..b2dc9423 100644
"1.8.x", "1.8.x",
"1.9.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 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..b0dcf0ac 100644 index 6279d9f3..f1ad722d 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java --- 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 +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java
@@ -1,5 +1,8 @@ @@ -1,5 +1,8 @@
@ -85,54 +85,51 @@ index 6279d9f3..b0dcf0ac 100644
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import java.util.Locale; import java.util.Locale;
@@ -28,8 +31,16 @@ public class ScoreboardObjective extends DefinedPacket @@ -32,12 +35,16 @@ public class ScoreboardObjective extends DefinedPacket
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
- name = readString( buf );
+
+ if (protocolVersion <= ProtocolConstants.MINECRAFT_1_13) {
+ String jsonName = readString(buf);
+ name = TextComponent.toLegacyText(ComponentSerializer.parse(jsonName));
+ }else {
+ name = readString( buf );
+ }
+
action = buf.readByte(); action = buf.readByte();
+
if ( action == 0 || action == 2 ) if ( action == 0 || action == 2 )
{ {
value = readString( buf ); - value = readString( buf );
@@ -46,11 +57,18 @@ public class ScoreboardObjective extends DefinedPacket if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
@Override {
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + // Waterfall start - 1.13
{ + String jsonName = readString(buf);
- writeString( name, buf ); + name = TextComponent.toLegacyText(ComponentSerializer.parse(jsonName));
+ // Waterfall start - 1.13 type = HealthDisplay.values()[readVarInt( buf )];
+ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) } else
+ { {
+ String nameJson = ComponentSerializer.toString(TextComponent.fromLegacyText(name)); // Waterfall - 1.13 + value = readString(buf);
+ writeString( nameJson, buf ); + // Waterfall end
+ } else type = HealthDisplay.fromString( readString( buf ) );
+ { }
+ writeString( name, buf ); }
+ } @@ -50,12 +57,16 @@ public class ScoreboardObjective extends DefinedPacket
buf.writeByte( action ); buf.writeByte( action );
if ( action == 0 || action == 2 ) if ( action == 0 || action == 2 )
{ {
- writeString( value, buf ); - writeString( value, buf );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
{ {
+ // Waterfall start - 1.13
+ String valueJson = ComponentSerializer.toString(TextComponent.fromLegacyText(value));
+ writeString(valueJson, buf);
writeVarInt( type.ordinal(), buf ); writeVarInt( type.ordinal(), buf );
} else
{
+ writeString(value, buf);
+ // Waterfall end
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 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..bb4f699b 100644 index f93508d9..19d0d2d9 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java --- 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 +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java
@@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
package net.md_5.bungee.protocol.packet; package net.md_5.bungee.protocol.packet;
+import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.chat.TextComponent; // Waterfall
+import net.md_5.bungee.chat.ComponentSerializer; +import net.md_5.bungee.chat.ComponentSerializer; // Waterfall
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;