Skip to content

Commit

Permalink
Merge pull request #26 from Matt-MX/dev
Browse files Browse the repository at this point in the history
🐛 Fix `ClassNotFoundException` being thrown for `TAB`
  • Loading branch information
Matt-MX authored Nov 11, 2024
2 parents 730d1b0 + 7d1274c commit ac52164
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 ac52164

Please sign in to comment.