mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-29 04:28:21 +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.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
@ -346,18 +345,10 @@ public final class ConnectionManager {
|
|||||||
DisconnectPacket disconnectPacket = new DisconnectPacket(shutdownText);
|
DisconnectPacket disconnectPacket = new DisconnectPacket(shutdownText);
|
||||||
for (Player player : getOnlinePlayers()) {
|
for (Player player : getOnlinePlayers()) {
|
||||||
final PlayerConnection playerConnection = player.getPlayerConnection();
|
final PlayerConnection playerConnection = player.getPlayerConnection();
|
||||||
if (playerConnection instanceof PlayerSocketConnection) {
|
playerConnection.sendPacket(disconnectPacket);
|
||||||
final PlayerSocketConnection socketConnection = (PlayerSocketConnection) playerConnection;
|
playerConnection.flush();
|
||||||
socketConnection.writeAndFlush(disconnectPacket);
|
player.remove();
|
||||||
playerConnection.disconnect();
|
playerConnection.disconnect();
|
||||||
try {
|
|
||||||
socketConnection.getChannel().close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
player.remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.players.clear();
|
this.players.clear();
|
||||||
this.connectionPlayerMap.clear();
|
this.connectionPlayerMap.clear();
|
||||||
|
@ -68,7 +68,7 @@ public final class Worker extends Thread {
|
|||||||
MinecraftServer.getConnectionManager().removePlayer(connection);
|
MinecraftServer.getConnectionManager().removePlayer(connection);
|
||||||
connection.refreshOnline(false);
|
connection.refreshOnline(false);
|
||||||
Player player = connection.getPlayer();
|
Player player = connection.getPlayer();
|
||||||
if (player != null) {
|
if (player != null && !player.isRemoved()) {
|
||||||
player.scheduleNextTick(Entity::remove);
|
player.scheduleNextTick(Entity::remove);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user