mirror of
https://github.com/BGHDDevelopment/PlayerBalancer.git
synced 2024-11-09 04:20:32 +01:00
Using streams for getPlayers on SectionServer
This commit is contained in:
parent
e0e67eb2ce
commit
a6c7cdbfac
@ -1,7 +1,9 @@
|
||||
package com.jaimemartz.playerbalancer.section;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.jaimemartz.playerbalancer.settings.props.features.BalancerProps;
|
||||
import net.md_5.bungee.BungeeServerInfo;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
@ -9,6 +11,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class SectionServer extends BungeeServerInfo {
|
||||
private final BalancerProps props;
|
||||
@ -29,13 +34,10 @@ public class SectionServer extends BungeeServerInfo {
|
||||
@Override
|
||||
public Collection<ProxiedPlayer> getPlayers() {
|
||||
if (props.isShowPlayers()) {
|
||||
List<ProxiedPlayer> res = new ArrayList<>();
|
||||
section.getServers().forEach(server -> {
|
||||
res.addAll(server.getPlayers());
|
||||
});
|
||||
return res;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return section.getServers().stream()
|
||||
.map(ServerInfo::getPlayers)
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toList());
|
||||
} else return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user