Skip to content

Commit

Permalink
🐛 Fix ClassNotFoundException being thrown for TAB
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-MX committed Nov 11, 2024
1 parent 4768ecd commit 7d1274c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main/java/com/mattmx/nametags/hook/NeznamyTABHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -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! ⚠
Expand All @@ -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);
}
});
}

Expand Down

0 comments on commit 7d1274c

Please sign in to comment.