mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 20:18:10 +01:00
Call Player#remove on server shutdown
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
5a4fc95ffd
commit
e97f1db184
@ -23,7 +23,6 @@ import net.minestom.server.utils.validate.Check;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
@ -346,18 +345,10 @@ public final class ConnectionManager {
|
||||
DisconnectPacket disconnectPacket = new DisconnectPacket(shutdownText);
|
||||
for (Player player : getOnlinePlayers()) {
|
||||
final PlayerConnection playerConnection = player.getPlayerConnection();
|
||||
if (playerConnection instanceof PlayerSocketConnection) {
|
||||
final PlayerSocketConnection socketConnection = (PlayerSocketConnection) playerConnection;
|
||||
socketConnection.writeAndFlush(disconnectPacket);
|
||||
playerConnection.disconnect();
|
||||
try {
|
||||
socketConnection.getChannel().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
player.remove();
|
||||
}
|
||||
playerConnection.sendPacket(disconnectPacket);
|
||||
playerConnection.flush();
|
||||
player.remove();
|
||||
playerConnection.disconnect();
|
||||
}
|
||||
this.players.clear();
|
||||
this.connectionPlayerMap.clear();
|
||||
|
@ -68,7 +68,7 @@ public final class Worker extends Thread {
|
||||
MinecraftServer.getConnectionManager().removePlayer(connection);
|
||||
connection.refreshOnline(false);
|
||||
Player player = connection.getPlayer();
|
||||
if (player != null) {
|
||||
if (player != null && !player.isRemoved()) {
|
||||
player.scheduleNextTick(Entity::remove);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user