From 773805101be826b0cf35c394474a8fa534423081 Mon Sep 17 00:00:00 2001 From: Video Date: Tue, 4 Apr 2023 20:25:17 -0600 Subject: [PATCH] Convert tags automatically when loading them in to avoid errors --- .../totalfreedom/totalfreedommod/player/PlayerData.java | 9 ++++++++- .../java/me/totalfreedom/totalfreedommod/util/FUtil.java | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java index 2872a2f8..08e648ce 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java @@ -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()); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java index 12c40e64..7aa8f2b8 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java @@ -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);