From cc6546bea9783eb5a1672e2c936ccf6ab819e5d8 Mon Sep 17 00:00:00 2001 From: Riley Park Date: Mon, 28 Sep 2020 05:30:33 -0700 Subject: [PATCH] Update for Adventure changes --- .../velocitypowered/proxy/VelocityServer.java | 8 +-- .../proxy/command/VelocityCommandManager.java | 3 +- .../proxy/command/builtin/GlistCommand.java | 24 +++++---- .../proxy/command/builtin/ServerCommand.java | 19 +++---- .../command/builtin/VelocityCommand.java | 51 ++++++++++--------- .../backend/LoginSessionHandler.java | 5 +- .../client/ClientPlaySessionHandler.java | 4 +- .../connection/client/ConnectedPlayer.java | 6 +-- .../client/HandshakeSessionHandler.java | 9 ++-- .../connection/util/ConnectionMessages.java | 13 ++--- .../VelocityLegacyHoverEventSerializer.java | 12 ++--- 11 files changed, 81 insertions(+), 73 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index a641acfb1..6fa6223ae 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -344,14 +344,14 @@ public class VelocityServer implements ProxyServer, ForwardingAudience { player.createConnectionRequest(next.get()).connectWithIndication() .whenComplete((success, ex) -> { if (ex != null || success == null || !success) { - player.disconnect(TextComponent.of("Your server has been changed, but we could " + player.disconnect(Component.text("Your server has been changed, but we could " + "not move you to any fallback servers.")); } latch.countDown(); }); } else { latch.countDown(); - player.disconnect(TextComponent.of("Your server has been changed, but we could " + player.disconnect(Component.text("Your server has been changed, but we could " + "not move you to any fallback servers.")); } } @@ -466,7 +466,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience { * @param explicitExit whether the user explicitly shut down the proxy */ public void shutdown(boolean explicitExit) { - shutdown(explicitExit, TextComponent.of("Proxy shutting down.")); + shutdown(explicitExit, Component.text("Proxy shutting down.")); } @Override @@ -520,7 +520,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience { } else { ConnectedPlayer existing = connectionsByUuid.get(connection.getUniqueId()); if (existing != null) { - existing.disconnect(TranslatableComponent.of("multiplayer.disconnect.duplicate_login")); + existing.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login")); } // We can now replace the entries as needed. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java index b2d4e4f27..491a14aff 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java @@ -24,6 +24,7 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.concurrent.CompletableFuture; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.format.NamedTextColor; @@ -161,7 +162,7 @@ public class VelocityCommandManager implements CommandManager { boolean isSyntaxError = !e.getType().equals( CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand()); if (isSyntaxError) { - source.sendMessage(TextComponent.of(e.getMessage(), NamedTextColor.RED)); + source.sendMessage(Component.text(e.getMessage(), NamedTextColor.RED)); // This is, of course, a lie, but the API will need to change... return true; } else { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/GlistCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/GlistCommand.java index 207ee028f..9337d4ea7 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/GlistCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/GlistCommand.java @@ -17,6 +17,7 @@ import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.proxy.server.RegisteredServer; import java.util.List; import java.util.Optional; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.format.NamedTextColor; @@ -59,9 +60,10 @@ public class GlistCommand { final CommandSource source = context.getSource(); sendTotalProxyCount(source); source.sendMessage( - TextComponent.builder("To view all players on servers, use ", NamedTextColor.YELLOW) - .append("/glist all", NamedTextColor.DARK_AQUA) - .append(".", NamedTextColor.YELLOW) + Component.text().content("To view all players on servers, use ") + .color(NamedTextColor.YELLOW) + .append(Component.text("/glist all", NamedTextColor.DARK_AQUA)) + .append(Component.text(".", NamedTextColor.YELLOW)) .build()); return 1; } @@ -78,7 +80,7 @@ public class GlistCommand { Optional registeredServer = server.getServer(serverName); if (!registeredServer.isPresent()) { source.sendMessage( - TextComponent.of("Server " + serverName + " doesn't exist.", NamedTextColor.RED)); + Component.text("Server " + serverName + " doesn't exist.", NamedTextColor.RED)); return -1; } sendServerPlayers(source, registeredServer.get(), false); @@ -87,9 +89,9 @@ public class GlistCommand { } private void sendTotalProxyCount(CommandSource target) { - target.sendMessage(TextComponent.builder("There are ", NamedTextColor.YELLOW) - .append(Integer.toString(server.getAllPlayers().size()), NamedTextColor.GREEN) - .append(" player(s) online.", NamedTextColor.YELLOW) + target.sendMessage(Component.text().content("There are ").color(NamedTextColor.YELLOW) + .append(Component.text(server.getAllPlayers().size(), NamedTextColor.GREEN)) + .append(Component.text(" player(s) online.", NamedTextColor.YELLOW)) .build()); } @@ -99,11 +101,11 @@ public class GlistCommand { return; } - TextComponent.Builder builder = TextComponent.builder() + TextComponent.Builder builder = Component.text() .append(TextComponent.of("[" + server.getServerInfo().getName() + "] ", NamedTextColor.DARK_AQUA)) - .append("(" + onServer.size() + ")", NamedTextColor.GRAY) - .append(": ") + .append(Component.text("(" + onServer.size() + ")", NamedTextColor.GRAY)) + .append(Component.text(": ")) .resetStyle(); for (int i = 0; i < onServer.size(); i++) { @@ -111,7 +113,7 @@ public class GlistCommand { builder.append(player.getUsername()); if (i + 1 < onServer.size()) { - builder.append(", "); + builder.append(Component.text(", ")); } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java index afc9551ed..4c606902b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java @@ -15,6 +15,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.format.NamedTextColor; @@ -34,7 +35,7 @@ public class ServerCommand implements SimpleCommand { final String[] args = invocation.arguments(); if (!(source instanceof Player)) { - source.sendMessage(TextComponent.of("Only players may run this command.", + source.sendMessage(Component.text("Only players may run this command.", NamedTextColor.RED)); return; } @@ -46,7 +47,7 @@ public class ServerCommand implements SimpleCommand { Optional toConnect = server.getServer(serverName); if (!toConnect.isPresent()) { player.sendMessage( - TextComponent.of("Server " + serverName + " doesn't exist.", NamedTextColor.RED)); + Component.text("Server " + serverName + " doesn't exist.", NamedTextColor.RED)); return; } @@ -59,24 +60,24 @@ public class ServerCommand implements SimpleCommand { private void outputServerInformation(Player executor) { String currentServer = executor.getCurrentServer().map(ServerConnection::getServerInfo) .map(ServerInfo::getName).orElse(""); - executor.sendMessage(TextComponent.of("You are currently connected to " + currentServer + ".", + executor.sendMessage(Component.text("You are currently connected to " + currentServer + ".", NamedTextColor.YELLOW)); List servers = BuiltinCommandUtil.sortedServerList(server); if (servers.size() > MAX_SERVERS_TO_LIST) { - executor.sendMessage(TextComponent.of( + executor.sendMessage(Component.text( "Too many servers to list. Tab-complete to show all servers.", NamedTextColor.RED)); return; } // Assemble the list of servers as components - TextComponent.Builder serverListBuilder = TextComponent.builder("Available servers: ") + TextComponent.Builder serverListBuilder = Component.text().content("Available servers: ") .color(NamedTextColor.YELLOW); for (int i = 0; i < servers.size(); i++) { RegisteredServer rs = servers.get(i); serverListBuilder.append(formatServerComponent(currentServer, rs)); if (i != servers.size() - 1) { - serverListBuilder.append(TextComponent.of(", ", NamedTextColor.GRAY)); + serverListBuilder.append(Component.text(", ", NamedTextColor.GRAY)); } } @@ -85,19 +86,19 @@ public class ServerCommand implements SimpleCommand { private TextComponent formatServerComponent(String currentPlayerServer, RegisteredServer server) { ServerInfo serverInfo = server.getServerInfo(); - TextComponent serverTextComponent = TextComponent.of(serverInfo.getName()); + TextComponent serverTextComponent = Component.text(serverInfo.getName()); String playersText = server.getPlayersConnected().size() + " player(s) online"; if (serverInfo.getName().equals(currentPlayerServer)) { serverTextComponent = serverTextComponent.color(NamedTextColor.GREEN) .hoverEvent( - showText(TextComponent.of("Currently connected to this server\n" + playersText)) + showText(Component.text("Currently connected to this server\n" + playersText)) ); } else { serverTextComponent = serverTextComponent.color(NamedTextColor.GRAY) .clickEvent(ClickEvent.runCommand("/server " + serverInfo.getName())) .hoverEvent( - showText(TextComponent.of("Click to connect to this server\n" + playersText)) + showText(Component.text("Click to connect to this server\n" + playersText)) ); } return serverTextComponent; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java index 1a0466f58..47cc3fb93 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java @@ -16,6 +16,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.stream.Collectors; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; @@ -59,7 +60,7 @@ public class VelocityCommand implements SimpleCommand { .map(Map.Entry::getKey) .collect(Collectors.joining("|")); String commandText = "/velocity <" + availableCommands + ">"; - source.sendMessage(TextComponent.of(commandText, NamedTextColor.RED)); + source.sendMessage(Component.text(commandText, NamedTextColor.RED)); } @Override @@ -142,15 +143,15 @@ public class VelocityCommand implements SimpleCommand { public void execute(CommandSource source, String @NonNull [] args) { try { if (server.reloadConfiguration()) { - source.sendMessage(TextComponent.of("Configuration reloaded.", NamedTextColor.GREEN)); + source.sendMessage(Component.text("Configuration reloaded.", NamedTextColor.GREEN)); } else { - source.sendMessage(TextComponent.of( + source.sendMessage(Component.text( "Unable to reload your configuration. Check the console for more details.", NamedTextColor.RED)); } } catch (Exception e) { logger.error("Unable to reload configuration", e); - source.sendMessage(TextComponent.of( + source.sendMessage(Component.text( "Unable to reload your configuration. Check the console for more details.", NamedTextColor.RED)); } @@ -173,16 +174,16 @@ public class VelocityCommand implements SimpleCommand { @Override public void execute(CommandSource source, String @NonNull [] args) { if (args.length != 0) { - source.sendMessage(TextComponent.of("/velocity version", NamedTextColor.RED)); + source.sendMessage(Component.text("/velocity version", NamedTextColor.RED)); return; } ProxyVersion version = server.getVersion(); - TextComponent velocity = TextComponent.builder(version.getName() + " ") + TextComponent velocity = Component.text().content(version.getName() + " ") .decoration(TextDecoration.BOLD, true) .color(NamedTextColor.DARK_AQUA) - .append(TextComponent.of(version.getVersion()).decoration(TextDecoration.BOLD, false)) + .append(Component.text(version.getVersion()).decoration(TextDecoration.BOLD, false)) .build(); TextComponent copyright = TextComponent .of("Copyright 2018-2020 " + version.getVendor() + ". " + version.getName() @@ -191,15 +192,15 @@ public class VelocityCommand implements SimpleCommand { source.sendMessage(copyright); if (version.getName().equals("Velocity")) { - TextComponent velocityWebsite = TextComponent.builder() + TextComponent velocityWebsite = Component.text() .content("Visit the ") - .append(TextComponent.builder("Velocity website") + .append(Component.text().content("Velocity website") .color(NamedTextColor.GREEN) .clickEvent( ClickEvent.openUrl("https://www.velocitypowered.com")) .build()) - .append(TextComponent.of(" or the ")) - .append(TextComponent.builder("Velocity GitHub") + .append(Component.text(" or the ")) + .append(Component.text().content("Velocity GitHub") .color(NamedTextColor.GREEN) .clickEvent(ClickEvent.openUrl( "https://github.com/VelocityPowered/Velocity")) @@ -226,7 +227,7 @@ public class VelocityCommand implements SimpleCommand { @Override public void execute(CommandSource source, String @NonNull [] args) { if (args.length != 0) { - source.sendMessage(TextComponent.of("/velocity plugins", NamedTextColor.RED)); + source.sendMessage(Component.text("/velocity plugins", NamedTextColor.RED)); return; } @@ -234,17 +235,17 @@ public class VelocityCommand implements SimpleCommand { int pluginCount = plugins.size(); if (pluginCount == 0) { - source.sendMessage(TextComponent.of("No plugins installed.", NamedTextColor.YELLOW)); + source.sendMessage(Component.text("No plugins installed.", NamedTextColor.YELLOW)); return; } - TextComponent.Builder output = TextComponent.builder("Plugins: ") + TextComponent.Builder output = Component.text().content("Plugins: ") .color(NamedTextColor.YELLOW); for (int i = 0; i < pluginCount; i++) { PluginContainer plugin = plugins.get(i); output.append(componentForPlugin(plugin.getDescription())); if (i + 1 < pluginCount) { - output.append(TextComponent.of(", ")); + output.append(Component.text(", ")); } } @@ -255,28 +256,28 @@ public class VelocityCommand implements SimpleCommand { String pluginInfo = description.getName().orElse(description.getId()) + description.getVersion().map(v -> " " + v).orElse(""); - TextComponent.Builder hoverText = TextComponent.builder(pluginInfo); + TextComponent.Builder hoverText = Component.text().content(pluginInfo); description.getUrl().ifPresent(url -> { - hoverText.append(TextComponent.newline()); - hoverText.append(TextComponent.of("Website: " + url)); + hoverText.append(Component.newline()); + hoverText.append(Component.text("Website: " + url)); }); if (!description.getAuthors().isEmpty()) { - hoverText.append(TextComponent.newline()); + hoverText.append(Component.newline()); if (description.getAuthors().size() == 1) { - hoverText.append(TextComponent.of("Author: " + description.getAuthors().get(0))); + hoverText.append(Component.text("Author: " + description.getAuthors().get(0))); } else { - hoverText.append(TextComponent.of("Authors: " + Joiner.on(", ") + hoverText.append(Component.text("Authors: " + Joiner.on(", ") .join(description.getAuthors()))); } } description.getDescription().ifPresent(pdesc -> { - hoverText.append(TextComponent.newline()); - hoverText.append(TextComponent.newline()); - hoverText.append(TextComponent.of(pdesc)); + hoverText.append(Component.newline()); + hoverText.append(Component.newline()); + hoverText.append(Component.text(pdesc)); }); - return TextComponent.of(description.getId(), NamedTextColor.GRAY) + return Component.text(description.getId(), NamedTextColor.GRAY) .hoverEvent(HoverEvent.showText(hoverText.build())); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java index 15980b863..dc839640c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java @@ -26,12 +26,13 @@ import java.util.concurrent.CompletableFuture; import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; public class LoginSessionHandler implements MinecraftSessionHandler { - private static final TextComponent MODERN_IP_FORWARDING_FAILURE = TextComponent - .of("Your server did not send a forwarding request to the proxy. Is it set up correctly?"); + private static final TextComponent MODERN_IP_FORWARDING_FAILURE = Component + .text("Your server did not send a forwarding request to the proxy. Is it set up correctly?"); private final VelocityServer server; private final VelocityServerConnection serverConn; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index e44f83ce6..846b4cdbf 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -43,7 +43,7 @@ import java.util.Optional; import java.util.Queue; import java.util.UUID; import java.util.concurrent.CompletableFuture; -import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -138,7 +138,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { logger.info("Exception occurred while running command for {}", player.getUsername(), e); player.sendMessage( - TextComponent.of("An error occurred while running this command.", + Component.text("An error occurred while running this command.", NamedTextColor.RED)); return null; }); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index f6ed9856b..3ad998ef4 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -504,7 +504,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { userMessage = "Unable to connect to " + server.getServerInfo().getName() + ". Try again " + "later."; } - handleConnectionException(server, null, TextComponent.of(userMessage, + handleConnectionException(server, null, Component.text(userMessage, NamedTextColor.RED), safe); } @@ -527,7 +527,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { if (connectedServer != null && connectedServer.getServerInfo().equals(server.getServerInfo())) { logger.error("{}: kicked from server {}: {}", this, server.getServerInfo().getName(), plainTextReason); - handleConnectionException(server, disconnectReason, TextComponent.builder() + handleConnectionException(server, disconnectReason, Component.text() .append(messages.getKickPrefix(server.getServerInfo().getName())) .color(NamedTextColor.RED) .append(disconnectReason) @@ -535,7 +535,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { } else { logger.error("{}: disconnected while connecting to {}: {}", this, server.getServerInfo().getName(), plainTextReason); - handleConnectionException(server, disconnectReason, TextComponent.builder() + handleConnectionException(server, disconnectReason, Component.text() .append(messages.getDisconnectPrefix(server.getServerInfo().getName())) .color(NamedTextColor.RED) .append(disconnectReason) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java index 83a25d4e8..632181582 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java @@ -22,6 +22,7 @@ import io.netty.buffer.ByteBuf; import java.net.InetAddress; import java.net.InetSocketAddress; import java.util.Optional; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TranslatableComponent; import net.kyori.adventure.text.format.NamedTextColor; @@ -54,7 +55,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler { @Override public boolean handle(LegacyHandshake packet) { connection.closeWith(LegacyDisconnect - .from(TextComponent.of("Your client is old, please upgrade!", NamedTextColor.RED))); + .from(Component.text("Your client is old, please upgrade!", NamedTextColor.RED))); return true; } @@ -100,13 +101,13 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler { private void handleLogin(Handshake handshake, InitialInboundConnection ic) { if (!ProtocolVersion.isSupported(handshake.getProtocolVersion())) { - ic.disconnectQuietly(TranslatableComponent.of("multiplayer.disconnect.outdated_client")); + ic.disconnectQuietly(Component.translatable("multiplayer.disconnect.outdated_client")); return; } InetAddress address = ((InetSocketAddress) connection.getRemoteAddress()).getAddress(); if (!server.getIpAttemptLimiter().attempt(address)) { - ic.disconnectQuietly(TextComponent.of("You are logging in too fast, try again later.")); + ic.disconnectQuietly(Component.text("You are logging in too fast, try again later.")); return; } @@ -116,7 +117,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler { // and lower, otherwise IP information will never get forwarded. if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN && handshake.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_13) < 0) { - ic.disconnectQuietly(TextComponent.of("This server is only compatible with 1.13 and above.")); + ic.disconnectQuietly(Component.text("This server is only compatible with 1.13 and above.")); return; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ConnectionMessages.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ConnectionMessages.java index 86f248297..50c9f3e88 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ConnectionMessages.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ConnectionMessages.java @@ -1,16 +1,17 @@ package com.velocitypowered.proxy.connection.util; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.format.NamedTextColor; public class ConnectionMessages { - public static final TextComponent ALREADY_CONNECTED = TextComponent - .of("You are already connected to this server!", NamedTextColor.RED); - public static final TextComponent IN_PROGRESS = TextComponent - .of("You are already connecting to a server!", NamedTextColor.RED); - public static final TextComponent INTERNAL_SERVER_CONNECTION_ERROR = TextComponent - .of("An internal server connection error occurred.", NamedTextColor.RED); + public static final TextComponent ALREADY_CONNECTED = Component + .text("You are already connected to this server!", NamedTextColor.RED); + public static final TextComponent IN_PROGRESS = Component + .text("You are already connecting to a server!", NamedTextColor.RED); + public static final TextComponent INTERNAL_SERVER_CONNECTION_ERROR = Component + .text("An internal server connection error occurred.", NamedTextColor.RED); private ConnectionMessages() { throw new AssertionError(); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/VelocityLegacyHoverEventSerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/VelocityLegacyHoverEventSerializer.java index 02af541a6..dbf27b039 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/VelocityLegacyHoverEventSerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/VelocityLegacyHoverEventSerializer.java @@ -31,7 +31,7 @@ public class VelocityLegacyHoverEventSerializer implements LegacyHoverEventSeria } private static Key legacyIdToFakeKey(byte id) { - return Key.of("velocity", "legacy_hover/id_" + id); + return Key.key("velocity", "legacy_hover/id_" + id); } @Override @@ -45,7 +45,7 @@ public class VelocityLegacyHoverEventSerializer implements LegacyHoverEventSeria if (idIfString.isEmpty()) { key = legacyIdToFakeKey(item.getByte("id")); } else { - key = Key.of(idIfString); + key = Key.key(idIfString); } byte count = item.getByte("Count", (byte) 1); @@ -62,10 +62,10 @@ public class VelocityLegacyHoverEventSerializer implements LegacyHoverEventSeria try { name = componentDecoder.decode(item.getString("name")); } catch (Exception e) { - name = TextComponent.of(item.getString("name")); + name = Component.text(item.getString("name")); } - return ShowEntity.of(Key.of(item.getString("type")), + return ShowEntity.of(Key.key(item.getString("type")), UUID.fromString(item.getString("id")), name); } @@ -89,7 +89,7 @@ public class VelocityLegacyHoverEventSerializer implements LegacyHoverEventSeria builder.put("tag", TagStringIO.get().asCompound(nbt.string())); } - return TextComponent.of(TagStringIO.get().asString(builder.build())); + return Component.text(TagStringIO.get().asString(builder.build())); } @Override @@ -102,6 +102,6 @@ public class VelocityLegacyHoverEventSerializer implements LegacyHoverEventSeria if (name != null) { tag.putString("name", componentEncoder.encode(name)); } - return TextComponent.of(TagStringIO.get().asString(tag.build())); + return Component.text(TagStringIO.get().asString(tag.build())); } }