Fix SubCommand.tabComplete with noVarArgs returning too early
Dieser Commit ist enthalten in:
Ursprung
2edb3dd951
Commit
a33c8a3a1e
@ -130,7 +130,7 @@ public abstract class SWCommand {
|
|||||||
if (mapper != null) {
|
if (mapper != null) {
|
||||||
name = mapper.value();
|
name = mapper.value();
|
||||||
}
|
}
|
||||||
if (!SWCommandUtils.MAPPER_FUNCTIONS.containsKey(name)) {
|
if (!SWCommandUtils.MAPPER_FUNCTIONS.containsKey(name) && !localTypeMapper.containsKey(name)) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "The parameter '" + parameter.toString() + "' is using an unsupported Mapper of type '" + name + "'");
|
Bukkit.getLogger().log(Level.WARNING, "The parameter '" + parameter.toString() + "' is using an unsupported Mapper of type '" + name + "'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -101,37 +101,41 @@ class SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<String> tabComplete(CommandSender commandSender, String[] args) {
|
List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||||
if (varArgType == null && args.length < arguments.length + subCommand.length - 1) {
|
if (varArgType == null && args.length > arguments.length + subCommand.length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
int index = 0;
|
||||||
List<String> argsList = new LinkedList<>(Arrays.asList(args));
|
List<String> argsList = new LinkedList<>(Arrays.asList(args));
|
||||||
for (String value : subCommand) {
|
for (String value : subCommand) {
|
||||||
String s = argsList.remove(0);
|
String s = argsList.remove(0);
|
||||||
if (argsList.isEmpty()) return Collections.singletonList(value);
|
if (argsList.isEmpty()) return Collections.singletonList(value);
|
||||||
if (!value.equalsIgnoreCase(s)) return null;
|
if (!value.equalsIgnoreCase(s)) return null;
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
for (TypeMapper<?> argument : arguments) {
|
for (TypeMapper<?> argument : arguments) {
|
||||||
String s = argsList.remove(0);
|
String s = argsList.remove(0);
|
||||||
if (argsList.isEmpty()) return argument.tabCompletes(commandSender, Arrays.copyOf(args, args.length - 1), s);
|
if (argsList.isEmpty()) return argument.tabCompletes(commandSender, Arrays.copyOf(args, args.length - 1), s);
|
||||||
try {
|
try {
|
||||||
if (argument.map(Arrays.copyOf(args, argsList.size()), s) == null) {
|
if (argument.map(Arrays.copyOf(args, index), s) == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
if (varArgType != null && !argsList.isEmpty()) {
|
if (varArgType != null && !argsList.isEmpty()) {
|
||||||
while (!argsList.isEmpty()) {
|
while (!argsList.isEmpty()) {
|
||||||
String s = argsList.remove(0);
|
String s = argsList.remove(0);
|
||||||
if (argsList.isEmpty()) return arguments[arguments.length - 1].tabCompletes(commandSender, Arrays.copyOf(args, args.length - 1), s);
|
if (argsList.isEmpty()) return arguments[arguments.length - 1].tabCompletes(commandSender, Arrays.copyOf(args, args.length - 1), s);
|
||||||
try {
|
try {
|
||||||
if (arguments[arguments.length - 1].map(Arrays.copyOf(args, argsList.size()), s) == null) {
|
if (arguments[arguments.length - 1].map(Arrays.copyOf(args, index), s) == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren