mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
ParametricCallable.mayConsumeArguments() handles flags better.
This commit is contained in:
parent
06c248e518
commit
765d987ae1
@ -344,20 +344,24 @@ class ParametricCallable implements CommandCallable {
|
|||||||
// Optional non-flag parameters:
|
// Optional non-flag parameters:
|
||||||
// - Before required parameters: Consume if there are 'left over' args
|
// - Before required parameters: Consume if there are 'left over' args
|
||||||
// - At the end: Always consumes
|
// - At the end: Always consumes
|
||||||
|
|
||||||
if (parameter.isOptional() && parameter.getFlag() == null) {
|
if (parameter.isOptional()) {
|
||||||
int numberFree = context.argsLength() - scoped.position();
|
if (parameter.getFlag() != null) {
|
||||||
for (int j = i; j < parameters.length; j++) {
|
return !parameter.isValueFlag() || context.hasFlag(parameter.getFlag());
|
||||||
if (parameters[j].isNonFlagConsumer() && !parameters[j].isOptional()) {
|
} else {
|
||||||
// We already checked if the consumed count was > -1
|
int numberFree = context.argsLength() - scoped.position();
|
||||||
// when we created this object
|
for (int j = i; j < parameters.length; j++) {
|
||||||
numberFree -= parameters[j].getConsumedCount();
|
if (parameters[j].isNonFlagConsumer() && !parameters[j].isOptional()) {
|
||||||
|
// We already checked if the consumed count was > -1
|
||||||
|
// when we created this object
|
||||||
|
numberFree -= parameters[j].getConsumedCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip this optional parameter
|
||||||
|
if (numberFree < 1) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Skip this optional parameter
|
|
||||||
if (numberFree < 1) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user