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());
}
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()));
return new TypeMapper<Boolean>() {
@Override
public Boolean map(CommandSender commandSender, String[] previousArguments, String s) {
int index = tabCompletes.indexOf(s);
if (index == -1) {
return null;
}
return index != 0;
}
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] previousArguments, String s) {
return tabCompletes;
}
};
return createMapper(s -> {
int index = tabCompletes.indexOf(s);
return index == -1 ? null : index != 0;
}, (commandSender, s) -> 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()));
return new TypeMapper<Integer>() {
@Override
public Integer map(CommandSender commandSender, String[] previousArguments, String s) {
int index = tabCompletes.indexOf(s);
if (index == -1) {
return null;
}
return index;
}
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] previousArguments, String s) {
return tabCompletes;
}
};
return createMapper(s -> {
int index = tabCompletes.indexOf(s);
return index == -1 ? null : index;
}, (commandSender, s) -> tabCompletes);
}
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 -> {
long index = tabCompletes.indexOf(s);
return index == -1 ? null : index;
}, (commandSender, s) -> tabCompletes);
}
}
}