Updated gamemode constant names

This commit is contained in:
Shoghi Cervantes Pueyo 2013-02-12 16:42:58 +01:00
parent 6c4670421c
commit 45192c4448
4 changed files with 17 additions and 17 deletions

View File

@ -162,7 +162,7 @@ class BlockAPI{
$target = $this->getBlock($vector); $target = $this->getBlock($vector);
$item = $player->equipment; $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); return $this->cancelAction($target);
} }
@ -184,7 +184,7 @@ class BlockAPI{
} }
public function drop($x, $y, $z, $block, $meta, $stack = 1){ 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; return;
} }
$data = array( $data = array(
@ -230,7 +230,7 @@ class BlockAPI{
return false; return false;
} }
} }
if($this->server->gamemode === 2){ //Adventure mode!! if($this->server->gamemode === ADVENTURE){ //Adventure mode!!
return $this->cancelAction($block); return $this->cancelAction($block);
} }
@ -299,7 +299,7 @@ class BlockAPI{
$t->data["creator"] = $player->username; $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); $player->removeItem($item->getID(), $item->getMetadata(), 1);
} }

View File

@ -64,7 +64,7 @@ class Player{
$this->inventory = array_fill(0, 36, array(AIR, 0, 0)); $this->inventory = array_fill(0, 36, array(AIR, 0, 0));
$this->armor = array_fill(0, 4, array(AIR, 0, 0)); $this->armor = array_fill(0, 4, array(AIR, 0, 0));
$this->gamemode = $this->server->gamemode; $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); $this->equipment = BlockAPI::getItem(AIR);
}else{ }else{
$this->equipment = BlockAPI::getItem(STONE); $this->equipment = BlockAPI::getItem(STONE);
@ -282,14 +282,14 @@ class Player{
} }
break; break;
case "player.block.place": 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); $this->removeItem($data["original"]->getID(), $data["original"]->getMetadata(), 1);
} }
break; break;
case "player.pickup": case "player.pickup":
if($data["eid"] === $this->eid){ if($data["eid"] === $this->eid){
$data["eid"] = 0; $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); $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->server->api->player->add($this->CID);
$this->auth = true; $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->data["inventory"] = $this->inventory;
} }
$this->inventory = &$this->data["inventory"]; $this->inventory = &$this->data["inventory"];
@ -608,7 +608,7 @@ class Player{
0x80 ? 0x80 ?
*/ */
$flags = 0; $flags = 0;
if($this->gamemode === 2){ if($this->gamemode === ADVENTURE){
$flags |= 0x01; //Not allow placing/breaking blocks $flags |= 0x01; //Not allow placing/breaking blocks
} }
$flags |= 0x20; //Nametags $flags |= 0x20; //Nametags
@ -652,7 +652,7 @@ class Player{
$data["eid"] = $this->eid; $data["eid"] = $this->eid;
if(Utils::distance($this->entity->position, $data) > 10){ if(Utils::distance($this->entity->position, $data) > 10){
break; 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); console("[DEBUG] Player \"".$this->username."\" tried to place not got block (or crafted block)", true, true, 2);
//break; //break;
} }
@ -710,7 +710,7 @@ class Player{
if($this->loggedIn === false){ if($this->loggedIn === false){
break; break;
} }
if($this->gamemode === 1){ if($this->gamemode === CREATIVE){
break; break;
} }
//$this->entity->setHealth($data["health"], "client"); //$this->entity->setHealth($data["health"], "client");

View File

@ -81,7 +81,7 @@ class PocketMinecraftServer{
$this->stop = false; $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->port = (int) $port; //19132 - 19135
$this->gamemode = (int) $gamemode; $this->gamemode = (int) $gamemode;
$this->name = $name; $this->name = $name;
@ -299,11 +299,11 @@ class PocketMinecraftServer{
public function getGamemode(){ public function getGamemode(){
switch($this->gamemode){ switch($this->gamemode){
case 0: case SURVIVAL:
return "survival"; return "survival";
case 1: case CREATIVE:
return "creative"; return "creative";
case 2: case ADVENTURE:
return "adventure"; return "adventure";
} }
} }
@ -548,7 +548,7 @@ class PocketMinecraftServer{
$data[0], $data[0],
$this->serverID, $this->serverID,
MAGIC, 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"]); ), false, $packet["ip"], $packet["port"]);
$this->custom["times_".$CID] = ($this->custom["times_".$CID] + 1) % strlen($this->description); $this->custom["times_".$CID] = ($this->custom["times_".$CID] + 1) % strlen($this->description);
break; break;

View File

@ -32,7 +32,7 @@ class BedrockBlock extends SolidBlock{
} }
public function isBreakable(Item $item, Player $player){ public function isBreakable(Item $item, Player $player){
if($player->gamemode === 1){ if($player->gamemode === CREATIVE){
return true; return true;
} }
return false; return false;