Test for adventure text support by trying to use it
This commit is contained in:
parent
cafc9f22d6
commit
d0ce9c0536
@ -222,8 +222,15 @@ public class DisguiseUtilities {
|
|||||||
public static boolean hasAdventureTextSupport() {
|
public static boolean hasAdventureTextSupport() {
|
||||||
if (adventureTextSupport == null) {
|
if (adventureTextSupport == null) {
|
||||||
try {
|
try {
|
||||||
Class.forName("net.kyori.adventure.text.minimessage.MiniMessage");
|
|
||||||
adventureTextSupport = true;
|
adventureTextSupport = true;
|
||||||
|
|
||||||
|
// Force a test for support by actually trying to use it all
|
||||||
|
BaseComponent[] test1 = ComponentSerializer.parse(GsonComponentSerializer.gson().serialize(getAdventureChat("<green>test")));
|
||||||
|
WrappedChatComponent test2 = AdventureComponentConverter.fromComponent(DisguiseUtilities.getAdventureChat("<green>test"));
|
||||||
|
|
||||||
|
if (test1 == null || test1.length == 0 || test2 == null) {
|
||||||
|
adventureTextSupport = false;
|
||||||
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
adventureTextSupport = false;
|
adventureTextSupport = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user