Convert tags automatically when loading them in to avoid errors

This commit is contained in:
Video 2023-04-04 20:25:17 -06:00
parent f474ce99fd
commit 773805101b
2 changed files with 14 additions and 1 deletions

View File

@ -53,7 +53,14 @@ public class PlayerData
ips.addAll(FUtil.stringToList(resultSet.getString("ips")));
notes.clear();
notes.addAll(FUtil.stringToList(resultSet.getString("notes")));
tag = FUtil.miniMessage(resultSet.getString("tag"));
String tempTag = resultSet.getString("tag");
//--
if (!Strings.isNullOrEmpty(tempTag) && FUtil.containsChatColor(tempTag))
{
tempTag = FUtil.miniMessage(FUtil.colorizeAsComponentSection(tempTag));
}
//--
tag = FUtil.miniMessage(tempTag);
discordID = resultSet.getString("discord_id");
masterBuilder = resultSet.getBoolean("master_builder");
rideMode = RideMode.valueOf(resultSet.getString("ride_mode").toUpperCase());

View File

@ -83,6 +83,7 @@ public class FUtil
private static final PlainTextComponentSerializer STEAMROLLER = PlainTextComponentSerializer.plainText();
public static final LegacyComponentSerializer LEGACY_AMPERSAND = LegacyComponentSerializer.legacyAmpersand();
public static final LegacyComponentSerializer LEGACY_SECTION = LegacyComponentSerializer.legacySection();
public static final MiniMessage MINI_MESSAGE = MiniMessage.builder().tags(TagResolver.resolver(
StandardTags.color(),
StandardTags.rainbow(),
@ -490,6 +491,11 @@ public class FUtil
return LEGACY_AMPERSAND.deserialize(string);
}
public static Component colorizeAsComponentSection(String string)
{
return LEGACY_SECTION.deserialize(string);
}
public static Component miniMessage(String string, TagResolver... placeholders)
{
return MINI_MESSAGE.deserialize(string, placeholders);