diff --git a/src/Player.php b/src/Player.php index ef0d3888..323bbfdb 100755 --- a/src/Player.php +++ b/src/Player.php @@ -963,7 +963,7 @@ class Player{ $this->blocked = true; $this->gamemode = $gm; $this->sendChat("Your gamemode has been changed to " . $this->getGamemode() . ", you've to do a forced reconnect.\n"); - $this->server->schedule(30, [$this, "close"], "gamemode change"); //Forces a kick + $this->server->schedule(30, [$this, "close"], "gamemode change", false, true); //Forces a kick } if($this->gamemode === SPECTATOR){ diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index 70afd14e..a5c46124 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -118,7 +118,6 @@ class PocketMinecraftServer{ $this->saveEnabled = true; $this->api->level->saveAll(); $this->saveEnabled = $save; - $this->send2Discord('[INFO] Server stopped!'); } public function startDatabase(){ @@ -203,7 +202,8 @@ class PocketMinecraftServer{ } if(($this->api instanceof ServerAPI) === true){ if(($this->api->chat instanceof ChatAPI) === true){ - $this->api->chat->broadcast("Stopping server..."); + $this->api->chat->send(false, "Stopping server..."); + new StopMessageThread($this, "[INFO] Stopping server..."); //broadcast didnt want to send message to discord for some reason } } $this->stop = true; @@ -215,7 +215,7 @@ class PocketMinecraftServer{ } } } - + public function send2Discord($msg){ if($this->extraprops->get("discord-msg") == true and $this->extraprops->get("discord-webhook-url") !== "none"){ $url = $this->extraprops->get("discord-webhook-url"); diff --git a/src/utils/StopMessageThread.php b/src/utils/StopMessageThread.php new file mode 100644 index 00000000..157a85ec --- /dev/null +++ b/src/utils/StopMessageThread.php @@ -0,0 +1,22 @@ +extraprops->get("discord-msg") == true and ($this->page = $server->extraprops->get("discord-webhook-url")) !== "none"){ + $this->msg = $server->extraprops->get("discord-ru-smiles") ? str_replace("@", " ", str_replace("Ы", "<:ru_cool:960113011383738369>", str_replace("Ь", "<:ru_cry:960112920346390548>", str_replace("Ъ", "<:ru_happy:960112868601237504>", $msg)))) : str_replace("@", "", $msg); + $this->name = $server->extraprops->get("discord-bot-name"); + $this->start(); + } + + } + + public function run(){ + Utils::curl_post($this->page, [ + "username" => $this->name, + "content" => $this->msg + ]); + } +} +