Skip to content

Commit

Permalink
rename option
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Feb 25, 2024
1 parent fca5f7e commit 42827d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions cloud-core/src/main/java/org/incendo/cloud/CommandTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ private Exception noPermissionOrSyntax(
final C sender,
final CommandNode<C> root
) {
final boolean convert = this.commandManager.settings().get(ManagerSetting.CONVERT_NO_PERMISSION_TO_SYNTAX_EXCEPTION);
final boolean convert = this.commandManager.settings().get(ManagerSetting.HIDE_COMMAND_EXISTENCE);
if (!convert) {
return new NoPermissionException(
permissionResult,
Expand All @@ -369,8 +369,8 @@ private Exception noPermissionOrSyntax(
return new InvalidSyntaxException(
this.commandManager.commandSyntaxFormatter().apply(
sender,
parentChain.stream().map(CommandNode::component)
.filter(Objects::nonNull).collect(Collectors.toList()),
parentChain.stream().map(CommandNode::component)
.filter(Objects::nonNull).collect(Collectors.toList()),
root
),
sender, this.getComponentChain(root)
Expand All @@ -384,7 +384,7 @@ private Exception noPermissionOrSyntax(
);
}

private boolean childPermitted(CommandNode<C> node, C sender) {
private boolean childPermitted(final CommandNode<C> node, final C sender) {
if (this.determinePermissionResult(sender, node).allowed()) {
return true;
}
Expand All @@ -396,7 +396,7 @@ private boolean childPermitted(CommandNode<C> node, C sender) {
return false;
}

private @Nullable List<CommandNode<C>> permittedParentChain(CommandNode<C> node, C sender) {
private @Nullable List<CommandNode<C>> permittedParentChain(final CommandNode<C> node, final C sender) {
final @Nullable CommandNode<C> parent = node.parent();
if (parent != null) {
if (this.determinePermissionResult(sender, parent).allowed()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public enum ManagerSetting implements Setting {
@API(status = API.Status.EXPERIMENTAL)
LIBERAL_FLAG_PARSING,

/**
* When the sender does not have permission for the parsed command, but does have permission for a preceding or following
* node, the command tree will return a {@link org.incendo.cloud.exception.InvalidSyntaxException} instead of a
* {@link org.incendo.cloud.exception.NoPermissionException}.
*/
@API(status = API.Status.EXPERIMENTAL)
CONVERT_NO_PERMISSION_TO_SYNTAX_EXCEPTION
HIDE_COMMAND_EXISTENCE
}

0 comments on commit 42827d4

Please sign in to comment.