Skip to content

Commit

Permalink
[Scoreboard] Fix toggle command being completely ignored when another…
Browse files Browse the repository at this point in the history
… plugin has sent scoreboard instead of processing it (to some degree)
  • Loading branch information
NEZNAMY committed Dec 10, 2024
1 parent bfde75d commit 6a9cca3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public void execute(@Nullable TabPlayer sender, @NotNull String[] args) {
return;
}
boolean silent = args.length == 2 && args[1].equals("-s");
if (target.scoreboardData.otherPluginScoreboard != null) return; //not overriding other plugins
scoreboard.setScoreboardVisible(target, false, !silent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public void execute(@Nullable TabPlayer sender, @NotNull String[] args) {
return;
}
boolean silent = args.length == 2 && args[1].equals("-s");
if (target.scoreboardData.otherPluginScoreboard != null) return; //not overriding other plugins
scoreboard.setScoreboardVisible(target, true, !silent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public void execute(@Nullable TabPlayer sender, @NotNull String[] args) {
return;
}
boolean silent = args.length == 2 && args[1].equals("-s");
if (target.scoreboardData.otherPluginScoreboard != null) return; //not overriding other plugins
scoreboard.toggleScoreboard(target, !silent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public String getRefreshDisplayName() {
@Override
public void refresh(@NotNull TabPlayer p, boolean force) {
if (p.scoreboardData.forcedScoreboard != null || !hasScoreboardVisible(p) ||
announcement != null || p.scoreboardData.otherPluginScoreboard != null || p.scoreboardData.joinDelayed) return;
announcement != null || p.scoreboardData.joinDelayed) return;
sendHighestScoreboard(p);
}

Expand All @@ -98,8 +98,7 @@ public void onJoin(@NotNull TabPlayer connectedPlayer) {
if (configuration.getJoinDelay() > 0) {
connectedPlayer.scoreboardData.joinDelayed = true;
customThread.executeLater(new TimedCaughtTask(TAB.getInstance().getCpu(), () -> {
if (connectedPlayer.scoreboardData.otherPluginScoreboard == null)
setScoreboardVisible(connectedPlayer, configuration.isHiddenByDefault() == sbOffPlayers.contains(connectedPlayer.getName()), false);
setScoreboardVisible(connectedPlayer, configuration.isHiddenByDefault() == sbOffPlayers.contains(connectedPlayer.getName()), false);
connectedPlayer.scoreboardData.joinDelayed = false;
}, getFeatureName(), TabConstants.CpuUsageCategory.PLAYER_JOIN), configuration.getJoinDelay());
} else {
Expand All @@ -114,6 +113,7 @@ public void onJoin(@NotNull TabPlayer connectedPlayer) {
* player to send scoreboard to
*/
public void sendHighestScoreboard(@NonNull TabPlayer p) {
if (p.scoreboardData.otherPluginScoreboard != null) return;
if (!hasScoreboardVisible(p)) return;
ScoreboardImpl scoreboard = (ScoreboardImpl) detectHighestScoreboard(p);
ScoreboardImpl current = p.scoreboardData.activeScoreboard;
Expand Down Expand Up @@ -273,7 +273,9 @@ public void setScoreboardVisible(@NonNull me.neznamy.tab.api.TabPlayer p, boolea
if (player.scoreboardData.visible == visible) return;
if (visible) {
player.scoreboardData.visible = true;
sendHighestScoreboard(player);
if (player.scoreboardData.otherPluginScoreboard == null) {
sendHighestScoreboard(player);
}
if (sendToggleMessage) {
player.sendMessage(TAB.getInstance().getConfiguration().getMessages().getScoreboardOn(), true);
}
Expand All @@ -291,7 +293,9 @@ public void setScoreboardVisible(@NonNull me.neznamy.tab.api.TabPlayer p, boolea
}
} else {
player.scoreboardData.visible = false;
unregisterScoreboard(player);
if (player.scoreboardData.otherPluginScoreboard == null) {
unregisterScoreboard(player);
}
if (sendToggleMessage) {
player.sendMessage(TAB.getInstance().getConfiguration().getMessages().getScoreboardOff(), true);
}
Expand Down

0 comments on commit 6a9cca3

Please sign in to comment.