3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Yet another breaking change in the Adventure API

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-07-22 11:18:46 -04:00
Ursprung bf0ae6b856
Commit f34b5ac2fc
6 geänderte Dateien mit 10 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -138,7 +138,7 @@ class BungeeCordMessageResponder {
} }
private void processMessage(ByteBufDataInput in) { private void processMessage(ByteBufDataInput in) {
processMessage0(in, LegacyComponentSerializer.legacy()); processMessage0(in, LegacyComponentSerializer.legacySection());
} }
private void processMessageRaw(ByteBufDataInput in) { private void processMessageRaw(ByteBufDataInput in) {
@ -210,7 +210,7 @@ class BungeeCordMessageResponder {
private void processKick(ByteBufDataInput in) { private void processKick(ByteBufDataInput in) {
proxy.getPlayer(in.readUTF()).ifPresent(player -> { proxy.getPlayer(in.readUTF()).ifPresent(player -> {
String kickReason = in.readUTF(); String kickReason = in.readUTF();
player.disconnect(LegacyComponentSerializer.legacy().deserialize(kickReason)); player.disconnect(LegacyComponentSerializer.legacySection().deserialize(kickReason));
}); });
} }

Datei anzeigen

@ -273,7 +273,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
// Due to issues with action bar packets, we'll need to convert the text message into a // Due to issues with action bar packets, we'll need to convert the text message into a
// legacy message and then inject the legacy text into a component... yuck! // legacy message and then inject the legacy text into a component... yuck!
JsonObject object = new JsonObject(); JsonObject object = new JsonObject();
object.addProperty("text", LegacyComponentSerializer.legacy().serialize(message)); object.addProperty("text", LegacyComponentSerializer.legacySection().serialize(message));
Chat chat = new Chat(); Chat chat = new Chat();
chat.setMessage(object.toString()); chat.setMessage(object.toString());
chat.setType((byte) 1); chat.setType((byte) 1);
@ -391,7 +391,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
*/ */
public void disconnect0(Component reason, boolean duringLogin) { public void disconnect0(Component reason, boolean duringLogin) {
logger.info("{} has disconnected: {}", this, logger.info("{} has disconnected: {}", this,
LegacyComponentSerializer.legacy().serialize(reason)); LegacyComponentSerializer.legacySection().serialize(reason));
connection.closeWith(Disconnect.create(reason, this.getProtocolVersion())); connection.closeWith(Disconnect.create(reason, this.getProtocolVersion()));
} }

Datei anzeigen

@ -60,7 +60,7 @@ public final class InitialInboundConnection implements InboundConnection,
*/ */
public void disconnect(Component reason) { public void disconnect(Component reason) {
logger.info("{} has disconnected: {}", this, logger.info("{} has disconnected: {}", this,
LegacyComponentSerializer.legacy().serialize(reason)); LegacyComponentSerializer.legacySection().serialize(reason));
connection.closeWith(Disconnect.create(reason, getProtocolVersion())); connection.closeWith(Disconnect.create(reason, getProtocolVersion()));
} }

Datei anzeigen

@ -39,7 +39,7 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
@Override @Override
public void sendMessage(net.kyori.adventure.text.@NonNull Component message) { public void sendMessage(net.kyori.adventure.text.@NonNull Component message) {
logger.info(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacy() logger.info(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()
.serialize(message)); .serialize(message));
} }

Datei anzeigen

@ -48,7 +48,7 @@ public class LegacyDisconnect {
LEGACY_COLOR_CODE + "1", LEGACY_COLOR_CODE + "1",
Integer.toString(response.getVersion().getProtocol()), Integer.toString(response.getVersion().getProtocol()),
response.getVersion().getName(), response.getVersion().getName(),
getFirstLine(LegacyComponentSerializer.legacy().serialize(response getFirstLine(LegacyComponentSerializer.legacySection().serialize(response
.getDescriptionComponent())), .getDescriptionComponent())),
Integer.toString(players.getOnline()), Integer.toString(players.getOnline()),
Integer.toString(players.getMax()) Integer.toString(players.getMax())
@ -74,7 +74,7 @@ public class LegacyDisconnect {
*/ */
public static LegacyDisconnect from(TextComponent component) { public static LegacyDisconnect from(TextComponent component) {
// We intentionally use the legacy serializers, because the old clients can't understand JSON. // We intentionally use the legacy serializers, because the old clients can't understand JSON.
String serialized = LegacyComponentSerializer.legacy().serialize(component); String serialized = LegacyComponentSerializer.legacySection().serialize(component);
return new LegacyDisconnect(serialized); return new LegacyDisconnect(serialized);
} }

Datei anzeigen

@ -127,7 +127,8 @@ public class PlayerListItem implements MinecraftPacket {
} else { } else {
Item item = items.get(0); Item item = items.get(0);
if (item.getDisplayName() != null) { if (item.getDisplayName() != null) {
String displayName = LegacyComponentSerializer.legacy().serialize(item.getDisplayName()); String displayName = LegacyComponentSerializer.legacySection()
.serialize(item.getDisplayName());
ProtocolUtils.writeString(buf, ProtocolUtils.writeString(buf,
displayName.length() > 16 ? displayName.substring(0, 16) : displayName); displayName.length() > 16 ? displayName.substring(0, 16) : displayName);
} else { } else {