Skip to content

Commit

Permalink
Fix rgb on paper and spigot
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Dec 16, 2024
1 parent 7c8fc18 commit bf8eba7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit bf8eba7

Please sign in to comment.