From 70698246bf20c669ed030d4d1a6e57cc9249d7a3 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 28 Jun 2020 23:20:46 -0400 Subject: [PATCH] Get everything compiling and Checkstyle clean --- .../velocitypowered/api/util/AdventureCompat.java | 12 ++++++++++++ .../proxy/command/ShutdownCommand.java | 4 ++-- .../proxy/connection/client/ConnectedPlayer.java | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/com/velocitypowered/api/util/AdventureCompat.java b/api/src/main/java/com/velocitypowered/api/util/AdventureCompat.java index ef775ded1..85d6d338a 100644 --- a/api/src/main/java/com/velocitypowered/api/util/AdventureCompat.java +++ b/api/src/main/java/com/velocitypowered/api/util/AdventureCompat.java @@ -12,6 +12,12 @@ public class AdventureCompat { throw new AssertionError("Do not create instances of this class."); } + /** + * Converts an {@link net.kyori.text.Component} component into an adventure + * {@link net.kyori.adventure.text.Component} component. + * @param component the component to translate + * @return the translated component + */ public static net.kyori.adventure.text.Component asAdventureComponent( net.kyori.text.Component component) { String json = net.kyori.text.serializer.gson.GsonComponentSerializer.INSTANCE @@ -20,6 +26,12 @@ public class AdventureCompat { .deserialize(json); } + /** + * Converts an {@link net.kyori.adventure.text.Component} component into an text + * {@link net.kyori.text.Component} component. + * @param component the component to translate + * @return the translated component + */ public static net.kyori.text.Component asOriginalTextComponent( net.kyori.adventure.text.Component component) { String json = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/ShutdownCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/ShutdownCommand.java index 568c4fdf4..3667a82a9 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/ShutdownCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/ShutdownCommand.java @@ -3,7 +3,7 @@ package com.velocitypowered.proxy.command; import com.velocitypowered.api.command.Command; import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.proxy.VelocityServer; -import net.kyori.text.serializer.legacy.LegacyComponentSerializer; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.checkerframework.checker.nullness.qual.NonNull; public class ShutdownCommand implements Command { @@ -20,7 +20,7 @@ public class ShutdownCommand implements Command { server.shutdown(true); } else { String reason = String.join(" ", args); - server.shutdown(true, LegacyComponentSerializer.legacy().deserialize(reason, '&')); + server.shutdown(true, LegacyComponentSerializer.legacy('&').deserialize(reason)); } } 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 ff0b71117..5da230765 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 @@ -281,7 +281,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { @Override public void showTitle(net.kyori.adventure.title.@NonNull Title title) { - GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(this.getProtocolVersion()); + GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(this + .getProtocolVersion()); TitlePacket titlePkt = new TitlePacket(); titlePkt.setAction(TitlePacket.SET_TITLE);