diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index fa8e01d96c..5986146e2f 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -61,9 +61,10 @@ class ServerAPI{ "server-name" => "Minecraft PE Server", "description" => "Server made using PocketMine-MP", "motd" => "Welcome @player to this server!", - "server-invisible" => false, "server-ip" => "", "server-port" => 19132, + "server-type" => "normal", + "server-invisible" => false, "memory-limit" => "128M", "last-update" => false, "white-list" => false, @@ -72,7 +73,6 @@ class ServerAPI{ "max-players" => 20, "allow-flight" => false, "item-enforcement" => false, - "server-type" => "normal", "gamemode" => SURVIVAL, "pvp" => true, "difficulty" => 1, @@ -81,7 +81,7 @@ class ServerAPI{ "level-name" => "world", "level-seed" => "", "level-type" => "FLAT", - "enable-query" => false, + "enable-query" => true, "enable-rcon" => false, "rcon.password" => substr(base64_encode(Utils::getRandomBytes(20, false)), 3, 10), "send-usage" => true, diff --git a/src/Player.php b/src/Player.php index dd5d511ed0..7a4721ce5b 100644 --- a/src/Player.php +++ b/src/Player.php @@ -701,7 +701,8 @@ class Player{ case 0xa0: //NACK foreach($data[0] as $count){ if(isset($this->recovery[$count])){ - $this->directDataPacket($this->recovery[$count]["id"], $this->recovery[$count], $count, $this->recovery[$count]["pid"]); + $this->directDataPacket($this->recovery[$count]["id"], $this->recovery[$count], $this->recovery[$count]["pid"]); + unset($this->recovery[$count]); } } break; @@ -710,14 +711,14 @@ class Player{ if($count > $this->counter[2]){ $this->counter[2] = $count; } - $this->recovery[$count] = null; unset($this->recovery[$count]); } - $limit = microtime(true) - 2; //max lag + $limit = microtime(true) - 8; //max lag foreach($this->recovery as $count => $d){ $diff = $this->counter[2] - $count; if($diff > 16 and $d["sendtime"] < $limit){ - $this->directDataPacket($d["id"], $d, $count, $d["pid"]); + $this->directDataPacket($d["id"], $d, $d["pid"]); + unset($this->recovery[$count]); } } break; @@ -1376,7 +1377,6 @@ class Player{ if(count($this->recovery) >= PLAYER_RECOVERY_BUFFER){ reset($this->recovery); $k = key($this->recovery); - $this->recovery[$k] = null; unset($this->recovery[$k]); end($this->recovery); } @@ -1389,24 +1389,22 @@ class Player{ } } - public function directDataPacket($id, $data = array(), $count = false, $pid = 0x00){ + public function directDataPacket($id, $data = array(), $pid = 0x00){ if($this->connected === false){ return false; } $data["id"] = $id; $data["pid"] = $pid; $data["sendtime"] = microtime(true); - if($count === false){ - $count = $this->counter[0]++; - if(count($this->recovery) >= PLAYER_RECOVERY_BUFFER){ - reset($this->recovery); - $k = key($this->recovery); - $this->recovery[$k] = null; - unset($this->recovery[$k]); - end($this->recovery); - } - $this->recovery[$count] = $data; + $count = $this->counter[0]++; + if(count($this->recovery) >= PLAYER_RECOVERY_BUFFER){ + reset($this->recovery); + $k = key($this->recovery); + unset($this->recovery[$k]); + end($this->recovery); } + $this->recovery[$count] = $data; + $this->send(0x80, array( $count, $pid, diff --git a/src/network/MinecraftInterface.php b/src/network/MinecraftInterface.php index a27285e176..1d269ad38e 100644 --- a/src/network/MinecraftInterface.php +++ b/src/network/MinecraftInterface.php @@ -56,7 +56,12 @@ class MinecraftInterface{ $p .= Utils::hexdump($raw); if(is_array($data)){ foreach($data as $i => $d){ - $p .= $i ." => ".(!is_array($d) ? Protocol::$raknet[$pid][$i]."(".((Protocol::$raknet[$pid][$i] === "magic" or substr(Protocol::$raknet[$pid][$i], 0, 7) === "special" or is_int(Protocol::$raknet[$pid][$i])) ? Utils::strToHex($d):Utils::printable($d)).")":Protocol::$raknet[$pid][$i]."(\"".serialize(array_map("Utils::printable", $d))."\")").PHP_EOL; + if(!isset(Protocol::$raknet[$pid][$i])){ + $ty = "special"; + }else{ + $ty = Protocol::$raknet[$pid][$i]; + } + $p .= $i ." => ".(!is_array($d) ? $ty."(".(($ty === "magic" or substr($ty, 0, 7) === "special" or is_int($ty)) ? Utils::strToHex($d):Utils::printable((string) $d)).")":$ty."(\"".serialize(array_map("Utils::printable", $d))."\")").PHP_EOL; } } $p .= PHP_EOL;