mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 03:57:50 +01:00
Prevent potential synchronization issue while removing client cache
This commit is contained in:
parent
8b526bcabe
commit
ddaa3a6678
@ -268,7 +268,7 @@ public final class ConnectionManager {
|
||||
*
|
||||
* @param player the player to add
|
||||
*/
|
||||
public void createPlayer(@NotNull Player player) {
|
||||
public synchronized void createPlayer(@NotNull Player player) {
|
||||
this.players.add(player);
|
||||
this.connectionPlayerMap.put(player.getPlayerConnection(), player);
|
||||
}
|
||||
@ -296,7 +296,7 @@ public final class ConnectionManager {
|
||||
* @param connection the player connection
|
||||
* @see PlayerConnection#disconnect() to properly disconnect a player
|
||||
*/
|
||||
public void removePlayer(@NotNull PlayerConnection connection) {
|
||||
public synchronized void removePlayer(@NotNull PlayerConnection connection) {
|
||||
final Player player = this.connectionPlayerMap.get(connection);
|
||||
if (player == null)
|
||||
return;
|
||||
|
@ -16,7 +16,7 @@ public class ClientChannel extends SimpleChannelInboundHandler<InboundPacket> {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(ClientChannel.class);
|
||||
|
||||
private final ConnectionManager connectionManager = MinecraftServer.getConnectionManager();
|
||||
private final static ConnectionManager CONNECTION_MANAGER = MinecraftServer.getConnectionManager();
|
||||
private final PacketProcessor packetProcessor;
|
||||
|
||||
public ClientChannel(@NotNull PacketProcessor packetProcessor) {
|
||||
@ -55,7 +55,7 @@ public class ClientChannel extends SimpleChannelInboundHandler<InboundPacket> {
|
||||
Player player = playerConnection.getPlayer();
|
||||
if (player != null) {
|
||||
player.remove();
|
||||
connectionManager.removePlayer(playerConnection);
|
||||
CONNECTION_MANAGER.removePlayer(playerConnection);
|
||||
}
|
||||
packetProcessor.removePlayerConnection(ctx);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class NettyPlayerConnection extends PlayerConnection {
|
||||
|
||||
@Override
|
||||
public void disconnect() {
|
||||
getChannel().close();
|
||||
channel.close();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
Loading…
Reference in New Issue
Block a user