From 28341f92e139f7c07cdcafa1f234d5037fcc6489 Mon Sep 17 00:00:00 2001 From: Reflxction Dev Date: Thu, 14 Jul 2022 12:56:04 +0300 Subject: [PATCH] update CategoryPermission --- .../java/revxrsal/commands/core/BaseCommandCategory.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/revxrsal/commands/core/BaseCommandCategory.java b/common/src/main/java/revxrsal/commands/core/BaseCommandCategory.java index 26de0670..2958449b 100644 --- a/common/src/main/java/revxrsal/commands/core/BaseCommandCategory.java +++ b/common/src/main/java/revxrsal/commands/core/BaseCommandCategory.java @@ -88,6 +88,10 @@ public void parent(BaseCommandCategory cat) { cat.categories.put(path, this); } + /** + * Category permission: They have access to the category if they have + * access to any of its commands or other categories. + */ private class CategoryPermission implements CommandPermission { @Override public boolean canExecute(@NotNull CommandActor actor) { @@ -97,7 +101,9 @@ private class CategoryPermission implements CommandPermission { for (CommandCategory category : categories.values()) if (category.getPermission().canExecute(actor)) return true; - return defaultAction == null || defaultAction.hasPermission(actor); + if (defaultAction == null) + return false; + return defaultAction.hasPermission(actor); } }