diff --git a/bukkit/src/main/java/net/pistonmaster/pistonmotd/bukkit/PingEventPaper.java b/bukkit/src/main/java/net/pistonmaster/pistonmotd/bukkit/PingEventPaper.java index 3bb5c8b..68dcbfb 100644 --- a/bukkit/src/main/java/net/pistonmaster/pistonmotd/bukkit/PingEventPaper.java +++ b/bukkit/src/main/java/net/pistonmaster/pistonmotd/bukkit/PingEventPaper.java @@ -10,7 +10,6 @@ import net.pistonmaster.pistonmotd.shared.StatusFavicon; import net.pistonmaster.pistonmotd.shared.StatusPingListener; import net.pistonmaster.pistonmotd.shared.utils.PMHelpers; -import net.pistonmaster.pistonmotd.shared.utils.PMUnsupportedConfigException; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -24,6 +23,11 @@ @RequiredArgsConstructor @SuppressWarnings({"removal", "deprecation"}) public class PingEventPaper implements Listener, StatusPingListener { + public static final LegacyComponentSerializer LEGACY_COMPONENT_SERIALIZER = LegacyComponentSerializer.builder() + .character('§') + .hexCharacter('#') + .hexColors() + .build(); private final PistonMOTDPlugin plugin; @EventHandler @@ -40,12 +44,12 @@ public void hidePlayers() { @Override public String getDescriptionJson() { - return GsonComponentSerializer.gson().serialize(LegacyComponentSerializer.legacySection().deserialize(event.getMotd())); + return GsonComponentSerializer.gson().serialize(LEGACY_COMPONENT_SERIALIZER.deserialize(event.getMotd())); } @Override public void setDescription(String descriptionJson) { - event.setMotd(LegacyComponentSerializer.legacySection().serialize(GsonComponentSerializer.gson().deserialize(descriptionJson))); + event.setMotd(LEGACY_COMPONENT_SERIALIZER.serialize(GsonComponentSerializer.gson().deserialize(descriptionJson))); } @Override diff --git a/bukkit/src/main/java/net/pistonmaster/pistonmotd/bukkit/PingEventSpigot.java b/bukkit/src/main/java/net/pistonmaster/pistonmotd/bukkit/PingEventSpigot.java index a28c218..cceee18 100644 --- a/bukkit/src/main/java/net/pistonmaster/pistonmotd/bukkit/PingEventSpigot.java +++ b/bukkit/src/main/java/net/pistonmaster/pistonmotd/bukkit/PingEventSpigot.java @@ -22,6 +22,12 @@ @RequiredArgsConstructor @SuppressWarnings({"deprecation"}) public class PingEventSpigot implements Listener, StatusPingListener { + public static final LegacyComponentSerializer LEGACY_COMPONENT_SERIALIZER = LegacyComponentSerializer.builder() + .character('§') + .hexCharacter('#') + .hexColors() + .useUnusualXRepeatedCharacterHexFormat() + .build(); private final PistonMOTDPlugin plugin; @EventHandler @@ -38,12 +44,12 @@ public void hidePlayers() throws PMUnsupportedConfigException { @Override public String getDescriptionJson() { - return GsonComponentSerializer.gson().serialize(LegacyComponentSerializer.legacySection().deserialize(event.getMotd())); + return GsonComponentSerializer.gson().serialize(LEGACY_COMPONENT_SERIALIZER.deserialize(event.getMotd())); } @Override public void setDescription(String descriptionJson) { - event.setMotd(LegacyComponentSerializer.legacySection().serialize(GsonComponentSerializer.gson().deserialize(descriptionJson))); + event.setMotd(LEGACY_COMPONENT_SERIALIZER.serialize(GsonComponentSerializer.gson().deserialize(descriptionJson))); } @Override