summaryrefslogtreecommitdiff
path: root/dicore3/command/src/main/java/io/dico/dicore/command/CommandBuilder.java
diff options
context:
space:
mode:
Diffstat (limited to 'dicore3/command/src/main/java/io/dico/dicore/command/CommandBuilder.java')
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/CommandBuilder.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/CommandBuilder.java b/dicore3/command/src/main/java/io/dico/dicore/command/CommandBuilder.java
index 0ffc960..e72d478 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/CommandBuilder.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/CommandBuilder.java
@@ -210,9 +210,11 @@ public final class CommandBuilder {
* @param shortDescription a short description
* @param description the lines of a full description.
* @return this
+ * @throws IllegalStateException if the current group has no command
*/
public CommandBuilder setGroupDescription(String shortDescription, String... description) {
Command command = cur.getCommand();
+ if (command == null) throw new IllegalStateException();
cur.setCommand(command
.setShortDescription(shortDescription)
.setDescription(description));
@@ -220,6 +222,28 @@ public final class CommandBuilder {
}
/**
+ * Add a context filter to the command of the current group
+ * @return this
+ * @throws IllegalStateException if the current group has no command
+ */
+ public CommandBuilder addContextFilter(IContextFilter contextFilter) {
+ Command command = cur.getCommand();
+ if (command == null) throw new IllegalStateException();
+ cur.setCommand(command
+ .addContextFilter(contextFilter));
+ return this;
+ }
+
+ /**
+ * Add a required permission to the command of the current group
+ * @return this
+ * @throws IllegalStateException if the current group has no command
+ */
+ public CommandBuilder addRequiredPermission(String permission) {
+ return addContextFilter(IContextFilter.permission(permission));
+ }
+
+ /**
* Jump up a level in the address
*
* @return this