Drop 1.13 scoreboard api support

Upstream has seemingly decided that they have no
intent of providing proper support for the new scoreboard
changes inside of the bungee API, thus leading many plugins
to have already worked around this.

While having proper API support would be great, shamefully,
plugins which are already working around, which causes
incompatibilies with Waterfall.
This commit is contained in:
Shane Freeder 2018-07-25 19:10:26 +01:00
parent cc4457473d
commit e910db4871

View File

@ -1,161 +0,0 @@
From a25bca47d6013791dfb61366811c8546d8d86422 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sat, 21 Jul 2018 17:14:39 +0100
Subject: [PATCH] 1.13 scoreboard support
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java b/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java
index 10e16d79..f902301e 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java
@@ -5,6 +5,9 @@ import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
import lombok.RequiredArgsConstructor;
+import net.md_5.bungee.api.chat.BaseComponent; // Waterfall - 1.13
+import net.md_5.bungee.api.chat.TextComponent; // Waterfall - 1.13
+import net.md_5.bungee.chat.ComponentSerializer; // Waterfall - 1.13
import java.util.UUID;
@@ -183,6 +186,15 @@ public abstract class DefinedPacket
return new UUID( input.readLong(), input.readLong() );
}
+ // Waterfall start - 1.13
+ public static String readComponentAsString(ByteBuf buf)
+ {
+ String json = readString(buf);
+ BaseComponent[] components = ComponentSerializer.parse(json);
+ return components[0] == null ? json : TextComponent.toLegacyText(components);
+ }
+ // Waterfall end - 1.13
+
public void read(ByteBuf buf)
{
throw new UnsupportedOperationException( "Packet must implement read method" );
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..9f9c76fc 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,8 @@
package net.md_5.bungee.protocol.packet;
+import net.md_5.bungee.api.chat.BaseComponent;
+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;
@@ -32,12 +35,15 @@ public class ScoreboardObjective extends DefinedPacket
action = buf.readByte();
if ( action == 0 || action == 2 )
{
- value = readString( buf );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
{
+ // Waterfall start - 1.13
+ value = readComponentAsString(buf);
type = HealthDisplay.values()[readVarInt( buf )];
} else
{
+ value = readString(buf);
+ // Waterfall end
type = HealthDisplay.fromString( readString( buf ) );
}
}
@@ -50,12 +56,16 @@ public class ScoreboardObjective extends DefinedPacket
buf.writeByte( action );
if ( action == 0 || action == 2 )
{
- writeString( value, buf );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
{
+ // Waterfall start - 1.13
+ String valueJson = ComponentSerializer.toString(TextComponent.fromLegacyText(value));
+ writeString(valueJson, 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
index f93508d9..8be62c7b 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,8 @@
package net.md_5.bungee.protocol.packet;
+import net.md_5.bungee.api.chat.BaseComponent;
+import net.md_5.bungee.api.chat.TextComponent; // Waterfall
+import net.md_5.bungee.chat.ComponentSerializer; // Waterfall
import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
@@ -46,7 +49,13 @@ public class Team extends DefinedPacket
mode = buf.readByte();
if ( mode == 0 || mode == 2 )
{
- displayName = readString( buf );
+ // Waterfall start - 1.13
+ if (protocolVersion >= ProtocolConstants.MINECRAFT_1_13) {
+ displayName = readComponentAsString( buf );
+ } else {
+ displayName = readString( buf );
+ }
+ // Waterfall end
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 )
{
prefix = readString( buf );
@@ -61,8 +70,10 @@ 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
+ prefix = readComponentAsString( buf );
+ suffix = readComponentAsString( buf );
+ // Waterfall end
}
}
if ( mode == 0 || mode == 3 || mode == 4 )
@@ -83,7 +94,14 @@ public class Team extends DefinedPacket
buf.writeByte( mode );
if ( mode == 0 || mode == 2 )
{
- writeString( displayName, buf );
+ // Waterfall start - 1.13
+ if (protocolVersion >= ProtocolConstants.MINECRAFT_1_13) {
+ String displayNameJson = ComponentSerializer.toString(TextComponent.fromLegacyText(displayName));
+ writeString( displayNameJson, buf );
+ } else {
+ writeString( displayName, buf );
+ }
+ // Waterfall end - 1.13
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 )
{
writeString( prefix, buf );
@@ -98,9 +116,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