Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Merge pull request #201 from VelocityPowered/text3
Bump text to 3.0.0
Dieser Commit ist enthalten in:
Commit
2bba87e8da
@ -18,7 +18,10 @@ sourceSets {
|
||||
dependencies {
|
||||
compile 'com.google.code.gson:gson:2.8.5'
|
||||
compile "com.google.guava:guava:${guavaVersion}"
|
||||
compile 'net.kyori:text:1.12-1.6.5'
|
||||
compile "net.kyori:text-api:${textVersion}"
|
||||
compile "net.kyori:text-serializer-gson:${textVersion}"
|
||||
compile "net.kyori:text-serializer-legacy:${textVersion}"
|
||||
compile "net.kyori:text-serializer-plain:${textVersion}"
|
||||
compile 'com.moandjiezana.toml:toml4j:0.7.2'
|
||||
compile "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||
compile 'com.google.inject:guice:4.2.0'
|
||||
|
@ -3,7 +3,7 @@ package com.velocitypowered.api.event;
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.Optional;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import net.kyori.text.serializer.plain.PlainComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
@ -102,7 +102,7 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
|
||||
return "allowed";
|
||||
}
|
||||
if (reason != null) {
|
||||
return "denied: " + ComponentSerializers.PLAIN.serialize(reason);
|
||||
return "denied: " + PlainComponentSerializer.INSTANCE.serialize(reason);
|
||||
}
|
||||
return "denied";
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ allprojects {
|
||||
|
||||
ext {
|
||||
// dependency versions
|
||||
textVersion = '3.0.0'
|
||||
junitVersion = '5.3.0-M1'
|
||||
slf4jVersion = '1.7.25'
|
||||
log4jVersion = '2.11.2'
|
||||
|
@ -60,7 +60,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.serializer.GsonComponentSerializer;
|
||||
import net.kyori.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
|
||||
@ -70,8 +70,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
public class VelocityServer implements ProxyServer {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(VelocityServer.class);
|
||||
public static final Gson GSON = new GsonBuilder()
|
||||
.registerTypeHierarchyAdapter(Component.class, new GsonComponentSerializer())
|
||||
public static final Gson GSON = GsonComponentSerializer.populate(new GsonBuilder())
|
||||
.registerTypeHierarchyAdapter(Favicon.class, new FaviconSerializer())
|
||||
.registerTypeHierarchyAdapter(GameProfile.class, new GameProfileSerializer())
|
||||
.create();
|
||||
|
@ -62,13 +62,13 @@ public class ServerCommand implements Command {
|
||||
String playersText = rs.getPlayersConnected().size() + " player(s) online";
|
||||
if (rs.getServerInfo().getName().equals(currentServer)) {
|
||||
infoComponent = infoComponent.color(TextColor.GREEN)
|
||||
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
TextComponent.of("Currently connected to this server\n" + playersText)));
|
||||
} else {
|
||||
infoComponent = infoComponent.color(TextColor.GRAY)
|
||||
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
.clickEvent(ClickEvent.runCommand(
|
||||
"/server " + rs.getServerInfo().getName()))
|
||||
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
TextComponent.of("Click to connect to this server\n" + playersText)));
|
||||
}
|
||||
serverListBuilder.append(infoComponent);
|
||||
|
@ -17,7 +17,6 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import net.kyori.text.Components;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.event.ClickEvent;
|
||||
import net.kyori.text.event.HoverEvent;
|
||||
@ -175,12 +174,12 @@ public class VelocityCommand implements Command {
|
||||
.append(TextComponent.builder("Velocity website")
|
||||
.color(TextColor.GREEN)
|
||||
.clickEvent(
|
||||
new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.velocitypowered.com"))
|
||||
ClickEvent.openUrl("https://www.velocitypowered.com"))
|
||||
.build())
|
||||
.append(TextComponent.of(" or the ").resetStyle())
|
||||
.append(TextComponent.of(" or the "))
|
||||
.append(TextComponent.builder("Velocity GitHub")
|
||||
.color(TextColor.GREEN)
|
||||
.clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,
|
||||
.clickEvent(ClickEvent.openUrl(
|
||||
"https://github.com/VelocityPowered/Velocity"))
|
||||
.build())
|
||||
.build();
|
||||
@ -237,11 +236,11 @@ public class VelocityCommand implements Command {
|
||||
TextComponent.Builder hoverText = TextComponent.builder(pluginInfo);
|
||||
|
||||
description.getUrl().ifPresent(url -> {
|
||||
hoverText.append(Components.newline());
|
||||
hoverText.append(TextComponent.newline());
|
||||
hoverText.append(TextComponent.of("Website: " + url));
|
||||
});
|
||||
if (!description.getAuthors().isEmpty()) {
|
||||
hoverText.append(Components.newline());
|
||||
hoverText.append(TextComponent.newline());
|
||||
if (description.getAuthors().size() == 1) {
|
||||
hoverText.append(TextComponent.of("Author: " + description.getAuthors().get(0)));
|
||||
} else {
|
||||
@ -250,13 +249,13 @@ public class VelocityCommand implements Command {
|
||||
}
|
||||
}
|
||||
description.getDescription().ifPresent(pdesc -> {
|
||||
hoverText.append(Components.newline());
|
||||
hoverText.append(Components.newline());
|
||||
hoverText.append(TextComponent.newline());
|
||||
hoverText.append(TextComponent.newline());
|
||||
hoverText.append(TextComponent.of(pdesc));
|
||||
});
|
||||
|
||||
return TextComponent.of(description.getId(), TextColor.GRAY)
|
||||
.hoverEvent(new HoverEvent(Action.SHOW_TEXT, hoverText.build()));
|
||||
.hoverEvent(HoverEvent.showText(hoverText.build()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,7 +22,8 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import net.kyori.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@ -278,9 +279,9 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi
|
||||
public Component getMotdComponent() {
|
||||
if (motdAsComponent == null) {
|
||||
if (motd.startsWith("{")) {
|
||||
motdAsComponent = ComponentSerializers.JSON.deserialize(motd);
|
||||
motdAsComponent = GsonComponentSerializer.INSTANCE.deserialize(motd);
|
||||
} else {
|
||||
motdAsComponent = ComponentSerializers.LEGACY.deserialize(motd, '&');
|
||||
motdAsComponent = LegacyComponentSerializer.INSTANCE.deserialize(motd, '&');
|
||||
}
|
||||
}
|
||||
return motdAsComponent;
|
||||
|
@ -58,8 +58,9 @@ import net.kyori.text.Component;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.TranslatableComponent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import net.kyori.text.serializer.PlainComponentSerializer;
|
||||
import net.kyori.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.text.serializer.plain.PlainComponentSerializer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@ -190,18 +191,18 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
// We can use the title packet instead.
|
||||
TitlePacket pkt = new TitlePacket();
|
||||
pkt.setAction(TitlePacket.SET_ACTION_BAR);
|
||||
pkt.setComponent(ComponentSerializers.JSON.serialize(component));
|
||||
pkt.setComponent(GsonComponentSerializer.INSTANCE.serialize(component));
|
||||
minecraftConnection.write(pkt);
|
||||
return;
|
||||
} else {
|
||||
// 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!
|
||||
JsonObject object = new JsonObject();
|
||||
object.addProperty("text", ComponentSerializers.LEGACY.serialize(component));
|
||||
object.addProperty("text", LegacyComponentSerializer.INSTANCE.serialize(component));
|
||||
json = object.toString();
|
||||
}
|
||||
} else {
|
||||
json = ComponentSerializers.JSON.serialize(component);
|
||||
json = GsonComponentSerializer.INSTANCE.serialize(component);
|
||||
}
|
||||
|
||||
Chat chat = new Chat();
|
||||
@ -242,7 +243,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
|
||||
@Override
|
||||
public void disconnect(Component reason) {
|
||||
logger.info("{} has disconnected: {}", this, ComponentSerializers.LEGACY.serialize(reason));
|
||||
logger.info("{} has disconnected: {}", this,
|
||||
LegacyComponentSerializer.INSTANCE.serialize(reason));
|
||||
minecraftConnection.closeWith(Disconnect.create(reason));
|
||||
}
|
||||
|
||||
@ -266,7 +268,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
if (titleText.isPresent()) {
|
||||
TitlePacket titlePkt = new TitlePacket();
|
||||
titlePkt.setAction(TitlePacket.SET_TITLE);
|
||||
titlePkt.setComponent(ComponentSerializers.JSON.serialize(titleText.get()));
|
||||
titlePkt.setComponent(GsonComponentSerializer.INSTANCE.serialize(titleText.get()));
|
||||
minecraftConnection.delayedWrite(titlePkt);
|
||||
}
|
||||
|
||||
@ -274,7 +276,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
if (subtitleText.isPresent()) {
|
||||
TitlePacket titlePkt = new TitlePacket();
|
||||
titlePkt.setAction(TitlePacket.SET_SUBTITLE);
|
||||
titlePkt.setComponent(ComponentSerializers.JSON.serialize(subtitleText.get()));
|
||||
titlePkt.setComponent(GsonComponentSerializer.INSTANCE.serialize(subtitleText.get()));
|
||||
minecraftConnection.delayedWrite(titlePkt);
|
||||
}
|
||||
|
||||
@ -354,7 +356,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
return;
|
||||
}
|
||||
|
||||
Component disconnectReason = ComponentSerializers.JSON.deserialize(disconnect.getReason());
|
||||
Component disconnectReason = GsonComponentSerializer.INSTANCE.deserialize(
|
||||
disconnect.getReason());
|
||||
String plainTextReason = PASS_THRU_TRANSLATE.serialize(disconnectReason);
|
||||
if (connectedServer != null && connectedServer.getServerInfo().equals(server.getServerInfo())) {
|
||||
logger.error("{}: kicked from server {}: {}", this, server.getServerInfo().getName(),
|
||||
|
@ -9,7 +9,7 @@ import com.velocitypowered.proxy.protocol.packet.Handshake;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Optional;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -54,7 +54,8 @@ class InitialInboundConnection implements InboundConnection, MinecraftConnection
|
||||
}
|
||||
|
||||
public void disconnect(Component reason) {
|
||||
logger.info("{} has disconnected: {}", this, ComponentSerializers.LEGACY.serialize(reason));
|
||||
logger.info("{} has disconnected: {}", this,
|
||||
LegacyComponentSerializer.INSTANCE.serialize(reason));
|
||||
connection.closeWith(Disconnect.create(reason));
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import net.kyori.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
public class ConnectionRequestResults {
|
||||
|
||||
@ -43,12 +43,12 @@ public class ConnectionRequestResults {
|
||||
}
|
||||
|
||||
public static Impl forDisconnect(Disconnect disconnect, RegisteredServer server) {
|
||||
Component deserialized = ComponentSerializers.JSON.deserialize(disconnect.getReason());
|
||||
Component deserialized = GsonComponentSerializer.INSTANCE.deserialize(disconnect.getReason());
|
||||
return forDisconnect(deserialized, server);
|
||||
}
|
||||
|
||||
public static Impl forUnsafeDisconnect(Disconnect disconnect, RegisteredServer server) {
|
||||
Component deserialized = ComponentSerializers.JSON.deserialize(disconnect.getReason());
|
||||
Component deserialized = GsonComponentSerializer.INSTANCE.deserialize(disconnect.getReason());
|
||||
return new Impl(Status.SERVER_DISCONNECTED, deserialized, server, false);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.minecrell.terminalconsole.SimpleTerminalConsole;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -35,7 +35,7 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
|
||||
|
||||
@Override
|
||||
public void sendMessage(Component component) {
|
||||
logger.info(ComponentSerializers.LEGACY.serialize(component));
|
||||
logger.info(LegacyComponentSerializer.INSTANCE.serialize(component));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,7 +27,7 @@ import java.util.Set;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import net.kyori.text.serializer.plain.PlainComponentSerializer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@ -71,7 +71,7 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
|
||||
|
||||
private QueryResponse createInitialResponse() {
|
||||
return QueryResponse.builder()
|
||||
.hostname(ComponentSerializers.PLAIN
|
||||
.hostname(PlainComponentSerializer.INSTANCE
|
||||
.serialize(server.getConfiguration().getMotdComponent()))
|
||||
.gameVersion(ProtocolVersion.SUPPORTED_VERSION_STRING)
|
||||
.map(server.getConfiguration().getQueryMap())
|
||||
|
@ -7,7 +7,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import net.kyori.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class Chat implements MinecraftPacket {
|
||||
@ -83,7 +83,7 @@ public class Chat implements MinecraftPacket {
|
||||
|
||||
public static Chat createClientbound(Component component, byte type) {
|
||||
Preconditions.checkNotNull(component, "component");
|
||||
return new Chat(ComponentSerializers.JSON.serialize(component), type);
|
||||
return new Chat(GsonComponentSerializer.INSTANCE.serialize(component), type);
|
||||
}
|
||||
|
||||
public static Chat createServerbound(String message) {
|
||||
|
@ -7,7 +7,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import net.kyori.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class Disconnect implements MinecraftPacket {
|
||||
@ -59,6 +59,6 @@ public class Disconnect implements MinecraftPacket {
|
||||
|
||||
public static Disconnect create(Component component) {
|
||||
Preconditions.checkNotNull(component, "component");
|
||||
return new Disconnect(ComponentSerializers.JSON.serialize(component));
|
||||
return new Disconnect(GsonComponentSerializer.INSTANCE.serialize(component));
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.serializer.ComponentSerializer;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import net.kyori.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
public class HeaderAndFooter implements MinecraftPacket {
|
||||
|
||||
@ -54,7 +54,7 @@ public class HeaderAndFooter implements MinecraftPacket {
|
||||
}
|
||||
|
||||
public static HeaderAndFooter create(Component header, Component footer) {
|
||||
ComponentSerializer<Component, Component, String> json = ComponentSerializers.JSON;
|
||||
ComponentSerializer<Component, Component, String> json = GsonComponentSerializer.INSTANCE;
|
||||
return new HeaderAndFooter(json.serialize(header), json.serialize(footer));
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,12 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
|
||||
import static net.kyori.text.serializer.ComponentSerializers.LEGACY;
|
||||
import static net.kyori.text.serializer.ComponentSerializers.PLAIN;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing.Players;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacyping.LegacyMinecraftPingVersion;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.text.serializer.plain.PlainComponentSerializer;
|
||||
|
||||
public class LegacyDisconnect {
|
||||
|
||||
@ -39,7 +37,7 @@ public class LegacyDisconnect {
|
||||
// remove all section symbols, along with fetching just the first line of an (unformatted)
|
||||
// MOTD.
|
||||
return new LegacyDisconnect(String.join(LEGACY_COLOR_CODE,
|
||||
cleanSectionSymbol(getFirstLine(PLAIN.serialize(response.getDescription()))),
|
||||
cleanSectionSymbol(getFirstLine(PlainComponentSerializer.INSTANCE.serialize(response.getDescription()))),
|
||||
Integer.toString(players.getOnline()),
|
||||
Integer.toString(players.getMax())));
|
||||
case MINECRAFT_1_4:
|
||||
@ -49,7 +47,7 @@ public class LegacyDisconnect {
|
||||
LEGACY_COLOR_CODE + "1",
|
||||
Integer.toString(response.getVersion().getProtocol()),
|
||||
response.getVersion().getName(),
|
||||
getFirstLine(LEGACY.serialize(response.getDescription())),
|
||||
getFirstLine(LegacyComponentSerializer.INSTANCE.serialize(response.getDescription())),
|
||||
Integer.toString(players.getOnline()),
|
||||
Integer.toString(players.getMax())
|
||||
));
|
||||
@ -75,7 +73,7 @@ public class LegacyDisconnect {
|
||||
public static LegacyDisconnect from(TextComponent component) {
|
||||
// We intentionally use the legacy serializers, because the old clients can't understand JSON.
|
||||
@SuppressWarnings("deprecation")
|
||||
String serialized = ComponentSerializers.LEGACY.serialize(component);
|
||||
String serialized = LegacyComponentSerializer.INSTANCE.serialize(component);
|
||||
return new LegacyDisconnect(serialized);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import net.kyori.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class PlayerListItem implements MinecraftPacket {
|
||||
@ -77,7 +77,7 @@ public class PlayerListItem implements MinecraftPacket {
|
||||
|
||||
private static @Nullable Component readOptionalComponent(ByteBuf buf) {
|
||||
if (buf.readBoolean()) {
|
||||
return ComponentSerializers.JSON.deserialize(ProtocolUtils.readString(buf));
|
||||
return GsonComponentSerializer.INSTANCE.deserialize(ProtocolUtils.readString(buf));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -123,7 +123,7 @@ public class PlayerListItem implements MinecraftPacket {
|
||||
private void writeDisplayName(ByteBuf buf, @Nullable Component displayName) {
|
||||
buf.writeBoolean(displayName != null);
|
||||
if (displayName != null) {
|
||||
ProtocolUtils.writeString(buf, ComponentSerializers.JSON.serialize(displayName));
|
||||
ProtocolUtils.writeString(buf, GsonComponentSerializer.INSTANCE.serialize(displayName));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import net.kyori.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class TabCompleteResponse implements MinecraftPacket {
|
||||
@ -68,7 +68,7 @@ public class TabCompleteResponse implements MinecraftPacket {
|
||||
int offersAvailable = ProtocolUtils.readVarInt(buf);
|
||||
for (int i = 0; i < offersAvailable; i++) {
|
||||
String offer = ProtocolUtils.readString(buf);
|
||||
Component tooltip = buf.readBoolean() ? ComponentSerializers.JSON.deserialize(
|
||||
Component tooltip = buf.readBoolean() ? GsonComponentSerializer.INSTANCE.deserialize(
|
||||
ProtocolUtils.readString(buf)) : null;
|
||||
offers.add(new Offer(offer, tooltip));
|
||||
}
|
||||
@ -91,7 +91,7 @@ public class TabCompleteResponse implements MinecraftPacket {
|
||||
ProtocolUtils.writeString(buf, offer.text);
|
||||
buf.writeBoolean(offer.tooltip != null);
|
||||
if (offer.tooltip != null) {
|
||||
ProtocolUtils.writeString(buf, ComponentSerializers.JSON.serialize(offer.tooltip));
|
||||
ProtocolUtils.writeString(buf, GsonComponentSerializer.INSTANCE.serialize(offer.tooltip));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren