summaryrefslogtreecommitdiffstats
path: root/src/Root.cpp
diff options
context:
space:
mode:
authorsweetgiorni <sweet.giorni@gmail.com>2017-01-03 19:57:31 +0100
committersweetgiorni <sweet.giorni@gmail.com>2017-01-03 20:15:34 +0100
commit25e4f15488c1f56c1571f4aefd216830e62ad52b (patch)
tree2946db2b152f9a67c4c8092e8f7f47532dd948d9 /src/Root.cpp
parentDebuggers: PluginStats are now output only on request. (#3513) (diff)
downloadcuberite-25e4f15488c1f56c1571f4aefd216830e62ad52b.tar
cuberite-25e4f15488c1f56c1571f4aefd216830e62ad52b.tar.gz
cuberite-25e4f15488c1f56c1571f4aefd216830e62ad52b.tar.bz2
cuberite-25e4f15488c1f56c1571f4aefd216830e62ad52b.tar.lz
cuberite-25e4f15488c1f56c1571f4aefd216830e62ad52b.tar.xz
cuberite-25e4f15488c1f56c1571f4aefd216830e62ad52b.tar.zst
cuberite-25e4f15488c1f56c1571f4aefd216830e62ad52b.zip
Diffstat (limited to 'src/Root.cpp')
-rw-r--r--src/Root.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Root.cpp b/src/Root.cpp
index 3d3930975..90e5cb9db 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -332,6 +332,22 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo)
void cRoot::StopServer()
{
+ // Kick all players from the server with custom disconnect message
+ class cPlayerCallback : public cPlayerListCallback
+ {
+ AString m_ShutdownMessage;
+ virtual bool Item(cPlayer * a_Player)
+ {
+ a_Player->GetClientHandlePtr()->Kick(m_ShutdownMessage);
+ return false;
+ }
+ public:
+ cPlayerCallback(AString a_ShutdownMessage) : m_ShutdownMessage(a_ShutdownMessage) {}
+ }PlayerCallback((m_Server->GetShutdownMessage()));
+
+ cRoot::Get()->ForEachPlayer(PlayerCallback);
+ // What's a better way to do this?
+ std::this_thread::sleep_for(std::chrono::seconds(1));
m_TerminateEventRaised = true;
m_StopEvent.Set();
m_InputThreadRunFlag.clear();