SteamWar/SpigotCore
Archiviert
13
0

Merge pull request 'Update SWCommandUtils and shorten the methods' (#163) from SWCommandUtilsShortening into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #163
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2022-02-01 11:25:32 +01:00
Commit 9f78734f86

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