mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-27 02:21:38 +01:00
Small synchronization optimization
This commit is contained in:
parent
501ed1f0b2
commit
765c5be642
@ -23,6 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.function.Consumer;
|
||||
@ -33,7 +34,7 @@ import java.util.function.Consumer;
|
||||
public final class ConnectionManager {
|
||||
|
||||
private final Set<Player> players = new CopyOnWriteArraySet<>();
|
||||
private final Map<PlayerConnection, Player> connectionPlayerMap = Collections.synchronizedMap(new HashMap<>());
|
||||
private final Map<PlayerConnection, Player> connectionPlayerMap = new ConcurrentHashMap<>();
|
||||
|
||||
// All the consumers to call once a packet is received
|
||||
private final List<ClientPacketConsumer> receiveClientPacketConsumers = new CopyOnWriteArrayList<>();
|
||||
@ -346,7 +347,7 @@ public final class ConnectionManager {
|
||||
* @param connection the player connection
|
||||
* @see PlayerConnection#disconnect() to properly disconnect a player
|
||||
*/
|
||||
public synchronized void removePlayer(@NotNull PlayerConnection connection) {
|
||||
public void removePlayer(@NotNull PlayerConnection connection) {
|
||||
final Player player = this.connectionPlayerMap.get(connection);
|
||||
if (player == null)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user