SteamWar/SpigotCore
Archiviert
13
0

Streamify SWCommand

Dieser Commit ist enthalten in:
yoyosource 2021-05-05 09:56:30 +02:00
Ursprung 06fb4bbc1a
Commit 259d6fef99

Datei anzeigen

@ -47,8 +47,8 @@ public abstract class SWCommand {
this.command = new Command(command, "", "/" + command, Arrays.asList(aliases)) { this.command = new Command(command, "", "/" + command, Arrays.asList(aliases)) {
@Override @Override
public boolean execute(CommandSender sender, String alias, String[] args) { public boolean execute(CommandSender sender, String alias, String[] args) {
// if (commandList.stream().filter(s -> s.invoke(sender, args)).findFirst().isEmpty()) return false; // if (commandList.stream().filter(s -> s.invoke(sender, args)).findFirst().isPresent()) return false;
// if (commandHelpList.stream().filter(s -> s.invoke(sender, args)).findFirst().isEmpty()) return false; // if (commandHelpList.stream().filter(s -> s.invoke(sender, args)).findFirst().isPresent()) return false;
for (SubCommand subCommand : commandList) { for (SubCommand subCommand : commandList) {
if (subCommand.invoke(sender, args)) return false; if (subCommand.invoke(sender, args)) return false;
} }
@ -109,10 +109,7 @@ public abstract class SWCommand {
if (clazz.isEnum() && mapper == null && !SWCommandUtils.MAPPER_FUNCTIONS.containsKey(clazz.getTypeName())) { if (clazz.isEnum() && mapper == null && !SWCommandUtils.MAPPER_FUNCTIONS.containsKey(clazz.getTypeName())) {
continue; continue;
} }
String name = clazz.getTypeName(); String name = mapper != null ? mapper.value() : clazz.getTypeName();
if (mapper != null) {
name = mapper.value();
}
if (!SWCommandUtils.MAPPER_FUNCTIONS.containsKey(name) && !localTypeMapper.containsKey(name)) { if (!SWCommandUtils.MAPPER_FUNCTIONS.containsKey(name) && !localTypeMapper.containsKey(name)) {
Bukkit.getLogger().log(Level.WARNING, "The parameter '" + parameter.toString() + "' is using an unsupported Mapper of type '" + name + "'"); Bukkit.getLogger().log(Level.WARNING, "The parameter '" + parameter.toString() + "' is using an unsupported Mapper of type '" + name + "'");
return; return;
@ -126,9 +123,8 @@ public abstract class SWCommand {
if (compare != 0) { if (compare != 0) {
return compare; return compare;
} else { } else {
int i1 = o1.varArgType != null ? Integer.MAX_VALUE : o1.arguments.length; return Integer.compare(o1.varArgType != null ? Integer.MAX_VALUE : o1.arguments.length,
int i2 = o2.varArgType != null ? Integer.MAX_VALUE : o2.arguments.length; o2.varArgType != null ? Integer.MAX_VALUE : o2.arguments.length);
return Integer.compare(i1, i2);
} }
}); });
commandHelpList.sort(Comparator.comparingInt(o -> -o.subCommand.length)); commandHelpList.sort(Comparator.comparingInt(o -> -o.subCommand.length));