diff --git a/src/main/java/org/sculk/Server.java b/src/main/java/org/sculk/Server.java index e174de0..544da60 100644 --- a/src/main/java/org/sculk/Server.java +++ b/src/main/java/org/sculk/Server.java @@ -51,6 +51,7 @@ import java.nio.file.Paths; import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; import static org.sculk.Sculk.CODE_NAME; import static org.sculk.Sculk.CODE_VERSION; @@ -95,8 +96,7 @@ public class Server { private final Config banByName; private final Config banByIp; - private final Map playerList = new HashMap<>(); - private final Map players = new HashMap<>(); + private final Map playerList = new ConcurrentHashMap<>(); @Getter private String motd; @@ -238,7 +238,6 @@ public CompletableFuture createPlayer(SculkServerSession session, Client try { Constructor constructor = clazz.getConstructor(Server.class, SculkServerSession.class, ClientChainData.class, NbtMap.class); player = constructor.newInstance(this, session, info, NbtMap.EMPTY); - this.addPlayer(session.getSocketAddress(), player); } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { this.logger.warn(FAILED_TO_CREATE_PLAYER, e); throw new RuntimeException(e); @@ -258,12 +257,6 @@ private Path createDirectories(String dataPath, String... directories) { return Path.of(dataPath, directories[0]); } - public void broadcastPacket(BedrockPacket packet) { - for (Player player : this.players.values()) { - player.sendDataPacket(packet); - } - } - public EventManager getEventManager() { return eventManager; } @@ -347,10 +340,6 @@ public Operators getOperators() { return this.operators; } - public void addPlayer(SocketAddress socketAddress, Player player) { - this.players.put(socketAddress, player); - } - public boolean addOnlinePlayer(Player player) { PlayerLoginEvent event = new PlayerLoginEvent(player, "Plugin reason"); event.call();