Skip to content

Commit

Permalink
Hide spectator effect for players who unvanished (#1209)
Browse files Browse the repository at this point in the history
  • Loading branch information
NEZNAMY committed Jan 13, 2024
1 parent ecc6e01 commit 3db8666
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
@Getter
public class SpectatorFix extends TabFeature implements JoinListener, GameModeListener, Loadable, UnLoadable,
ServerSwitchListener, WorldSwitchListener {
ServerSwitchListener, WorldSwitchListener, VanishListener {

private final String featureName = "Spectator fix";

Expand Down Expand Up @@ -85,9 +85,19 @@ public void onServerChange(@NotNull TabPlayer changed, @NotNull String from, @No
@Override
public void onWorldChange(@NotNull TabPlayer changed, @NotNull String from, @NotNull String to) {
// Some server versions may resend gamemode on world switch, resend false value again
if (changed.getGamemode() != 3) return;
for (TabPlayer viewer : TAB.getInstance().getOnlinePlayers()) {
if (viewer == changed || changed.getGamemode() != 3 || viewer.hasPermission(TabConstants.Permission.SPECTATOR_BYPASS)) continue;
if (viewer == changed || viewer.hasPermission(TabConstants.Permission.SPECTATOR_BYPASS)) continue;
viewer.getTabList().updateGameMode(changed.getTablistId(), 0);
}
}

@Override
public void onVanishStatusChange(@NotNull TabPlayer player) {
if (player.isVanished() || player.getGamemode() != 3) return;
for (TabPlayer viewer : TAB.getInstance().getOnlinePlayers()) {
if (viewer == player || viewer.hasPermission(TabConstants.Permission.SPECTATOR_BYPASS)) continue;
viewer.getTabList().updateGameMode(player.getTablistId(), 0);
}
}
}

0 comments on commit 3db8666

Please sign in to comment.