From 7d1274c2fd8e682ac34ab345798e24e5f140a249 Mon Sep 17 00:00:00 2001 From: MattMX Date: Mon, 11 Nov 2024 17:52:30 +0000 Subject: [PATCH] :bug: Fix `ClassNotFoundException` being thrown for `TAB` --- .../mattmx/nametags/hook/NeznamyTABHook.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/mattmx/nametags/hook/NeznamyTABHook.java b/src/main/java/com/mattmx/nametags/hook/NeznamyTABHook.java index ea26700..50a8e2e 100644 --- a/src/main/java/com/mattmx/nametags/hook/NeznamyTABHook.java +++ b/src/main/java/com/mattmx/nametags/hook/NeznamyTABHook.java @@ -26,7 +26,15 @@ private static void start() { NameTags plugin = NameTags.getInstance(); NameTagManager nameTagManager = TabAPI.getInstance().getNameTagManager(); - if (nameTagManager instanceof UnlimitedNameTagManager) { + boolean isUnlimitedNameTag = false; + + try { + Class.forName("me.neznamy.tab.api.nametag.UnlimitedNameTagManager"); + isUnlimitedNameTag = nameTagManager instanceof UnlimitedNameTagManager; + } catch (ClassNotFoundException ignored) { + } + + if (isUnlimitedNameTag) { plugin.getLogger().warning(""" ⚠ TAB UnlimitedNameTags Mode detected! ⚠ @@ -51,9 +59,11 @@ private static void start() { .register(PlayerLoadEvent.class, (event) -> { final TabPlayer tabPlayer = event.getPlayer(); - TabAPI.getInstance() - .getNameTagManager() - .hideNameTag(tabPlayer); + NameTagManager manager = TabAPI.getInstance().getNameTagManager(); + + if (manager != null) { + manager.hideNameTag(tabPlayer); + } }); }