Skip to content

Commit

Permalink
fix: tab breaks on reload
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelillo15 committed Dec 31, 2024
1 parent aa5873b commit b72c51b
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@

@Singleton
public final class TabNameTagTransformer implements NameTagTransformer {
private final NameTagManager nameTagManager = TabAPI.getInstance().getNameTagManager();

@Inject
public TabNameTagTransformer(@NotNull final Logger logger) {
if (nameTagManager == null) {
if (getNameTagManager() == null) {
logger.severe("TabAPI is not loaded, disabling TabNametagTransformer.");
}
}
Expand All @@ -27,6 +25,7 @@ public TabNameTagTransformer(@NotNull final Logger logger) {
public void setPrefix(@NotNull PlayerWrapper player, @NotNull String prefix) {
requireNonNull(player, "Player cannot be null.");
requireNonNull(prefix, "Prefix cannot be null.");
final var nameTagManager = getNameTagManager();

if (nameTagManager == null) return;
nameTagManager.setPrefix(getTabPlayer(player), prefix);
Expand All @@ -35,6 +34,7 @@ public void setPrefix(@NotNull PlayerWrapper player, @NotNull String prefix) {
@Override
public void removePrefix(@NotNull PlayerWrapper player) {
requireNonNull(player, "Player cannot be null.");
final var nameTagManager = getNameTagManager();

if (nameTagManager == null) return;
nameTagManager.setPrefix(getTabPlayer(player), null);
Expand All @@ -43,6 +43,7 @@ public void removePrefix(@NotNull PlayerWrapper player) {
@Override
public void setSuffix(@NotNull PlayerWrapper player, @NotNull String suffix) {
requireNonNull(player, "Player cannot be null.");
final var nameTagManager = getNameTagManager();

if (nameTagManager == null) return;
nameTagManager.setSuffix(getTabPlayer(player), suffix);
Expand All @@ -51,6 +52,7 @@ public void setSuffix(@NotNull PlayerWrapper player, @NotNull String suffix) {
@Override
public void removeSuffix(@NotNull PlayerWrapper player) {
requireNonNull(player, "Player cannot be null.");
final var nameTagManager = getNameTagManager();

if (nameTagManager == null) return;
nameTagManager.setSuffix(getTabPlayer(player), null);
Expand All @@ -59,4 +61,8 @@ public void removeSuffix(@NotNull PlayerWrapper player) {
private TabPlayer getTabPlayer(PlayerWrapper player) {
return TabAPI.getInstance().getPlayer(player.getUniqueId());
}

private NameTagManager getNameTagManager() {
return TabAPI.getInstance().getNameTagManager();
}
}

0 comments on commit b72c51b

Please sign in to comment.