Rename CommandFlag#getCommandPermission
This commit is contained in:
parent
9c804addbd
commit
8aa81b445e
2 changed files with 7 additions and 8 deletions
|
|
@ -218,7 +218,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
|
||||||
final List<String> strings = new LinkedList<>();
|
final List<String> strings = new LinkedList<>();
|
||||||
/* Recommend "primary" flags */
|
/* Recommend "primary" flags */
|
||||||
for (final CommandFlag<?> flag : this.flags) {
|
for (final CommandFlag<?> flag : this.flags) {
|
||||||
if (usedFlags.contains(flag) || !commandContext.hasPermission(flag.getCommandPermission())) {
|
if (usedFlags.contains(flag) || !commandContext.hasPermission(flag.permission())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
strings.add(
|
strings.add(
|
||||||
|
|
@ -231,7 +231,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
|
||||||
/* Recommend aliases */
|
/* Recommend aliases */
|
||||||
final boolean suggestCombined = input.length() > 1 && input.charAt(0) == '-' && input.charAt(1) != '-';
|
final boolean suggestCombined = input.length() > 1 && input.charAt(0) == '-' && input.charAt(1) != '-';
|
||||||
for (final CommandFlag<?> flag : this.flags) {
|
for (final CommandFlag<?> flag : this.flags) {
|
||||||
if (usedFlags.contains(flag) || !commandContext.hasPermission(flag.getCommandPermission())) {
|
if (usedFlags.contains(flag) || !commandContext.hasPermission(flag.permission())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (final String alias : flag.getAliases()) {
|
for (final String alias : flag.getAliases()) {
|
||||||
|
|
@ -280,7 +280,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentFlag != null
|
if (currentFlag != null
|
||||||
&& commandContext.hasPermission(currentFlag.getCommandPermission())
|
&& commandContext.hasPermission(currentFlag.permission())
|
||||||
&& currentFlag.getCommandArgument() != null) {
|
&& currentFlag.getCommandArgument() != null) {
|
||||||
return (List<String>) ((BiFunction) currentFlag.getCommandArgument().getSuggestionsProvider())
|
return (List<String>) ((BiFunction) currentFlag.getCommandArgument().getSuggestionsProvider())
|
||||||
.apply(commandContext, input);
|
.apply(commandContext, input);
|
||||||
|
|
@ -355,7 +355,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
|
||||||
FailureReason.DUPLICATE_FLAG,
|
FailureReason.DUPLICATE_FLAG,
|
||||||
commandContext
|
commandContext
|
||||||
));
|
));
|
||||||
} else if (!commandContext.hasPermission(flag.getCommandPermission())) {
|
} else if (!commandContext.hasPermission(flag.permission())) {
|
||||||
return ArgumentParseResult.failure(new FlagParseException(
|
return ArgumentParseResult.failure(new FlagParseException(
|
||||||
string,
|
string,
|
||||||
FailureReason.NO_PERMISSION,
|
FailureReason.NO_PERMISSION,
|
||||||
|
|
@ -402,7 +402,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
|
||||||
FailureReason.DUPLICATE_FLAG,
|
FailureReason.DUPLICATE_FLAG,
|
||||||
commandContext
|
commandContext
|
||||||
));
|
));
|
||||||
} else if (!commandContext.hasPermission(currentFlag.getCommandPermission())) {
|
} else if (!commandContext.hasPermission(currentFlag.permission())) {
|
||||||
return ArgumentParseResult.failure(new FlagParseException(
|
return ArgumentParseResult.failure(new FlagParseException(
|
||||||
string,
|
string,
|
||||||
FailureReason.NO_PERMISSION,
|
FailureReason.NO_PERMISSION,
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,6 @@ public final class CommandFlag<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the flag description
|
* Get the flag description
|
||||||
* <p>
|
|
||||||
*
|
*
|
||||||
* @return Flag description
|
* @return Flag description
|
||||||
* @deprecated for removal since 1.4.0. Use {@link #getArgumentDescription()} instead.
|
* @deprecated for removal since 1.4.0. Use {@link #getArgumentDescription()} instead.
|
||||||
|
|
@ -131,12 +130,12 @@ public final class CommandFlag<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the command permission, if it exists
|
* Get the permission required to use this flag, if it exists
|
||||||
*
|
*
|
||||||
* @return Command permission, or {@code null}
|
* @return Command permission, or {@code null}
|
||||||
* @since 1.6.0
|
* @since 1.6.0
|
||||||
*/
|
*/
|
||||||
public CommandPermission getCommandPermission() {
|
public CommandPermission permission() {
|
||||||
return this.permission;
|
return this.permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue