SteamWar/SpigotCore
Archiviert
13
0

Update SWCommandUtils and shorten the methods #163

Zusammengeführt
Lixfel hat 1 Commits von SWCommandUtilsShortening nach master 2022-02-01 11:25:33 +01:00 zusammengeführt

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);
}
}
}