mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-15 06:45:04 +01:00
Kick and save connected players if the server crashes or shuts down
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package emu.lunarcore.server.game;
|
package emu.lunarcore.server.game;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import emu.lunarcore.Config.GameServerConfig;
|
import emu.lunarcore.Config.GameServerConfig;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarRail;
|
||||||
@@ -94,5 +96,13 @@ public class GameServer extends KcpServer {
|
|||||||
// Set region info
|
// Set region info
|
||||||
this.info.setUp(false);
|
this.info.setUp(false);
|
||||||
this.info.save();
|
this.info.save();
|
||||||
|
|
||||||
|
// Kick and save all players
|
||||||
|
List<Player> list = new ArrayList<>(players.size());
|
||||||
|
list.addAll(players.values());
|
||||||
|
|
||||||
|
for (Player player : list) {
|
||||||
|
player.getSession().close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user