correct update player list
This commit is contained in:
@@ -6,6 +6,7 @@ package mc.core;
|
||||
|
||||
import mc.core.network.NetChannel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface PlayerManager {
|
||||
@@ -13,5 +14,6 @@ public interface PlayerManager {
|
||||
void joinServer(Player player);
|
||||
void leftServer(Player player);
|
||||
Optional<Player> getPlayer(String name);
|
||||
List<Player> getPlayers();
|
||||
NetChannel getBroadcastChannel();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import mc.core.network.NetChannel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
public class InMemoryPlayerManager implements PlayerManager, Runnable {
|
||||
@@ -60,6 +61,11 @@ public class InMemoryPlayerManager implements PlayerManager, Runnable {
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> getPlayers() {
|
||||
return players.stream().filter(Player::isOnline).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetChannel getBroadcastChannel() {
|
||||
return new BroadcastNetChannel(players.stream().filter(Player::isOnline));
|
||||
|
||||
Reference in New Issue
Block a user