From bf8eba7bdd6d2b7c0fc2138ea69a4afe85d9d0f9 Mon Sep 17 00:00:00 2001 From: AlexProgrammerDE <40795980+AlexProgrammerDE@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:02:37 +0100 Subject: [PATCH] Fix rgb on paper and spigot --- .../pistonmaster/pistonmotd/bukkit/PingEventPaper.java | 10 +++++++--- .../pistonmotd/bukkit/PingEventSpigot.java | 10 ++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) 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