3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-06 00:00:47 +01:00

Replace uses of deprecated LegacyComponentSerializer.INSTANCE

Dieser Commit ist enthalten in:
Andrew Steinborn 2019-05-31 15:50:46 -04:00
Ursprung a77fee9ad1
Commit dfe210707f
5 geänderte Dateien mit 7 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -287,7 +287,7 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi
if (motd.startsWith("{")) { if (motd.startsWith("{")) {
motdAsComponent = GsonComponentSerializer.INSTANCE.deserialize(motd); motdAsComponent = GsonComponentSerializer.INSTANCE.deserialize(motd);
} else { } else {
motdAsComponent = LegacyComponentSerializer.INSTANCE.deserialize(motd, '&'); motdAsComponent = LegacyComponentSerializer.legacy().deserialize(motd, '&');
} }
} }
return motdAsComponent; return motdAsComponent;

Datei anzeigen

@ -208,7 +208,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.INSTANCE.serialize(component)); object.addProperty("text", LegacyComponentSerializer.legacy().serialize(component));
json = object.toString(); json = object.toString();
} }
} else { } else {
@ -254,7 +254,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
@Override @Override
public void disconnect(Component reason) { public void disconnect(Component reason) {
logger.info("{} has disconnected: {}", this, logger.info("{} has disconnected: {}", this,
LegacyComponentSerializer.INSTANCE.serialize(reason)); LegacyComponentSerializer.legacy().serialize(reason));
minecraftConnection.closeWith(Disconnect.create(reason)); minecraftConnection.closeWith(Disconnect.create(reason));
} }

Datei anzeigen

@ -55,7 +55,7 @@ class InitialInboundConnection implements InboundConnection, MinecraftConnection
public void disconnect(Component reason) { public void disconnect(Component reason) {
logger.info("{} has disconnected: {}", this, logger.info("{} has disconnected: {}", this,
LegacyComponentSerializer.INSTANCE.serialize(reason)); LegacyComponentSerializer.legacy().serialize(reason));
connection.closeWith(Disconnect.create(reason)); connection.closeWith(Disconnect.create(reason));
} }
} }

Datei anzeigen

@ -35,7 +35,7 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
@Override @Override
public void sendMessage(Component component) { public void sendMessage(Component component) {
logger.info(LegacyComponentSerializer.INSTANCE.serialize(component)); logger.info(LegacyComponentSerializer.legacy().serialize(component));
} }
@Override @Override

Datei anzeigen

@ -26,7 +26,6 @@ public class LegacyDisconnect {
* @param version the requesting clients' version * @param version the requesting clients' version
* @return the disconnect packet * @return the disconnect packet
*/ */
@SuppressWarnings("deprecation") // we use these on purpose to service older clients!
public static LegacyDisconnect fromServerPing(ServerPing response, public static LegacyDisconnect fromServerPing(ServerPing response,
LegacyMinecraftPingVersion version) { LegacyMinecraftPingVersion version) {
Players players = response.getPlayers().orElse(FAKE_PLAYERS); Players players = response.getPlayers().orElse(FAKE_PLAYERS);
@ -47,7 +46,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.INSTANCE.serialize(response.getDescription())), getFirstLine(LegacyComponentSerializer.legacy().serialize(response.getDescription())),
Integer.toString(players.getOnline()), Integer.toString(players.getOnline()),
Integer.toString(players.getMax()) Integer.toString(players.getMax())
)); ));
@ -72,8 +71,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.
@SuppressWarnings("deprecation") String serialized = LegacyComponentSerializer.legacy().serialize(component);
String serialized = LegacyComponentSerializer.INSTANCE.serialize(component);
return new LegacyDisconnect(serialized); return new LegacyDisconnect(serialized);
} }