Skip to content

Commit

Permalink
Enhance command visibility check with permission override logic
Browse files Browse the repository at this point in the history
  • Loading branch information
NonSwag committed Jul 29, 2024
1 parent b7b8743 commit 7b9e599
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ public class CommandListener {
@SuppressWarnings("UnstableApiUsage")
public void onCommandSend(PlayerAvailableCommandsEvent event) {
if (event.getPlayer().getPermissionValue("commander.bypass").equals(Tristate.TRUE)) return;
event.getRootNode().getChildren().removeIf(commandNode ->
commander.commandRegistry().isHidden(commandNode.getName()));
event.getRootNode().getChildren().removeIf(commandNode -> {
if (commander.commandRegistry().isHidden(commandNode.getName())) return true;
var permission = commander.permissionOverride().permission(commandNode.getName());
return !event.getPlayer().hasPermission(permission);
});
}
}

0 comments on commit 7b9e599

Please sign in to comment.