From d0ce9c05367b884b3ab4d2c1be0c3ac1dcb776af Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 11 Jun 2021 05:57:45 +1200 Subject: [PATCH] Test for adventure text support by trying to use it --- .../disguise/utilities/DisguiseUtilities.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 5eae4330..b35d1ee5 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -222,8 +222,15 @@ public class DisguiseUtilities { public static boolean hasAdventureTextSupport() { if (adventureTextSupport == null) { try { - Class.forName("net.kyori.adventure.text.minimessage.MiniMessage"); adventureTextSupport = true; + + // Force a test for support by actually trying to use it all + BaseComponent[] test1 = ComponentSerializer.parse(GsonComponentSerializer.gson().serialize(getAdventureChat("test"))); + WrappedChatComponent test2 = AdventureComponentConverter.fromComponent(DisguiseUtilities.getAdventureChat("test")); + + if (test1 == null || test1.length == 0 || test2 == null) { + adventureTextSupport = false; + } } catch (Throwable ex) { adventureTextSupport = false; }