13
0
geforkt von Mirrors/Velocity

Remove potentially high-frequency usages of streams

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-09-27 02:37:53 -04:00
Ursprung 63f22dc2de
Commit d4910d9edc
2 geänderte Dateien mit 14 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -68,11 +68,14 @@ public class VelocityCommandManager implements CommandManager {
String alias = split[0]; String alias = split[0];
if (split.length == 1) { if (split.length == 1) {
return Optional.of(commands.entrySet().stream() List<String> availableCommands = new ArrayList<>();
.filter(ent -> ent.getKey().regionMatches(true, 0, alias, 0, alias.length())) for (Map.Entry<String, Command> entry : commands.entrySet()) {
.filter(ent -> ent.getValue().hasPermission(source, new String[0])) if (entry.getKey().regionMatches(true, 0, alias, 0, alias.length()) &&
.map(ent -> "/" + ent.getKey()) entry.getValue().hasPermission(source, new String[0])) {
.collect(Collectors.toList())); availableCommands.add("/" + entry.getKey());
}
}
return Optional.of(availableCommands);
} }
String[] actualArgs = Arrays.copyOfRange(split, 1, split.length); String[] actualArgs = Arrays.copyOfRange(split, 1, split.length);

Datei anzeigen

@ -7,6 +7,7 @@ import com.velocitypowered.api.proxy.messages.ChannelRegistrar;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -44,10 +45,11 @@ public class VelocityChannelRegistrar implements ChannelRegistrar {
} }
public Collection<String> getModernChannelIds() { public Collection<String> getModernChannelIds() {
return identifierMap.values().stream() Collection<String> ids = new ArrayList<>();
.filter(i -> i instanceof MinecraftChannelIdentifier) for (ChannelIdentifier value : identifierMap.values()) {
.map(ChannelIdentifier::getId) ids.add(value.getId());
.collect(Collectors.toList()); }
return ids;
} }
public boolean registered(String id) { public boolean registered(String id) {