mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-29 12:37:42 +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
|
* @param player the player to add
|
||||||
*/
|
*/
|
||||||
public void createPlayer(@NotNull Player player) {
|
public synchronized void createPlayer(@NotNull Player player) {
|
||||||
this.players.add(player);
|
this.players.add(player);
|
||||||
this.connectionPlayerMap.put(player.getPlayerConnection(), player);
|
this.connectionPlayerMap.put(player.getPlayerConnection(), player);
|
||||||
}
|
}
|
||||||
@ -296,7 +296,7 @@ public final class ConnectionManager {
|
|||||||
* @param connection the player connection
|
* @param connection the player connection
|
||||||
* @see PlayerConnection#disconnect() to properly disconnect a player
|
* @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);
|
final Player player = this.connectionPlayerMap.get(connection);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
|
@ -16,7 +16,7 @@ public class ClientChannel extends SimpleChannelInboundHandler<InboundPacket> {
|
|||||||
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(ClientChannel.class);
|
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;
|
private final PacketProcessor packetProcessor;
|
||||||
|
|
||||||
public ClientChannel(@NotNull PacketProcessor packetProcessor) {
|
public ClientChannel(@NotNull PacketProcessor packetProcessor) {
|
||||||
@ -55,7 +55,7 @@ public class ClientChannel extends SimpleChannelInboundHandler<InboundPacket> {
|
|||||||
Player player = playerConnection.getPlayer();
|
Player player = playerConnection.getPlayer();
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.remove();
|
player.remove();
|
||||||
connectionManager.removePlayer(playerConnection);
|
CONNECTION_MANAGER.removePlayer(playerConnection);
|
||||||
}
|
}
|
||||||
packetProcessor.removePlayerConnection(ctx);
|
packetProcessor.removePlayerConnection(ctx);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class NettyPlayerConnection extends PlayerConnection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
getChannel().close();
|
channel.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
Loading…
Reference in New Issue
Block a user