✨ Rename methods (#41)
This commit is contained in:
parent
8ebb248a47
commit
fdb80b304c
6 changed files with 51 additions and 12 deletions
|
|
@ -659,7 +659,7 @@ public class Command<C> {
|
|||
* @param permission Command permission
|
||||
* @return New builder instance using the command permission
|
||||
*/
|
||||
public @NonNull Builder<C> withPermission(final @NonNull CommandPermission permission) {
|
||||
public @NonNull Builder<C> permission(final @NonNull CommandPermission permission) {
|
||||
return new Builder<>(
|
||||
this.commandManager,
|
||||
this.commandMeta,
|
||||
|
|
@ -677,7 +677,7 @@ public class Command<C> {
|
|||
* @param permission Command permission
|
||||
* @return New builder instance using the command permission
|
||||
*/
|
||||
public @NonNull Builder<C> withPermission(final @NonNull String permission) {
|
||||
public @NonNull Builder<C> permission(final @NonNull String permission) {
|
||||
return new Builder<>(
|
||||
this.commandManager,
|
||||
this.commandMeta,
|
||||
|
|
@ -710,7 +710,7 @@ public class Command<C> {
|
|||
builder = builder.argument(builtArgument, Description.of(command.getArgumentDescription(argument)));
|
||||
}
|
||||
if (this.commandPermission.toString().isEmpty()) {
|
||||
builder = builder.withPermission(command.getCommandPermission());
|
||||
builder = builder.permission(command.getCommandPermission());
|
||||
}
|
||||
return builder.handler(command.commandExecutionHandler);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,39 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
|
|||
return StringArgument.<C>newBuilder(name).asOptionalWithDefault(defaultString).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument with the 'single' parsing mode
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
*/
|
||||
public static <C> @NonNull CommandArgument<C, String> single(final @NonNull String name) {
|
||||
return of(name, StringMode.SINGLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument with the 'greedy' parsing mode
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
*/
|
||||
public static <C> @NonNull CommandArgument<C, String> greedy(final @NonNull String name) {
|
||||
return of(name, StringMode.GREEDY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument with the 'quoted' parsing mode
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
*/
|
||||
public static <C> @NonNull CommandArgument<C, String> quoted(final @NonNull String name) {
|
||||
return of(name, StringMode.QUOTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string mode
|
||||
*
|
||||
|
|
@ -158,6 +191,12 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
|
|||
super(String.class, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the String mode
|
||||
*
|
||||
* @param stringMode String mode to parse with
|
||||
* @return Builder instance
|
||||
*/
|
||||
private @NonNull Builder<C> withMode(final @NonNull StringMode stringMode) {
|
||||
this.stringMode = stringMode;
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ class CommandPermissionTest {
|
|||
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
manager.command(manager.commandBuilder("test").literal("foo").withPermission("test.permission.one").build());
|
||||
manager.command(manager.commandBuilder("test").literal("bar").withPermission("test.permission.two").build());
|
||||
manager.command(manager.commandBuilder("test").literal("fizz").withPermission("test.permission.three").build());
|
||||
manager.command(manager.commandBuilder("test").literal("buzz").withPermission("test.permission.four").build());
|
||||
manager.command(manager.commandBuilder("test").literal("foo").permission("test.permission.one").build());
|
||||
manager.command(manager.commandBuilder("test").literal("bar").permission("test.permission.two").build());
|
||||
manager.command(manager.commandBuilder("test").literal("fizz").permission("test.permission.three").build());
|
||||
manager.command(manager.commandBuilder("test").literal("buzz").permission("test.permission.four").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class CommandTreeTest {
|
|||
manager.command(manager.commandBuilder("test", SimpleCommandMeta.empty())
|
||||
.literal("one").build())
|
||||
.command(manager.commandBuilder("test", SimpleCommandMeta.empty())
|
||||
.literal("two").withPermission("no").build())
|
||||
.literal("two").permission("no").build())
|
||||
.command(manager.commandBuilder("test", Collections.singleton("other"),
|
||||
SimpleCommandMeta.empty()
|
||||
)
|
||||
|
|
@ -79,11 +79,11 @@ class CommandTreeTest {
|
|||
|
||||
/* Build command for testing intermediary and final executors */
|
||||
manager.command(manager.commandBuilder("command")
|
||||
.withPermission("command.inner")
|
||||
.permission("command.inner")
|
||||
.literal("inner")
|
||||
.handler(c -> System.out.println("Using inner command")));
|
||||
manager.command(manager.commandBuilder("command")
|
||||
.withPermission("command.outer")
|
||||
.permission("command.outer")
|
||||
.handler(c -> System.out.println("Using outer command")));
|
||||
|
||||
/* Build command for testing compound types */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue