From 6e2f7af6b4703812fe7eb0c53a6baea8e5279f7a Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Wed, 29 May 2013 22:58:43 +0200 Subject: [PATCH] Added hardcore mode --- src/API/ServerAPI.php | 1 + src/network/Query.php | 4 ++-- src/world/Entity.php | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index 699fa90a21..ffc766994e 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -74,6 +74,7 @@ class ServerAPI{ "allow-flight" => false, "item-enforcement" => false, "gamemode" => SURVIVAL, + "hardcore" => false, "pvp" => true, "difficulty" => 1, "generator" => "", diff --git a/src/network/Query.php b/src/network/Query.php index e0dc3be073..05fa0d7eeb 100644 --- a/src/network/Query.php +++ b/src/network/Query.php @@ -69,7 +69,7 @@ class Query{ $KVdata = array( "splitnum" => chr(128), "hostname" => $this->server->name, - "gametype" => "SMP", + "gametype" => ($this->server->gamemode & 0x01) === 0 ? "SMP":"CMP", "game_id" => "MINECRAFTPE", "version" => CURRENT_MINECRAFT_VERSION, "plugins" => $plist, @@ -127,7 +127,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->api->level->getDefault()->getName()."\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"]); + $this->server->send(0, chr(0).Utils::writeInt($sessionID).$this->server->name."\x00".(($this->server->gamemode & 0x01) === 0 ? "SMP":"CMP")."\x00".$this->server->api->level->getDefault()->getName()."\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; } diff --git a/src/world/Entity.php b/src/world/Entity.php index b8f10d0d57..2d424f6b8f 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -797,6 +797,9 @@ class Entity extends Position{ if($this->player instanceof Player){ $this->player->blocked = true; $this->server->api->dhandle("player.death", array("player" => $this->player, "cause" => $cause)); + if(($this->player->gamemode & 0x01) === 0 and $this->server->api->getProperty("hardcore") == 1){ + $this->server->api->ban->ban($this->player->username); + } }else{ $this->close(); }