diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index f0716a663d..5c70f9a165 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -101,14 +101,13 @@ class ServerAPI{ "memory-limit" => "256M", "last-update" => false, "white-list" => false, - "debug" => 1, "spawn-protection" => 16, "view-distance" => 7, "max-players" => 20, "allow-flight" => false, "item-enforcement" => false, "server-type" => "normal", - "gamemode" => CREATIVE, + "gamemode" => SURVIVAL, "pvp" => true, "difficulty" => 1, "generator" => "", @@ -122,13 +121,13 @@ class ServerAPI{ "send-usage" => true, )); $this->parseProperties(); - define("DEBUG", $this->getProperty("debug")); + define("DEBUG", $this->getProperty("debug", 1)); if($this->getProperty("port") !== false){ $this->setProperty("server-port", $this->getProperty("port")); $this->config->remove("port"); $this->config->remove("invisible"); } - $this->server = new PocketMinecraftServer($this->getProperty("server-name"), $this->getProperty("gamemode"), false, $this->getProperty("server-port"), $this->getProperty("server-id"), $this->getProperty("server-ip")); + $this->server = new PocketMinecraftServer($this->getProperty("server-name"), $this->getProperty("gamemode"), false, $this->getProperty("server-port"), $this->getProperty("server-id"), $this->getProperty("server-ip", "0.0.0.0")); self::$serverRequest = $this->server; if($this->getProperty("server-id") != $this->server->serverID){ $this->setProperty("server-id", $this->server->serverID); @@ -212,7 +211,7 @@ class ServerAPI{ $this->gen->generate(); $this->gen->save($this->server->mapDir, $this->server->mapName); $this->setProperty("level-name", $this->server->mapName); - $this->setProperty("gamemode", CREATIVE); + $this->setProperty("gamemode", SURVIVAL); } $this->loadProperties(); $this->server->loadMap(); @@ -347,7 +346,7 @@ class ServerAPI{ } if($this->getProperty("enable-rcon") === true){ - $this->rcon = new RCON($this->getProperty("rcon.password", ""), $this->getProperty("server-port")); + $this->rcon = new RCON($this->getProperty("rcon.password", ""), $this->getProperty("server-port"), $this->getProperty("server-ip", "0.0.0.0")); } if($this->getProperty("enable-query") === true){ $this->query = new Query(); @@ -449,7 +448,7 @@ class ServerAPI{ return $this->config->getAll(); } - public function getProperty($name){ + public function getProperty($name, $default = false){ if(($v = arg($name)) !== false){ //Allow for command-line arguments switch(strtolower(trim($v))){ case "on": @@ -487,7 +486,7 @@ class ServerAPI{ } return $v; } - return $this->config->get($name); + return ($this->config->exists($name) ? $this->config->get($name):$default); } public function setProperty($name, $value){ diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index 32034a1f21..8199a50382 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -71,12 +71,12 @@ class PocketMinecraftServer{ $this->timePerSecond = 20; $this->tickMeasure = array_fill(0, 40, 0); $this->setType("normal"); - $this->interface = new MinecraftInterface("255.255.255.255", $this->port, true, false); + $this->interface = new MinecraftInterface("255.255.255.255", $this->port, true, false, $this->serverip); $this->reloadConfig(); $this->stop = false; } - function __construct($name, $gamemode = CREATIVE, $seed = false, $port = 19132, $serverID = false, $serverip = "0.0.0.0"){ + function __construct($name, $gamemode = SURVIVAL, $seed = false, $port = 19132, $serverID = false, $serverip = "0.0.0.0"){ $this->port = (int) $port; //19132 - 19135 $this->doTick = true; $this->gamemode = (int) $gamemode; diff --git a/src/network/Query.php b/src/network/Query.php index e450f2950a..df9fa3b4a0 100644 --- a/src/network/Query.php +++ b/src/network/Query.php @@ -40,7 +40,7 @@ class Query{ $this->threads = (int) max(1, $threads); $this->clientsPerThread = (int) max(1, $clientsPerThread); $this->server = ServerAPI::request(); - $addr = $this->server->api->getProperty("server-ip"); + $addr = $this->server->api->getProperty("server-ip", "0.0.0.0"); $port = $this->server->api->getProperty("server-port"); console("[INFO] Setting query port to $port"); $this->server->addHandler("server.unknownpacket", array($this, "packetHandler"), 50); @@ -72,7 +72,7 @@ class Query{ "numplayers" => count($this->server->clients), "maxplayers" => $this->server->maxClients, "hostport" => $this->server->api->getProperty("server-port"), - //"hostip" => $this->server->api->getProperty("server-ip") + //"hostip" => $this->server->api->getProperty("server-ip", "0.0.0.0") ); foreach($KVdata as $key => $value){ $str .= $key."\x00".$value."\x00"; @@ -121,7 +121,7 @@ class Query{ } $this->server->send(0, chr(0).Utils::writeInt($sessionID).$this->longData, true, $packet["ip"], $packet["port"]); }else{ - $this->server->send(0, chr(0).Utils::writeInt($sessionID).$this->server->name."\x00SMP\x00".$this->server->mapName."\x00".count($this->server->clients)."\x00".$this->server->maxClients."\x00".Utils::writeLShort($this->server->api->getProperty("server-port")).$this->server->api->getProperty("server-ip")."\x00", true, $packet["ip"], $packet["port"]); + $this->server->send(0, chr(0).Utils::writeInt($sessionID).$this->server->name."\x00SMP\x00".$this->server->mapName."\x00".count($this->server->clients)."\x00".$this->server->maxClients."\x00".Utils::writeLShort($this->server->api->getProperty("server-port")).$this->server->api->getProperty("server-ip", "0.0.0.0")."\x00", true, $packet["ip"], $packet["port"]); } break; }