diff options
author | Dico <dico.karssiens@gmail.com> | 2018-08-12 18:07:43 +0100 |
---|---|---|
committer | Dico <dico.karssiens@gmail.com> | 2018-08-12 18:07:43 +0100 |
commit | 5bd0970c54a843c897126116d5eaff88014360fb (patch) | |
tree | 54ce2c17247377024c67b1dacb528fa46615b9d5 /dicore3/command/src/main/java/io/dico/dicore/command/CommandBuilder.java | |
parent | 957d6f2434f9223107605a8115b6e868de772018 (diff) |
Work on a couple of the todos
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.java | 24 |
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 |