Use legacy colour codes in signs

This commit is contained in:
Allink 2023-08-25 22:48:33 +01:00
parent bc5d0476ee
commit 7336cc8feb
No known key found for this signature in database

View File

@ -2,19 +2,21 @@ package dev.plex.listener.impl;
import dev.plex.listener.PlexListener;
import dev.plex.util.PlexUtils;
import dev.plex.util.minimessage.SafeMiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.SignChangeEvent;
public class SignListener extends PlexListener
{
private static final LegacyComponentSerializer LEGACY_COMPONENT_SERIALIZER = LegacyComponentSerializer.legacyAmpersand();
@EventHandler(priority = EventPriority.HIGHEST)
public void onSignEdit(SignChangeEvent event)
{
for (int i = 0; i < event.lines().size(); i++)
{
event.line(i, SafeMiniMessage.mmDeserialize(PlexUtils.getTextFromComponent(event.line(i))));
event.line(i, LEGACY_COMPONENT_SERIALIZER.deserialize(PlexUtils.getTextFromComponent(event.line(i))));
}
}
}