diff --git a/cloud-core/src/main/java/org/incendo/cloud/CommandTree.java b/cloud-core/src/main/java/org/incendo/cloud/CommandTree.java index 5295c831c..f6b6f531a 100644 --- a/cloud-core/src/main/java/org/incendo/cloud/CommandTree.java +++ b/cloud-core/src/main/java/org/incendo/cloud/CommandTree.java @@ -348,7 +348,7 @@ private Exception noPermissionOrSyntax( final C sender, final CommandNode 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, @@ -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) @@ -384,7 +384,7 @@ private Exception noPermissionOrSyntax( ); } - private boolean childPermitted(CommandNode node, C sender) { + private boolean childPermitted(final CommandNode node, final C sender) { if (this.determinePermissionResult(sender, node).allowed()) { return true; } @@ -396,7 +396,7 @@ private boolean childPermitted(CommandNode node, C sender) { return false; } - private @Nullable List> permittedParentChain(CommandNode node, C sender) { + private @Nullable List> permittedParentChain(final CommandNode node, final C sender) { final @Nullable CommandNode parent = node.parent(); if (parent != null) { if (this.determinePermissionResult(sender, parent).allowed()) { diff --git a/cloud-core/src/main/java/org/incendo/cloud/setting/ManagerSetting.java b/cloud-core/src/main/java/org/incendo/cloud/setting/ManagerSetting.java index 2632d94ca..55dc6ac71 100644 --- a/cloud-core/src/main/java/org/incendo/cloud/setting/ManagerSetting.java +++ b/cloud-core/src/main/java/org/incendo/cloud/setting/ManagerSetting.java @@ -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 }