CommandFramework3 #94
@ -21,10 +21,13 @@ package de.steamwar.command;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
@ -103,8 +106,33 @@ class SubCommand {
|
||||
}
|
||||
|
||||
List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||
|
||||
// TODO: implement tabCompleting for SubCommand
|
||||
return null;
|
||||
List<String> argsList = Arrays.asList(args);
|
||||
for (int i = 0; i < subCommand.length; i++) {
|
||||
String s = argsList.remove(0);
|
||||
if (argsList.isEmpty()) return Collections.singletonList(subCommand[i]);
|
||||
if (!subCommand[i].equals(s)) return Collections.emptyList();
|
||||
}
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
String s = argsList.remove(0);
|
||||
if (argsList.isEmpty()) return arguments[i].tabCompletes(s);
|
||||
try {
|
||||
arguments[i].map(s);
|
||||
} catch (Exception e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
if (varArgs && !argsList.isEmpty()) {
|
||||
while (!argsList.isEmpty()) {
|
||||
String s = argsList.remove(0);
|
||||
if (argsList.isEmpty()) return arguments[arguments.length - 1].tabCompletes(s);
|
||||
try {
|
||||
arguments[arguments.length - 1].map(s);
|
||||
} catch (Exception e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Entweder du behandelst im SWCommand nicht den Fall null, oder du returnst immer eine leere Liste. Bitte nicht beides zeitgleich.
Denn fall null behandle ich eigentlich wegen unsauberen TabCompletern, die eigengeschrieben sind.
Dann nutze doch auch einfach immer null.