mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Removed ParametricCallable's getSuggestions() which isn't quite working.
This commit is contained in:
parent
c7988c7ad9
commit
e261e720b6
@ -253,92 +253,7 @@ class ParametricCallable implements CommandCallable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getSuggestions(String stringArguments, CommandLocals locals) throws CommandException {
|
public List<String> getSuggestions(String stringArguments, CommandLocals locals) throws CommandException {
|
||||||
String[] split = CommandContext.split(stringArguments);
|
return Collections.emptyList();
|
||||||
CommandContext context = new CommandContext(split, getValueFlags());
|
|
||||||
|
|
||||||
ContextArgumentStack scoped = new ContextArgumentStack(context);
|
|
||||||
SuggestionContext suggestable = context.getSuggestionContext();
|
|
||||||
|
|
||||||
// For /command -f |
|
|
||||||
// For /command -f flag|
|
|
||||||
if (suggestable.forFlag()) {
|
|
||||||
for (ParameterData parameter : parameters) {
|
|
||||||
if (parameter.getFlag() == suggestable.getFlag()) {
|
|
||||||
String prefix = context.getFlag(parameter.getFlag());
|
|
||||||
if (prefix == null) {
|
|
||||||
prefix = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return parameter.getBinding().getSuggestions(parameter, prefix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This should not happen
|
|
||||||
return new ArrayList<String>();
|
|
||||||
}
|
|
||||||
|
|
||||||
int consumerIndex = 0;
|
|
||||||
ParameterData lastConsumer = null;
|
|
||||||
String lastConsumed = null;
|
|
||||||
|
|
||||||
for (ParameterData parameter : parameters) {
|
|
||||||
if (parameter.getFlag() != null) {
|
|
||||||
continue; // We already handled flags
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
scoped.mark();
|
|
||||||
parameter.getBinding().bind(parameter, scoped, true);
|
|
||||||
if (scoped.wasConsumed()) {
|
|
||||||
lastConsumer = parameter;
|
|
||||||
lastConsumed = scoped.getConsumed();
|
|
||||||
consumerIndex++;
|
|
||||||
}
|
|
||||||
} catch (MissingParameterException e) {
|
|
||||||
// For /command value1 |value2
|
|
||||||
// For /command |value1 value2
|
|
||||||
if (suggestable.forHangingValue()) {
|
|
||||||
return parameter.getBinding().getSuggestions(parameter, "");
|
|
||||||
} else {
|
|
||||||
// For /command value1| value2
|
|
||||||
if (lastConsumer != null) {
|
|
||||||
return lastConsumer.getBinding()
|
|
||||||
.getSuggestions(lastConsumer, lastConsumed);
|
|
||||||
// For /command| value1 value2
|
|
||||||
// This should never occur
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException("Invalid suggestion context");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (ParameterException e) {
|
|
||||||
if (suggestable.forHangingValue()) {
|
|
||||||
String name = getDescription().getParameters()
|
|
||||||
.get(consumerIndex).getName();
|
|
||||||
|
|
||||||
throw new InvalidUsageException("For parameter '" + name + "': "
|
|
||||||
+ e.getMessage(), getDescription());
|
|
||||||
} else {
|
|
||||||
return parameter.getBinding().getSuggestions(parameter, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// For /command value1 value2 |
|
|
||||||
if (suggestable.forHangingValue()) {
|
|
||||||
// There's nothing that we can suggest because there's no more parameters
|
|
||||||
// to add on, and we can't change the previous parameter
|
|
||||||
return new ArrayList<String>();
|
|
||||||
} else {
|
|
||||||
// For /command value1 value2|
|
|
||||||
if (lastConsumer != null) {
|
|
||||||
return lastConsumer.getBinding()
|
|
||||||
.getSuggestions(lastConsumer, lastConsumed);
|
|
||||||
// This should never occur
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException("Invalid suggestion context");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user