From a6262b7279248c81ed0a45aaf7889ad146f01366 Mon Sep 17 00:00:00 2001 From: LOOHP Date: Mon, 13 May 2024 19:03:54 +0100 Subject: [PATCH] Attempt to fix #210 again --- .../utils/InteractiveChatComponentSerializer.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/loohp/interactivechat/utils/InteractiveChatComponentSerializer.java b/common/src/main/java/com/loohp/interactivechat/utils/InteractiveChatComponentSerializer.java index 6ad8bcf..d794922 100644 --- a/common/src/main/java/com/loohp/interactivechat/utils/InteractiveChatComponentSerializer.java +++ b/common/src/main/java/com/loohp/interactivechat/utils/InteractiveChatComponentSerializer.java @@ -23,7 +23,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; -import com.loohp.interactivechat.InteractiveChat; import com.loohp.interactivechat.objectholders.LegacyIdKey; import net.kyori.adventure.key.Key; import net.kyori.adventure.nbt.CompoundBinaryTag; @@ -82,7 +81,7 @@ public class InteractiveChatComponentSerializer { .value(JSONOptions.EMIT_RGB, true) .value(JSONOptions.EMIT_HOVER_EVENT_TYPE, JSONOptions.HoverEventValueMode.BOTH) .value(JSONOptions.EMIT_DEFAULT_ITEM_HOVER_QUANTITY, true) - .value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, isProxyEnvironment() || InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_20_3)) + .value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, isProxyEnvironment() || isBukkitAboveV1_20_3()) .build() ) .build() @@ -108,11 +107,19 @@ private static boolean isProxyEnvironment() { try { Class.forName("org.bukkit.plugin.java.JavaPlugin"); return true; - } catch (ClassNotFoundException e) { + } catch (Throwable e) { return false; } } + private static boolean isBukkitAboveV1_20_3() { + try { + return com.loohp.interactivechat.InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_20_3); + } catch (Throwable e) { + return true; + } + } + public static InteractiveChatBungeecordAPILegacyComponentSerializer bungeecordApiLegacy() { return BUNGEECORD_CHAT_LEGACY; }