Skip to content

Commit

Permalink
Attempt to fix #210 again
Browse files Browse the repository at this point in the history
  • Loading branch information
LOOHP committed May 13, 2024
1 parent 92e419b commit a6262b7
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand All @@ -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;
}
Expand Down

0 comments on commit a6262b7

Please sign in to comment.