From 45192c44486a83331edd7e5b9fe6fd1772686723 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Tue, 12 Feb 2013 16:42:58 +0100 Subject: [PATCH] Updated gamemode constant names --- src/API/BlockAPI.php | 8 ++++---- src/classes/Player.php | 14 +++++++------- src/classes/PocketMinecraftServer.php | 10 +++++----- src/classes/material/block/solid/Bedrock.php | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index bc3e11e25..cde14b68c 100644 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -162,7 +162,7 @@ class BlockAPI{ $target = $this->getBlock($vector); $item = $player->equipment; - if(!$target->isBreakable($item, $player) or $this->server->gamemode === 2){ + if(!$target->isBreakable($item, $player) or $this->server->gamemode === ADVENTURE){ return $this->cancelAction($target); } @@ -184,7 +184,7 @@ class BlockAPI{ } public function drop($x, $y, $z, $block, $meta, $stack = 1){ - if($block === AIR or $stack <= 0 or $this->server->gamemode === 1){ + if($block === AIR or $stack <= 0 or $this->server->gamemode === CREATIVE){ return; } $data = array( @@ -230,7 +230,7 @@ class BlockAPI{ return false; } } - if($this->server->gamemode === 2){ //Adventure mode!! + if($this->server->gamemode === ADVENTURE){ //Adventure mode!! return $this->cancelAction($block); } @@ -299,7 +299,7 @@ class BlockAPI{ $t->data["creator"] = $player->username; } - if($this->server->gamemode === 0 or $this->server->gamemode === 2){ + if($this->server->gamemode === SURVIVAL or $this->server->gamemode === ADVENTURE){ $player->removeItem($item->getID(), $item->getMetadata(), 1); } diff --git a/src/classes/Player.php b/src/classes/Player.php index bc4929206..af92cafb1 100644 --- a/src/classes/Player.php +++ b/src/classes/Player.php @@ -64,7 +64,7 @@ class Player{ $this->inventory = array_fill(0, 36, array(AIR, 0, 0)); $this->armor = array_fill(0, 4, array(AIR, 0, 0)); $this->gamemode = $this->server->gamemode; - if($this->gamemode === 0 or $this->gamemode === 2){ + if($this->gamemode === SURVIVAL or $this->gamemode === ADVENTURE){ $this->equipment = BlockAPI::getItem(AIR); }else{ $this->equipment = BlockAPI::getItem(STONE); @@ -282,14 +282,14 @@ class Player{ } break; case "player.block.place": - if($data["eid"] === $this->eid and ($this->gamemode === 0 or $this->gamemode === 2)){ + if($data["eid"] === $this->eid and ($this->gamemode === SURVIVAL or $this->gamemode === ADVENTURE)){ $this->removeItem($data["original"]->getID(), $data["original"]->getMetadata(), 1); } break; case "player.pickup": if($data["eid"] === $this->eid){ $data["eid"] = 0; - if(($this->gamemode === 0 or $this->gamemode === 2)){ + if(($this->gamemode === SURVIVAL or $this->gamemode === ADVENTURE)){ $this->addItem($data["entity"]->type, $data["entity"]->meta, $data["entity"]->stack); } } @@ -534,7 +534,7 @@ class Player{ } $this->server->api->player->add($this->CID); $this->auth = true; - if(!isset($this->data["inventory"]) or $this->gamemode === 1){ + if(!isset($this->data["inventory"]) or $this->gamemode === CREATIVE){ $this->data["inventory"] = $this->inventory; } $this->inventory = &$this->data["inventory"]; @@ -608,7 +608,7 @@ class Player{ 0x80 ? */ $flags = 0; - if($this->gamemode === 2){ + if($this->gamemode === ADVENTURE){ $flags |= 0x01; //Not allow placing/breaking blocks } $flags |= 0x20; //Nametags @@ -652,7 +652,7 @@ class Player{ $data["eid"] = $this->eid; if(Utils::distance($this->entity->position, $data) > 10){ break; - }elseif(($this->gamemode === 0 or $this->gamemode === 2) and !$this->hasItem($data["block"], $data["meta"])){ + }elseif(($this->gamemode === SURVIVAL or $this->gamemode === ADVENTURE) and !$this->hasItem($data["block"], $data["meta"])){ console("[DEBUG] Player \"".$this->username."\" tried to place not got block (or crafted block)", true, true, 2); //break; } @@ -710,7 +710,7 @@ class Player{ if($this->loggedIn === false){ break; } - if($this->gamemode === 1){ + if($this->gamemode === CREATIVE){ break; } //$this->entity->setHealth($data["health"], "client"); diff --git a/src/classes/PocketMinecraftServer.php b/src/classes/PocketMinecraftServer.php index 4212fbf82..b9fa464b8 100644 --- a/src/classes/PocketMinecraftServer.php +++ b/src/classes/PocketMinecraftServer.php @@ -81,7 +81,7 @@ class PocketMinecraftServer{ $this->stop = false; } - function __construct($name, $gamemode = 1, $seed = false, $port = 19132, $serverID = false, $serverip = "0.0.0.0"){ + function __construct($name, $gamemode = CREATIVE, $seed = false, $port = 19132, $serverID = false, $serverip = "0.0.0.0"){ $this->port = (int) $port; //19132 - 19135 $this->gamemode = (int) $gamemode; $this->name = $name; @@ -299,11 +299,11 @@ class PocketMinecraftServer{ public function getGamemode(){ switch($this->gamemode){ - case 0: + case SURVIVAL: return "survival"; - case 1: + case CREATIVE: return "creative"; - case 2: + case ADVENTURE: return "adventure"; } } @@ -548,7 +548,7 @@ class PocketMinecraftServer{ $data[0], $this->serverID, MAGIC, - $this->serverType. $this->name . " [".($this->gamemode === 1 ? "C":($this->gamemode === 2 ? "A":"S")).($this->whitelist !== false ? "W":"")." ".count($this->clients)."/".$this->maxClients."] ".$txt, + $this->serverType. $this->name . " [".($this->gamemode === CREATIVE ? "C":($this->gamemode === ADVENTURE ? "A":"S")).($this->whitelist !== false ? "W":"")." ".count($this->clients)."/".$this->maxClients."] ".$txt, ), false, $packet["ip"], $packet["port"]); $this->custom["times_".$CID] = ($this->custom["times_".$CID] + 1) % strlen($this->description); break; diff --git a/src/classes/material/block/solid/Bedrock.php b/src/classes/material/block/solid/Bedrock.php index 9487c26be..741871840 100644 --- a/src/classes/material/block/solid/Bedrock.php +++ b/src/classes/material/block/solid/Bedrock.php @@ -32,7 +32,7 @@ class BedrockBlock extends SolidBlock{ } public function isBreakable(Item $item, Player $player){ - if($player->gamemode === 1){ + if($player->gamemode === CREATIVE){ return true; } return false;