From b6d86c287cfda9fad73a61f9c2a55a4c22a227df Mon Sep 17 00:00:00 2001 From: Humerus Date: Thu, 8 Aug 2013 22:58:32 -0400 Subject: [PATCH 1/2] Update ServerAPI.php --- src/API/ServerAPI.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index 17f0d8341..4f4af46f1 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -84,6 +84,7 @@ class ServerAPI{ "enable-rcon" => false, "rcon.password" => substr(base64_encode(Utils::getRandomBytes(20, false)), 3, 10), "send-usage" => true, + "auto-save" => true, )); $this->parseProperties(); @@ -179,6 +180,10 @@ class ServerAPI{ unset($this->asyncCalls[$id]); return $ob; } + public function autoSave(){ + console("[DEBUG] Saving...", true, true, 2); + $this->server->api->level->saveAll(); + } public function sendUsage(){ console("[DEBUG] Sending usage data...", true, true, 2); @@ -279,7 +284,9 @@ class ServerAPI{ $this->server->schedule(6000, array($this, "sendUsage"), array(), true); //Send the info after 5 minutes have passed $this->sendUsage(); } - + if($this->getProperty("auto-save") === true){ + $this->server->schedule(18000, array($this, "autoSave"), array(), true); + } if($this->getProperty("enable-rcon") === true){ $this->rcon = new RCON($this->getProperty("rcon.password", ""), $this->getProperty("rcon.port", $this->getProperty("server-port")), ($ip = $this->getProperty("server-ip")) != "" ? $ip:"0.0.0.0", $this->getProperty("rcon.threads", 1), $this->getProperty("rcon.clients-per-thread", 50)); } From 62b589295e7e4e6145109606289ec7d103f27aa5 Mon Sep 17 00:00:00 2001 From: Humerus Date: Thu, 8 Aug 2013 23:02:38 -0400 Subject: [PATCH 2/2] Enabled autosave --- src/API/ServerAPI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index 4f4af46f1..c91c23490 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -181,7 +181,7 @@ class ServerAPI{ return $ob; } public function autoSave(){ - console("[DEBUG] Saving...", true, true, 2); + console("[DEBUG] Saving....", true, true, 2); $this->server->api->level->saveAll(); }