SteamWar/SpigotCore
Archiviert
13
0

Fix SubCommand.tabComplete with noVarArgs returning too early

Dieser Commit ist enthalten in:
yoyosource 2021-03-31 14:43:04 +02:00
Ursprung 2edb3dd951
Commit a33c8a3a1e
2 geänderte Dateien mit 8 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -130,7 +130,7 @@ public abstract class SWCommand {
if (mapper != null) {
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 + "'");
return;
}

Datei anzeigen

@ -101,37 +101,41 @@ class SubCommand {
}
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;
}
int index = 0;
List<String> argsList = new LinkedList<>(Arrays.asList(args));
for (String value : subCommand) {
String s = argsList.remove(0);
if (argsList.isEmpty()) return Collections.singletonList(value);
if (!value.equalsIgnoreCase(s)) return null;
index++;
}
for (TypeMapper<?> argument : arguments) {
String s = argsList.remove(0);
if (argsList.isEmpty()) return argument.tabCompletes(commandSender, Arrays.copyOf(args, args.length - 1), s);
try {
if (argument.map(Arrays.copyOf(args, argsList.size()), s) == null) {
if (argument.map(Arrays.copyOf(args, index), s) == null) {
return null;
}
} catch (Exception e) {
return null;
}
index++;
}
if (varArgType != null && !argsList.isEmpty()) {
while (!argsList.isEmpty()) {
String s = argsList.remove(0);
if (argsList.isEmpty()) return arguments[arguments.length - 1].tabCompletes(commandSender, Arrays.copyOf(args, args.length - 1), s);
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;
}
} catch (Exception e) {
return null;
}
index++;
}
}
return null;