SteamWar/SpigotCore
Archiviert
13
0

Update SWCommandUtils and shorten the methods
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-02-01 11:16:33 +01:00
Ursprung 15a35ca5a7
Commit c33bc728ec

Datei anzeigen

@ -162,41 +162,26 @@ public class SWCommandUtils {
return createMapper(staticValue.value()); return createMapper(staticValue.value());
} }
if (staticValue.allowISE()) { if (staticValue.allowISE()) {
if (parameter.getType() == boolean.class && staticValue.value().length == 2) { if ((parameter.getType() == boolean.class || parameter.getType() == Boolean.class) && staticValue.value().length == 2) {
List<String> tabCompletes = new ArrayList<>(Arrays.asList(staticValue.value())); List<String> tabCompletes = new ArrayList<>(Arrays.asList(staticValue.value()));
return new TypeMapper<Boolean>() { return createMapper(s -> {
@Override int index = tabCompletes.indexOf(s);
public Boolean map(CommandSender commandSender, String[] previousArguments, String s) { return index == -1 ? null : index != 0;
int index = tabCompletes.indexOf(s); }, (commandSender, s) -> tabCompletes);
if (index == -1) {
return null;
}
return index != 0;
}
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] previousArguments, String s) {
return tabCompletes;
}
};
} }
if (parameter.getType() == int.class && staticValue.value().length >= 2) { if ((parameter.getType() == int.class || parameter.getType() == Integer.class) && staticValue.value().length >= 2) {
List<String> tabCompletes = new ArrayList<>(Arrays.asList(staticValue.value())); List<String> tabCompletes = new ArrayList<>(Arrays.asList(staticValue.value()));
return new TypeMapper<Integer>() { return createMapper(s -> {
@Override int index = tabCompletes.indexOf(s);
public Integer map(CommandSender commandSender, String[] previousArguments, String s) { return index == -1 ? null : index;
int index = tabCompletes.indexOf(s); }, (commandSender, s) -> tabCompletes);
if (index == -1) { }
return null; if ((parameter.getType() == long.class || parameter.getType() == Long.class) && staticValue.value().length >= 2) {
} List<String> tabCompletes = new ArrayList<>(Arrays.asList(staticValue.value()));
return index; return createMapper(s -> {
} long index = tabCompletes.indexOf(s);
return index == -1 ? null : index;
@Override }, (commandSender, s) -> tabCompletes);
public List<String> tabCompletes(CommandSender commandSender, String[] previousArguments, String s) {
return tabCompletes;
}
};
} }
} }
} }