Formatting code

This commit is contained in:
Shoghi Cervantes 2014-03-23 00:32:05 +01:00
parent af14c87572
commit 80cfa7cc84
126 changed files with 473 additions and 469 deletions

View File

@ -81,7 +81,7 @@ class BanAPI{
$username = strtolower($username); $username = strtolower($username);
if($this->server->api->dhandle("op.check", $username) === true){ if($this->server->api->dhandle("op.check", $username) === true){
return true; return true;
} elseif($this->ops->exists($username)){ }elseif($this->ops->exists($username)){
return true; return true;
} }
@ -121,7 +121,7 @@ class BanAPI{
if($this->server->api->handle("console.check", $data) === true or $this->isOp($data["issuer"]->getUsername())){ if($this->server->api->handle("console.check", $data) === true or $this->isOp($data["issuer"]->getUsername())){
return; return;
} }
} elseif($data["issuer"] === "console" or $data["issuer"] === "rcon"){ }elseif($data["issuer"] === "console" or $data["issuer"] === "rcon"){
return; return;
} }
@ -185,12 +185,12 @@ class BanAPI{
case "kick": case "kick":
if(!isset($params[0])){ if(!isset($params[0])){
$output .= "Usage: /kick <player> [reason ...]\n"; $output .= "Usage: /kick <player> [reason ...]\n";
} else{ }else{
$name = strtolower(array_shift($params)); $name = strtolower(array_shift($params));
$player = Player::get($name); $player = Player::get($name);
if($player === false){ if($player === false){
$output .= "Player \"" . $name . "\" does not exist\n"; $output .= "Player \"" . $name . "\" does not exist\n";
} else{ }else{
$reason = implode(" ", $params); $reason = implode(" ", $params);
$reason = $reason == "" ? "No reason" : $reason; $reason = $reason == "" ? "No reason" : $reason;
@ -198,7 +198,7 @@ class BanAPI{
$player->blocked = true; $player->blocked = true;
if($issuer instanceof Player){ if($issuer instanceof Player){
Player::broadcastChat($player->getUsername() . " has been kicked by " . $issuer->getUsername() . ": $reason\n"); Player::broadcastChat($player->getUsername() . " has been kicked by " . $issuer->getUsername() . ": $reason\n");
} else{ }else{
Player::broadcastChat($player->getUsername() . " has been kicked: $reason\n"); Player::broadcastChat($player->getUsername() . " has been kicked: $reason\n");
} }
} }
@ -296,7 +296,7 @@ class BanAPI{
} }
if($issuer instanceof Player){ if($issuer instanceof Player){
Player::broadcastChat($user . " has been banned by " . $issuer->getUsername() . "\n"); Player::broadcastChat($user . " has been banned by " . $issuer->getUsername() . "\n");
} else{ }else{
Player::broadcastChat($user . " has been banned\n"); Player::broadcastChat($user . " has been banned\n");
} }
$this->kick($user, "Banned"); $this->kick($user, "Banned");
@ -368,9 +368,9 @@ class BanAPI{
public function isIPBanned($ip){ public function isIPBanned($ip){
if($this->server->api->dhandle("api.ban.ip.check", $ip) === false){ if($this->server->api->dhandle("api.ban.ip.check", $ip) === false){
return true; return true;
} elseif($this->bannedIPs->exists($ip, true)){ }elseif($this->bannedIPs->exists($ip, true)){
return true; return true;
} else{ }else{
return false; return false;
} }
} }
@ -384,9 +384,9 @@ class BanAPI{
$username = strtolower($username); $username = strtolower($username);
if($this->server->api->dhandle("api.ban.check", $username) === false){ if($this->server->api->dhandle("api.ban.check", $username) === false){
return true; return true;
} elseif($this->banned->exists($username, true)){ }elseif($this->banned->exists($username, true)){
return true; return true;
} else{ }else{
return false; return false;
} }
} }
@ -400,9 +400,9 @@ class BanAPI{
$username = strtolower($username); $username = strtolower($username);
if($this->isOp($username)){ if($this->isOp($username)){
return true; return true;
} elseif($this->server->api->dhandle("api.ban.whitelist.check", $username) === false){ }elseif($this->server->api->dhandle("api.ban.whitelist.check", $username) === false){
return true; return true;
} elseif($this->whitelist->exists($username, true)){ }elseif($this->whitelist->exists($username, true)){
return true; return true;
} }

View File

@ -248,7 +248,7 @@ class BlockAPI{
if(!isset($params[2])){ if(!isset($params[2])){
$item->setCount($item->getMaxStackSize()); $item->setCount($item->getMaxStackSize());
} else{ }else{
$item->setCount((int) $params[2]); $item->setCount((int) $params[2]);
} }
@ -263,7 +263,7 @@ class BlockAPI{
} }
$player->addItem(clone $item); $player->addItem(clone $item);
$output .= "Giving " . $item->getCount() . " of " . $item->getName() . " (" . $item->getID() . ":" . $item->getMetadata() . ") to " . $player->getUsername() . "\n"; $output .= "Giving " . $item->getCount() . " of " . $item->getName() . " (" . $item->getID() . ":" . $item->getMetadata() . ") to " . $player->getUsername() . "\n";
} else{ }else{
$output .= "Unknown player.\n"; $output .= "Unknown player.\n";
} }
@ -281,7 +281,7 @@ class BlockAPI{
$this->scheduleBlockUpdate($pos->getSide(3), $delay, $type); $this->scheduleBlockUpdate($pos->getSide(3), $delay, $type);
$this->scheduleBlockUpdate($pos->getSide(4), $delay, $type); $this->scheduleBlockUpdate($pos->getSide(4), $delay, $type);
$this->scheduleBlockUpdate($pos->getSide(5), $delay, $type); $this->scheduleBlockUpdate($pos->getSide(5), $delay, $type);
} else{ }else{
$this->blockUpdate($pos->getSide(0), $type); $this->blockUpdate($pos->getSide(0), $type);
$this->blockUpdate($pos->getSide(1), $type); $this->blockUpdate($pos->getSide(1), $type);
$this->blockUpdate($pos->getSide(2), $type); $this->blockUpdate($pos->getSide(2), $type);
@ -294,7 +294,7 @@ class BlockAPI{
public function blockUpdate(Position $pos, $type = Level::BLOCK_UPDATE_NORMAL){ public function blockUpdate(Position $pos, $type = Level::BLOCK_UPDATE_NORMAL){
if(!($pos instanceof BLock\Block)){ if(!($pos instanceof BLock\Block)){
$block = $pos->level->getBlock($pos); $block = $pos->level->getBlock($pos);
} else{ }else{
$pos = new Position($pos->x, $pos->y, $pos->z, $pos->level); $pos = new Position($pos->x, $pos->y, $pos->z, $pos->level);
$block = $pos->level->getBlock($pos); $block = $pos->level->getBlock($pos);
} }

View File

@ -65,10 +65,10 @@ class ChatAPI{
if(!($issuer instanceof Player)){ if(!($issuer instanceof Player)){
if($issuer === "rcon"){ if($issuer === "rcon"){
$sender = "Rcon"; $sender = "Rcon";
} else{ }else{
$sender = ucfirst($issuer); $sender = ucfirst($issuer);
} }
} else{ }else{
$sender = $issuer->getUsername(); $sender = $issuer->getUsername();
} }
Player::broadcastChat("* $sender " . implode(" ", $params)); Player::broadcastChat("* $sender " . implode(" ", $params));
@ -80,7 +80,7 @@ class ChatAPI{
} }
if(!($issuer instanceof Player)){ if(!($issuer instanceof Player)){
$sender = ucfirst($issuer); $sender = ucfirst($issuer);
} else{ }else{
$sender = $issuer; $sender = $issuer;
} }
$n = array_shift($params); $n = array_shift($params);

View File

@ -142,7 +142,7 @@ class ConsoleAPI{
$curpage = (int) ceil($current / 5); $curpage = (int) ceil($current / 5);
if($curpage === $page){ if($curpage === $page){
$output .= "/$c " . $h . "\n"; $output .= "/$c " . $h . "\n";
} elseif($curpage > $page){ }elseif($curpage > $page){
break; break;
} }
++$current; ++$current;
@ -186,7 +186,7 @@ class ConsoleAPI{
} }
if($issuer instanceof Player){ if($issuer instanceof Player){
console("[DEBUG] " . TextFormat::AQUA . $issuer->getUsername() . TextFormat::RESET . " issued server command: " . ltrim("$alias ") . "/$cmd " . $params, true, true, 2); console("[DEBUG] " . TextFormat::AQUA . $issuer->getUsername() . TextFormat::RESET . " issued server command: " . ltrim("$alias ") . "/$cmd " . $params, true, true, 2);
} else{ }else{
console("[DEBUG] " . TextFormat::YELLOW . "*" . $issuer . TextFormat::RESET . " issued server command: " . ltrim("$alias ") . "/$cmd " . $params, true, true, 2); console("[DEBUG] " . TextFormat::YELLOW . "*" . $issuer . TextFormat::RESET . " issued server command: " . ltrim("$alias ") . "/$cmd " . $params, true, true, 2);
} }
@ -220,10 +220,10 @@ class ConsoleAPI{
foreach(Player::getAll() as $p){ foreach(Player::getAll() as $p){
$output .= $this->run($cmd . " " . substr_replace($params, $p->getUsername(), $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1), $issuer, $alias); $output .= $this->run($cmd . " " . substr_replace($params, $p->getUsername(), $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1), $issuer, $alias);
} }
} else{ }else{
$issuer->sendChat("You don't have permissions to use this command.\n"); $issuer->sendChat("You don't have permissions to use this command.\n");
} }
} else{ }else{
$output = ""; $output = "";
foreach(Player::getAll() as $p){ foreach(Player::getAll() as $p){
$output .= $this->run($cmd . " " . substr_replace($params, $p->getUsername(), $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1), $issuer, $alias); $output .= $this->run($cmd . " " . substr_replace($params, $p->getUsername(), $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1), $issuer, $alias);
@ -259,10 +259,10 @@ class ConsoleAPI{
or ($d2 = $this->server->api->dhandle("console.command", array("cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias))) === false or ($d2 = $this->server->api->dhandle("console.command", array("cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias))) === false
){ ){
$output = "You don't have permissions to use this command.\n"; $output = "You don't have permissions to use this command.\n";
} elseif($d1 !== true and (!isset($d2) or $d2 !== true)){ }elseif($d1 !== true and (!isset($d2) or $d2 !== true)){
if(isset($this->cmds[$cmd]) and is_callable($this->cmds[$cmd])){ if(isset($this->cmds[$cmd]) and is_callable($this->cmds[$cmd])){
$output = @call_user_func($this->cmds[$cmd], $cmd, $params, $issuer, $alias); $output = @call_user_func($this->cmds[$cmd], $cmd, $params, $issuer, $alias);
} elseif($this->server->api->dhandle("console.command.unknown", array("cmd" => $cmd, "params" => $params, "issuer" => $issuer, "alias" => $alias)) !== false){ }elseif($this->server->api->dhandle("console.command.unknown", array("cmd" => $cmd, "params" => $params, "issuer" => $issuer, "alias" => $alias)) !== false){
$output = $this->defaultCommands($cmd, $params, $issuer, $alias); $output = $this->defaultCommands($cmd, $params, $issuer, $alias);
} }
} }
@ -289,7 +289,7 @@ class ConsoleAPI{
console("[CMD] " . $m); console("[CMD] " . $m);
} }
} }
} else{ }else{
$this->loop->notify(); $this->loop->notify();
} }
} }
@ -316,7 +316,7 @@ class ConsoleLoop extends \Thread{
private function readLine(){ private function readLine(){
if($this->fp){ if($this->fp){
$line = trim(fgets($this->fp)); $line = trim(fgets($this->fp));
} else{ }else{
$line = trim(readline("")); $line = trim(readline(""));
if($line != ""){ if($line != ""){
readline_add_history($line); readline_add_history($line);

View File

@ -55,11 +55,11 @@ class LevelAPI{
case "seed": case "seed":
if(!isset($params[0]) and ($issuer instanceof Player)){ if(!isset($params[0]) and ($issuer instanceof Player)){
$output .= "Seed: " . $issuer->level->getSeed() . "\n"; $output .= "Seed: " . $issuer->level->getSeed() . "\n";
} elseif(isset($params[0])){ }elseif(isset($params[0])){
if(($lv = Level::get(trim(implode(" ", $params)))) !== false){ if(($lv = Level::get(trim(implode(" ", $params)))) !== false){
$output .= "Seed: " . $lv->getSeed() . "\n"; $output .= "Seed: " . $lv->getSeed() . "\n";
} }
} else{ }else{
$output .= "Seed: " . Level::getDefault()->getSeed() . "\n"; $output .= "Seed: " . Level::getDefault()->getSeed() . "\n";
} }
} }

View File

@ -22,8 +22,8 @@
namespace PocketMine; namespace PocketMine;
use PocketMine\Entity\RealHuman; use PocketMine\Entity\RealHuman;
use PocketMine\Event;
use PocketMine\Event\EventHandler; use PocketMine\Event\EventHandler;
use PocketMine\Event;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Level\Position; use PocketMine\Level\Position;
@ -83,7 +83,7 @@ use PocketMine\Utils\Utils;
class Player extends RealHuman{ class Player extends RealHuman{
const MAX_QUEUE = 2048; const MAX_QUEUE = 2048;
const SURVIVAL_SLOTS = 36; const SURVIVAL_SLOTS = 36;
const CREATIVE_SLOTS = 112; const CREATIVE_SLOTS = 112;
public static $list = array(); //???? public static $list = array(); //????
public $auth = false; public $auth = false;
public $CID; public $CID;
@ -246,7 +246,7 @@ const CREATIVE_SLOTS = 112;
} }
return; return;
} else{ }else{
unset($this->chunkCount[$count]); unset($this->chunkCount[$count]);
} }
} }
@ -492,7 +492,7 @@ const CREATIVE_SLOTS = 112;
public function setSpawn(Vector3 $pos){ public function setSpawn(Vector3 $pos){
if(!($pos instanceof Position)){ if(!($pos instanceof Position)){
$level = $this->level; $level = $this->level;
} else{ }else{
$level = $pos->level; $level = $pos->level;
} }
$this->spawnPosition = new Position($pos->x, $pos->y, $pos->z, $level); $this->spawnPosition = new Position($pos->x, $pos->y, $pos->z, $level);
@ -584,7 +584,7 @@ const CREATIVE_SLOTS = 112;
$this->awardAchievement("diamond"); $this->awardAchievement("diamond");
break; break;
} }
} elseif($data["entity"]->level === $this->level){ }elseif($data["entity"]->level === $this->level){
$pk = new TakeItemEntityPacket; $pk = new TakeItemEntityPacket;
$pk->eid = $data["eid"]; $pk->eid = $data["eid"];
$pk->target = $data["entity"]->getID(); $pk->target = $data["entity"]->getID();
@ -603,7 +603,7 @@ const CREATIVE_SLOTS = 112;
case "entity.metadata": case "entity.metadata":
if($data->getID() === $this->id){ if($data->getID() === $this->id){
$eid = 0; $eid = 0;
} else{ }else{
$eid = $data->getID(); $eid = $data->getID();
} }
if($data->level === $this->level){ if($data->level === $this->level){
@ -616,7 +616,7 @@ const CREATIVE_SLOTS = 112;
case "entity.event": case "entity.event":
if($data["entity"]->getID() === $this->id){ if($data["entity"]->getID() === $this->id){
$eid = 0; $eid = 0;
} else{ }else{
$eid = $data["entity"]->getID(); $eid = $data["entity"]->getID();
} }
if($data["entity"]->level === $this->level){ if($data["entity"]->level === $this->level){
@ -641,7 +641,7 @@ const CREATIVE_SLOTS = 112;
Achievement::broadcast($this, $achievementId); Achievement::broadcast($this, $achievementId);
return true; return true;
} else{ }else{
return false; return false;
} }
} }
@ -665,7 +665,7 @@ const CREATIVE_SLOTS = 112;
if(($this->gamemode & 0x01) === ($gm & 0x01)){ if(($this->gamemode & 0x01) === ($gm & 0x01)){
$this->gamemode = $gm; $this->gamemode = $gm;
$this->sendChat("Your gamemode has been changed to " . $this->getGamemode() . ".\n"); $this->sendChat("Your gamemode has been changed to " . $this->getGamemode() . ".\n");
} else{ }else{
$this->blocked = true; $this->blocked = true;
$this->gamemode = $gm; $this->gamemode = $gm;
$this->sendChat("Your gamemode has been changed to " . $this->getGamemode() . ", you've to do a forced reconnect.\n"); $this->sendChat("Your gamemode has been changed to " . $this->getGamemode() . ", you've to do a forced reconnect.\n");
@ -745,7 +745,7 @@ const CREATIVE_SLOTS = 112;
} }
if($this->packetStats[1] > 2){ if($this->packetStats[1] > 2){
$this->packetLoss = $this->packetStats[1] / max(1, $this->packetStats[0] + $this->packetStats[1]); $this->packetLoss = $this->packetStats[1] / max(1, $this->packetStats[0] + $this->packetStats[1]);
} else{ }else{
$this->packetLoss = 0; $this->packetLoss = 0;
} }
$this->packetStats = array(0, 0); $this->packetStats = array(0, 0);
@ -824,7 +824,7 @@ const CREATIVE_SLOTS = 112;
if(isset($p->messageIndex) and $p->messageIndex !== false){ if(isset($p->messageIndex) and $p->messageIndex !== false){
if($p->messageIndex > $this->receiveCount){ if($p->messageIndex > $this->receiveCount){
$this->receiveCount = $p->messageIndex; $this->receiveCount = $p->messageIndex;
} elseif($p->messageIndex !== 0){ }elseif($p->messageIndex !== 0){
if(isset($this->received[$p->messageIndex])){ if(isset($this->received[$p->messageIndex])){
continue; continue;
} }
@ -934,7 +934,7 @@ const CREATIVE_SLOTS = 112;
$pk = new LoginStatusPacket; $pk = new LoginStatusPacket;
$pk->status = 1; $pk->status = 1;
$this->directDataPacket($pk); $this->directDataPacket($pk);
} else{ }else{
$pk = new LoginStatusPacket; $pk = new LoginStatusPacket;
$pk->status = 2; $pk->status = 2;
$this->directDataPacket($pk); $this->directDataPacket($pk);
@ -959,7 +959,7 @@ const CREATIVE_SLOTS = 112;
$this->close($this->username . " has left the game", "Server is white-listed"); $this->close($this->username . " has left the game", "Server is white-listed");
return; return;
} elseif($this->server->api->ban->isBanned($this->iusername) or $this->server->api->ban->isIPBanned($this->ip)){ }elseif($this->server->api->ban->isBanned($this->iusername) or $this->server->api->ban->isIPBanned($this->ip)){
$this->close($this->username . " has left the game", "You are banned"); $this->close($this->username . " has left the game", "You are banned");
return; return;
@ -1009,7 +1009,7 @@ const CREATIVE_SLOTS = 112;
if(($this->gamemode & 0x01) === 0x01){ if(($this->gamemode & 0x01) === 0x01){
$this->slot = 0; $this->slot = 0;
$this->hotbar[0] = 0; $this->hotbar[0] = 0;
} else{ }else{
$this->slot = $this->hotbar[0]; $this->slot = $this->hotbar[0];
} }
@ -1108,7 +1108,7 @@ const CREATIVE_SLOTS = 112;
if($this->forceMovement instanceof Vector3){ if($this->forceMovement instanceof Vector3){
if($this->forceMovement->distance($newPos) <= 0.7){ if($this->forceMovement->distance($newPos) <= 0.7){
$this->forceMovement = false; $this->forceMovement = false;
} else{ }else{
$this->setPosition($this->forceMovement); $this->setPosition($this->forceMovement);
} }
} }
@ -1132,7 +1132,7 @@ const CREATIVE_SLOTS = 112;
if($packet->slot === 0x28 or $packet->slot === 0){ //0 for 0.8.0 compatibility if($packet->slot === 0x28 or $packet->slot === 0){ //0 for 0.8.0 compatibility
$packet->slot = -1; //Air $packet->slot = -1; //Air
} else{ }else{
$packet->slot -= 9; //Get real block slot $packet->slot -= 9; //Get real block slot
} }
@ -1240,7 +1240,7 @@ const CREATIVE_SLOTS = 112;
$pk->meta = $block->getMetadata(); $pk->meta = $block->getMetadata();
$this->dataPacket($pk); $this->dataPacket($pk);
break; break;
} elseif($packet->face === 0xff and $this->server->handle("player.action", $data) !== false){ }elseif($packet->face === 0xff and $this->server->handle("player.action", $data) !== false){
$this->inAction = true; $this->inAction = true;
$this->startAction = microtime(true); $this->startAction = microtime(true);
//$this->updateMetadata(); //$this->updateMetadata();
@ -1365,7 +1365,7 @@ const CREATIVE_SLOTS = 112;
$s = $packet->slots[$i]; $s = $packet->slots[$i];
if($s === 0 or $s === 255){ if($s === 0 or $s === 255){
$s = Item::get(Item::AIR, 0, 0); $s = Item::get(Item::AIR, 0, 0);
} else{ }else{
$s = Item::get($s + 256, 0, 1); $s = Item::get($s + 256, 0, 1);
} }
$slot = $this->getArmorSlot($i); $slot = $this->getArmorSlot($i);
@ -1373,7 +1373,7 @@ const CREATIVE_SLOTS = 112;
if($this->setArmorSlot($i, Item::get(Item::AIR, 0, 0)) === false){ if($this->setArmorSlot($i, Item::get(Item::AIR, 0, 0)) === false){
$this->sendArmor(); $this->sendArmor();
$this->sendInventory(); $this->sendInventory();
} else{ }else{
$this->addItem($slot); $this->addItem($slot);
$packet->slots[$i] = 255; $packet->slots[$i] = 255;
} }
@ -1381,17 +1381,17 @@ const CREATIVE_SLOTS = 112;
if($this->setArmorSlot($i, $this->getSlot($sl)) === false){ if($this->setArmorSlot($i, $this->getSlot($sl)) === false){
$this->sendArmor(); $this->sendArmor();
$this->sendInventory(); $this->sendInventory();
} else{ }else{
$this->setSlot($sl, Item::get(Item::AIR, 0, 0)); $this->setSlot($sl, Item::get(Item::AIR, 0, 0));
} }
}elseif($s->getID() !== Item::AIR and $slot->getID() !== Item::AIR and ($slot->getID() !== $s->getID() or $slot->getMetadata() !== $s->getMetadata()) and ($sl = $this->hasItem($s, false)) !== false){ }elseif($s->getID() !== Item::AIR and $slot->getID() !== Item::AIR and ($slot->getID() !== $s->getID() or $slot->getMetadata() !== $s->getMetadata()) and ($sl = $this->hasItem($s, false)) !== false){
if($this->setArmorSlot($i, $this->getSlot($sl)) === false){ if($this->setArmorSlot($i, $this->getSlot($sl)) === false){
$this->sendArmor(); $this->sendArmor();
$this->sendInventory(); $this->sendInventory();
} else{ }else{
$this->setSlot($sl, $slot); $this->setSlot($sl, $slot);
} }
} else{ }else{
$packet->slots[$i] = 255; $packet->slots[$i] = 255;
} }
@ -1606,7 +1606,7 @@ const CREATIVE_SLOTS = 112;
$message = $packet->message; $message = $packet->message;
if($message{0} === "/"){ //Command if($message{0} === "/"){ //Command
$this->server->api->console->run(substr($message, 1), $this); $this->server->api->console->run(substr($message, 1), $this);
} else{ }else{
$ev = new Event\Player\PlayerChatEvent($this, $message); $ev = new Event\Player\PlayerChatEvent($this, $message);
if(EventHandler::callEvent($ev) !== Event\Event::DENY){ if(EventHandler::callEvent($ev) !== Event\Event::DENY){
Player::groupChat(sprintf($ev->getFormat(), $ev->getPlayer()->getUsername(), $ev->getMessage()), $ev->getRecipients()); Player::groupChat(sprintf($ev->getFormat(), $ev->getPlayer()->getUsername(), $ev->getMessage()), $ev->getRecipients());
@ -1631,7 +1631,7 @@ const CREATIVE_SLOTS = 112;
$pk->case2 = 0; $pk->case2 = 0;
Player::broadcastPacket($this->level->players, $pk); Player::broadcastPacket($this->level->players, $pk);
} }
} elseif($this->windows[$packet->windowid] instanceof Chest){ }elseif($this->windows[$packet->windowid] instanceof Chest){
$pk = new TileEventPacket; $pk = new TileEventPacket;
$pk->x = $this->windows[$packet->windowid]->x; $pk->x = $this->windows[$packet->windowid]->x;
$pk->y = $this->windows[$packet->windowid]->y; $pk->y = $this->windows[$packet->windowid]->y;
@ -1655,7 +1655,7 @@ const CREATIVE_SLOTS = 112;
if($this->lastCraft <= (microtime(true) - 1)){ if($this->lastCraft <= (microtime(true) - 1)){
if(isset($this->toCraft[-1])){ if(isset($this->toCraft[-1])){
$this->toCraft = array(-1 => $this->toCraft[-1]); $this->toCraft = array(-1 => $this->toCraft[-1]);
} else{ }else{
$this->toCraft = array(); $this->toCraft = array();
} }
$this->craftingItems = array(); $this->craftingItems = array();
@ -1668,14 +1668,14 @@ const CREATIVE_SLOTS = 112;
$use = Item::get($slot->getID(), $slot->getMetadata(), $slot->getCount() - $packet->item->getCount()); $use = Item::get($slot->getID(), $slot->getMetadata(), $slot->getCount() - $packet->item->getCount());
$this->craftingItems[$packet->slot] = $use; $this->craftingItems[$packet->slot] = $use;
$craft = true; $craft = true;
} elseif($slot->getCount() <= $packet->item->getCount() and ($slot->getID() === Item::AIR or ($slot->getID() === $packet->item->getID() and $slot->getMetadata() === $packet->item->getMetadata()))){ //Crafting final }elseif($slot->getCount() <= $packet->item->getCount() and ($slot->getID() === Item::AIR or ($slot->getID() === $packet->item->getID() and $slot->getMetadata() === $packet->item->getMetadata()))){ //Crafting final
$craftItem = Item::get($packet->item->getID(), $packet->item->getMetadata(), $packet->item->getCount() - $slot->getCount()); $craftItem = Item::get($packet->item->getID(), $packet->item->getMetadata(), $packet->item->getCount() - $slot->getCount());
if(count($this->toCraft) === 0){ if(count($this->toCraft) === 0){
$this->toCraft[-1] = 0; $this->toCraft[-1] = 0;
} }
$this->toCraft[$packet->slot] = $craftItem; $this->toCraft[$packet->slot] = $craftItem;
$craft = true; $craft = true;
} elseif(((count($this->toCraft) === 1 and isset($this->toCraft[-1])) or count($this->toCraft) === 0) and $slot->getCount() > 0 and $slot->getID() > Item::AIR and ($slot->getID() !== $packet->item->getID() or $slot->getMetadata() !== $packet->item->getMetadata())){ //Crafting final }elseif(((count($this->toCraft) === 1 and isset($this->toCraft[-1])) or count($this->toCraft) === 0) and $slot->getCount() > 0 and $slot->getID() > Item::AIR and ($slot->getID() !== $packet->item->getID() or $slot->getMetadata() !== $packet->item->getMetadata())){ //Crafting final
$craftItem = Item::get($packet->item->getID(), $packet->item->getMetadata(), $packet->item->getCount()); $craftItem = Item::get($packet->item->getID(), $packet->item->getMetadata(), $packet->item->getCount());
if(count($this->toCraft) === 0){ if(count($this->toCraft) === 0){
$this->toCraft[-1] = 0; $this->toCraft[-1] = 0;
@ -1694,12 +1694,12 @@ const CREATIVE_SLOTS = 112;
if($recipe === false){ if($recipe === false){
$this->sendInventory(); $this->sendInventory();
$this->toCraft = array(); $this->toCraft = array();
} else{ }else{
$this->toCraft = array(-1 => $this->toCraft[-1]); $this->toCraft = array(-1 => $this->toCraft[-1]);
} }
$this->craftingItems = array(); $this->craftingItems = array();
} }
} else{ }else{
$this->toCraft = array(); $this->toCraft = array();
$this->craftingItems = array(); $this->craftingItems = array();
} }
@ -1713,11 +1713,11 @@ const CREATIVE_SLOTS = 112;
$tile = $tiles[0]; $tile = $tiles[0];
$slotn = $packet->slot; $slotn = $packet->slot;
$offset = 0; $offset = 0;
} elseif($packet->slot >= Chest::SLOTS and $packet->slot <= (Chest::SLOTS << 1)){ }elseif($packet->slot >= Chest::SLOTS and $packet->slot <= (Chest::SLOTS << 1)){
$tile = $tiles[1]; $tile = $tiles[1];
$slotn = $packet->slot - Chest::SLOTS; $slotn = $packet->slot - Chest::SLOTS;
$offset = Chest::SLOTS; $offset = Chest::SLOTS;
} else{ }else{
break; break;
} }
@ -1748,12 +1748,12 @@ const CREATIVE_SLOTS = 112;
$this->sendInventory(); $this->sendInventory();
break; break;
} }
} elseif($slot->getCount() > $item->getCount()){ }elseif($slot->getCount() > $item->getCount()){
$it = clone $item; $it = clone $item;
$it->setCount($slot->getCount() - $item->getCount()); $it->setCount($slot->getCount() - $item->getCount());
$this->addItem($it); $this->addItem($it);
} }
} else{ }else{
if($this->removeItem($item) === false){ if($this->removeItem($item) === false){
$this->sendInventory(); $this->sendInventory();
break; break;
@ -1761,7 +1761,7 @@ const CREATIVE_SLOTS = 112;
$this->addItem($slot); $this->addItem($slot);
} }
$tile->setSlot($slotn, $item, true, $offset); $tile->setSlot($slotn, $item, true, $offset);
} else{ }else{
$tile = $this->windows[$packet->windowid]; $tile = $this->windows[$packet->windowid];
if( if(
!($tile instanceof Chest or $tile instanceof Furnace) !($tile instanceof Chest or $tile instanceof Furnace)
@ -1810,12 +1810,12 @@ const CREATIVE_SLOTS = 112;
$this->sendInventory(); $this->sendInventory();
break; break;
} }
} elseif($slot->getCount() > $item->getCount()){ }elseif($slot->getCount() > $item->getCount()){
$it = clone $item; $it = clone $item;
$it->setCount($slot->count - $item->count); $it->setCount($slot->count - $item->count);
$this->addItem($it); $this->addItem($it);
} }
} else{ }else{
if($this->removeItem($item) === false){ if($this->removeItem($item) === false){
$this->sendInventory(); $this->sendInventory();
break; break;
@ -1840,12 +1840,12 @@ const CREATIVE_SLOTS = 112;
if($t instanceof Sign){ if($t instanceof Sign){
if($t->namedtag->creator !== $this->username){ if($t->namedtag->creator !== $this->username){
$t->spawnTo($this); $t->spawnTo($this);
} else{ }else{
$nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt = new NBT(NBT::LITTLE_ENDIAN);
$nbt->read($packet->namedtag); $nbt->read($packet->namedtag);
if($nbt->id !== Tile::SIGN){ if($nbt->id !== Tile::SIGN){
$t->spawnTo($this); $t->spawnTo($this);
} else{ }else{
$t->setText($nbt->Text1, $nbt->Text2, $nbt->Text3, $nbt->Text4); $t->setText($nbt->Text1, $nbt->Text2, $nbt->Text3, $nbt->Text4);
} }
} }
@ -2037,7 +2037,7 @@ const CREATIVE_SLOTS = 112;
foreach(Player::$list as $player){ foreach(Player::$list as $player){
if($multiple === false and $player->iusername === $name){ if($multiple === false and $player->iusername === $name){
return $player; return $player;
} elseif(strpos($player->iusername, $name) !== false){ }elseif(strpos($player->iusername, $name) !== false){
$players[$player->CID] = $player; $players[$player->CID] = $player;
} }
} }
@ -2045,10 +2045,10 @@ const CREATIVE_SLOTS = 112;
if($multiple === false){ if($multiple === false){
if(count($players) > 0){ if(count($players) > 0){
return array_shift($players); return array_shift($players);
} else{ }else{
return false; return false;
} }
} else{ }else{
return $players; return $players;
} }
} }
@ -2149,16 +2149,17 @@ const CREATIVE_SLOTS = 112;
$nbt->Achievements[$achievement] = new Byte($achievement, $status == true ? 1 : 0); $nbt->Achievements[$achievement] = new Byte($achievement, $status == true ? 1 : 0);
} }
unlink(\PocketMine\DATA . "players/" . $iname . ".yml"); unlink(\PocketMine\DATA . "players/" . $iname . ".yml");
} else{ }else{
console("[NOTICE] Player data not found for \"" . $iname . "\", creating new profile"); console("[NOTICE] Player data not found for \"" . $iname . "\", creating new profile");
Player::saveOffline($name, $nbt); Player::saveOffline($name, $nbt);
} }
} else{ }else{
$nbt = new NBT(NBT::BIG_ENDIAN); $nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->readCompressed(file_get_contents(\PocketMine\DATA . "players/" . $iname . ".dat")); $nbt->readCompressed(file_get_contents(\PocketMine\DATA . "players/" . $iname . ".dat"));
$nbt = $nbt->getData(); $nbt = $nbt->getData();
} }
return $nbt; return $nbt;
} }
@ -2222,7 +2223,7 @@ const CREATIVE_SLOTS = 112;
$craftItem[0] = $item->getID(); $craftItem[0] = $item->getID();
if($item->getMetadata() !== $craftItem[1] and $craftItem[1] !== true){ if($item->getMetadata() !== $craftItem[1] and $craftItem[1] !== true){
$craftItem[1] = false; $craftItem[1] = false;
} else{ }else{
$craftItem[1] = $item->getMetadata(); $craftItem[1] = $item->getMetadata();
} }
$craftItem[2] += $item->getCount(); $craftItem[2] += $item->getCount();
@ -2234,7 +2235,7 @@ const CREATIVE_SLOTS = 112;
foreach($recipe as $slot => $item){ foreach($recipe as $slot => $item){
if(!isset($recipeItems[$item->getID()])){ if(!isset($recipeItems[$item->getID()])){
$recipeItems[$item->getID()] = array($item->getID(), $item->getMetadata(), $item->getCount()); $recipeItems[$item->getID()] = array($item->getID(), $item->getMetadata(), $item->getCount());
} else{ }else{
if($item->getMetadata() !== $recipeItems[$item->getID()][1]){ if($item->getMetadata() !== $recipeItems[$item->getID()][1]){
$recipeItems[$item->getID()][1] = false; $recipeItems[$item->getID()][1] = false;
} }
@ -2267,7 +2268,7 @@ const CREATIVE_SLOTS = 112;
$s = $this->getSlot($slot); $s = $this->getSlot($slot);
if($s->getCount() <= 0 or $s->getID() === Item::AIR){ if($s->getCount() <= 0 or $s->getID() === Item::AIR){
$this->setSlot($slot, Item::get($item->getID(), $item->getMetadata(), $item->getCount())); $this->setSlot($slot, Item::get($item->getID(), $item->getMetadata(), $item->getCount()));
} else{ }else{
$this->setSlot($slot, Item::get($item->getID(), $item->getMetadata(), $s->getCount() + $item->getCount())); $this->setSlot($slot, Item::get($item->getID(), $item->getMetadata(), $s->getCount() + $item->getCount()));
} }
@ -2424,6 +2425,4 @@ const CREATIVE_SLOTS = 112;
} }
} }

View File

@ -82,7 +82,7 @@ class PlayerAPI{
break; break;
} }
} }
} else{ }else{
switch($data["cause"]){ switch($data["cause"]){
case "cactus": case "cactus":
$message = " was pricked to death"; $message = " was pricked to death";
@ -140,10 +140,10 @@ class PlayerAPI{
$tg = array_shift($params); $tg = array_shift($params);
if(count($params) === 3 and substr($tg, 0, 2) === "w:"){ if(count($params) === 3 and substr($tg, 0, 2) === "w:"){
$target = Level::get(substr($tg, 2)); $target = Level::get(substr($tg, 2));
} else{ }else{
$target = Player::get($tg); $target = Player::get($tg);
} }
} else{ }else{
$target = $issuer; $target = $issuer;
} }
@ -155,19 +155,19 @@ class PlayerAPI{
if(count($params) === 3){ if(count($params) === 3){
if($target instanceof Level){ if($target instanceof Level){
$spawn = new Vector3(floatval(array_shift($params)), floatval(array_shift($params)), floatval(array_shift($params))); $spawn = new Vector3(floatval(array_shift($params)), floatval(array_shift($params)), floatval(array_shift($params)));
} else{ }else{
$spawn = new Position(floatval(array_shift($params)), floatval(array_shift($params)), floatval(array_shift($params)), $issuer->level); $spawn = new Position(floatval(array_shift($params)), floatval(array_shift($params)), floatval(array_shift($params)), $issuer->level);
} }
} else{ }else{
$spawn = new Position($issuer->entity->x, $issuer->entity->y, $issuer->entity->z, $issuer->entity->level); $spawn = new Position($issuer->entity->x, $issuer->entity->y, $issuer->entity->z, $issuer->entity->level);
} }
$target->setSpawn($spawn); $target->setSpawn($spawn);
if($target instanceof Level){ if($target instanceof Level){
$output .= "Spawnpoint of world " . $target->getName() . " set correctly!\n"; $output .= "Spawnpoint of world " . $target->getName() . " set correctly!\n";
} elseif($target !== $issuer){ }elseif($target !== $issuer){
$output .= "Spawnpoint of " . $target->getUsername() . " set correctly!\n"; $output .= "Spawnpoint of " . $target->getUsername() . " set correctly!\n";
} else{ }else{
$output .= "Spawnpoint set correctly!\n"; $output .= "Spawnpoint set correctly!\n";
} }
break; break;
@ -208,14 +208,14 @@ class PlayerAPI{
if(Player::get($params[1]) instanceof Player){ if(Player::get($params[1]) instanceof Player){
$player = Player::get($params[1]); $player = Player::get($params[1]);
$setgm = $params[0]; $setgm = $params[0];
} elseif(Player::get($params[0]) instanceof Player){ }elseif(Player::get($params[0]) instanceof Player){
$player = Player::get($params[0]); $player = Player::get($params[0]);
$setgm = $params[1]; $setgm = $params[1];
} else{ }else{
$output .= "Usage: /$cmd <mode> [player] or /$cmd [player] <mode>\n"; $output .= "Usage: /$cmd <mode> [player] or /$cmd [player] <mode>\n";
break; break;
} }
} elseif(isset($params[0])){ }elseif(isset($params[0])){
if(!(Player::get($params[0]) instanceof Player)){ if(!(Player::get($params[0]) instanceof Player)){
if($issuer instanceof Player){ if($issuer instanceof Player){
$setgm = $params[0]; $setgm = $params[0];
@ -237,36 +237,36 @@ class PlayerAPI{
if((!isset($params[1]) or substr($params[0], 0, 2) === "w:") and isset($params[0]) and ($issuer instanceof Player)){ if((!isset($params[1]) or substr($params[0], 0, 2) === "w:") and isset($params[0]) and ($issuer instanceof Player)){
$name = $issuer->getUsername(); $name = $issuer->getUsername();
$target = implode(" ", $params); $target = implode(" ", $params);
} elseif(isset($params[1]) and isset($params[0])){ }elseif(isset($params[1]) and isset($params[0])){
$name = array_shift($params); $name = array_shift($params);
$target = implode(" ", $params); $target = implode(" ", $params);
} else{ }else{
$output .= "Usage: /$cmd [target player] <destination player | w:world>\n"; $output .= "Usage: /$cmd [target player] <destination player | w:world>\n";
break; break;
} }
if($this->teleport($name, $target) !== false){ if($this->teleport($name, $target) !== false){
$output .= "\"$name\" teleported to \"$target\"\n"; $output .= "\"$name\" teleported to \"$target\"\n";
} else{ }else{
$output .= "Couldn't teleport.\n"; $output .= "Couldn't teleport.\n";
} }
} else{ }else{
if(!isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0]) and ($issuer instanceof Player)){ if(!isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0]) and ($issuer instanceof Player)){
$name = $issuer->getUsername(); $name = $issuer->getUsername();
$x = $params[0]; $x = $params[0];
$y = $params[1]; $y = $params[1];
$z = $params[2]; $z = $params[2];
} elseif(isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0])){ }elseif(isset($params[3]) and isset($params[2]) and isset($params[1]) and isset($params[0])){
$name = $params[0]; $name = $params[0];
$x = $params[1]; $x = $params[1];
$y = $params[2]; $y = $params[2];
$z = $params[3]; $z = $params[3];
} else{ }else{
$output .= "Usage: /$cmd [player] <x> <y> <z>\n"; $output .= "Usage: /$cmd [player] <x> <y> <z>\n";
break; break;
} }
if($this->tppos($name, $x, $y, $z)){ if($this->tppos($name, $x, $y, $z)){
$output .= "\"$name\" teleported to ($x, $y, $z)\n"; $output .= "\"$name\" teleported to ($x, $y, $z)\n";
} else{ }else{
$output .= "Couldn't teleport.\n"; $output .= "Couldn't teleport.\n";
} }
} }
@ -275,13 +275,13 @@ class PlayerAPI{
case "suicide": case "suicide":
if(!isset($params[0]) and ($issuer instanceof Player)){ if(!isset($params[0]) and ($issuer instanceof Player)){
$player = $issuer; $player = $issuer;
} else{ }else{
$player = Player::get($params[0]); $player = Player::get($params[0]);
} }
if($player instanceof Player){ if($player instanceof Player){
$player->harm(1000, "console", true); $player->harm(1000, "console", true);
$player->sendChat("Ouch. That looks like it hurt.\n"); $player->sendChat("Ouch. That looks like it hurt.\n");
} else{ }else{
$output .= "Usage: /$cmd [player]\n"; $output .= "Usage: /$cmd [player]\n";
} }
break; break;
@ -310,7 +310,7 @@ class PlayerAPI{
return $origin->teleport($lv->getSafeSpawn()); return $origin->teleport($lv->getSafeSpawn());
} }
} else{ }else{
return false; return false;
} }
} }

View File

@ -46,18 +46,18 @@ namespace PocketMine {
$className = array_pop($path); $className = array_pop($path);
if(count($path) > 0){ if(count($path) > 0){
$path = implode(DIRECTORY_SEPARATOR, array_map("strtolower", $path)) . DIRECTORY_SEPARATOR; $path = implode(DIRECTORY_SEPARATOR, array_map("strtolower", $path)) . DIRECTORY_SEPARATOR;
} else{ }else{
$path = ""; $path = "";
} }
$fPath = \PocketMine\PATH . "src" . DIRECTORY_SEPARATOR . "PocketMine" . DIRECTORY_SEPARATOR . $path . $className . ".php"; $fPath = \PocketMine\PATH . "src" . DIRECTORY_SEPARATOR . "PocketMine" . DIRECTORY_SEPARATOR . $path . $className . ".php";
if(file_exists($fPath)){ if(file_exists($fPath)){
require_once($fPath); require_once($fPath);
} }
} else{ //Try plugin }else{ //Try plugin
$className = array_pop($path); $className = array_pop($path);
if(count($path) > 0){ if(count($path) > 0){
$path = implode(DIRECTORY_SEPARATOR, array_map("strtolower", $path)) . DIRECTORY_SEPARATOR; $path = implode(DIRECTORY_SEPARATOR, array_map("strtolower", $path)) . DIRECTORY_SEPARATOR;
} else{ }else{
$path = ""; $path = "";
} }
$fPath = \PocketMine\PATH . "plugins" . DIRECTORY_SEPARATOR . $parent . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR . $path . $className . ".php"; $fPath = \PocketMine\PATH . "plugins" . DIRECTORY_SEPARATOR . $parent . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR . $path . $className . ".php";
@ -85,7 +85,7 @@ namespace PocketMine {
exec("date.exe /T", $date); exec("date.exe /T", $date);
$j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0]))); $j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0])));
$offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60; $offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60;
} else{ }else{
exec("date +%s", $t); exec("date +%s", $t);
$offset = round((intval(trim($t[0])) - time()) / 60) * 60; $offset = round((intval(trim($t[0])) - time()) / 60) * 60;
} }
@ -94,7 +94,7 @@ namespace PocketMine {
$d = timezone_name_from_abbr("", $offset, $daylight); $d = timezone_name_from_abbr("", $offset, $daylight);
@ini_set("date.timezone", $d); @ini_set("date.timezone", $d);
date_default_timezone_set($d); date_default_timezone_set($d);
} else{ }else{
$d = @date_default_timezone_get(); $d = @date_default_timezone_get();
if(strpos($d, "/") === false){ if(strpos($d, "/") === false){
$d = timezone_name_from_abbr($d); $d = timezone_name_from_abbr($d);
@ -118,7 +118,7 @@ namespace PocketMine {
if((strpos(strtoupper(php_uname("s")), "WIN") === false or isset($opts["enable-ansi"])) and !isset($opts["disable-ansi"])){ if((strpos(strtoupper(php_uname("s")), "WIN") === false or isset($opts["enable-ansi"])) and !isset($opts["disable-ansi"])){
define("PocketMine\\ANSI", true); define("PocketMine\\ANSI", true);
} else{ }else{
define("PocketMine\\ANSI", false); define("PocketMine\\ANSI", false);
} }
@ -182,13 +182,13 @@ namespace PocketMine {
} }
$var = null; $var = null;
unset($var); unset($var);
} elseif(is_array($var)){ }elseif(is_array($var)){
foreach($var as $i => $v){ foreach($var as $i => $v){
hard_unset($var[$i]); hard_unset($var[$i]);
} }
$var = null; $var = null;
unset($var); unset($var);
} else{ }else{
$var = null; $var = null;
unset($var); unset($var);
} }
@ -235,7 +235,7 @@ namespace PocketMine {
} }
} }
$message = Utils\TextFormat::toANSI($time . $add . $message . Utils\TextFormat::RESET); $message = Utils\TextFormat::toANSI($time . $add . $message . Utils\TextFormat::RESET);
} else{ }else{
$message = $replaced; $message = $replaced;
} }
echo $message; echo $message;
@ -332,7 +332,7 @@ namespace PocketMine {
if(!extension_loaded("pthreads")){ if(!extension_loaded("pthreads")){
console("[ERROR] Unable to find the pthreads extension.", true, true, 0); console("[ERROR] Unable to find the pthreads extension.", true, true, 0);
++$errors; ++$errors;
} else{ }else{
$pthreads_version = phpversion("pthreads"); $pthreads_version = phpversion("pthreads");
if(substr_count($pthreads_version, ".") < 2){ if(substr_count($pthreads_version, ".") < 2){
$pthreads_version = "0.$pthreads_version"; $pthreads_version = "0.$pthreads_version";
@ -371,7 +371,7 @@ namespace PocketMine {
$gitsha1 = false; $gitsha1 = false;
if(file_exists(\PocketMine\PATH . ".git/refs/heads/master")){ //Found Git information! if(file_exists(\PocketMine\PATH . ".git/refs/heads/master")){ //Found Git information!
define("PocketMine\\GIT_COMMIT", strtolower(trim(file_get_contents(\PocketMine\PATH . ".git/refs/heads/master")))); define("PocketMine\\GIT_COMMIT", strtolower(trim(file_get_contents(\PocketMine\PATH . ".git/refs/heads/master"))));
} else{ //Unknown :( }else{ //Unknown :(
define("PocketMine\\GIT_COMMIT", str_repeat("00", 20)); define("PocketMine\\GIT_COMMIT", str_repeat("00", 20));
} }

View File

@ -284,7 +284,7 @@ class Server{
if(is_array($this->async[$ID])){ if(is_array($this->async[$ID])){
$method = $this->async[$ID][1]; $method = $this->async[$ID][1];
$result = $this->async[$ID][0]->$method($data, $type, $ID); $result = $this->async[$ID][0]->$method($data, $type, $ID);
} else{ }else{
$result = $this->async[$ID]($data, $type, $ID); $result = $this->async[$ID]($data, $type, $ID);
} }
} }
@ -334,10 +334,10 @@ class Server{
if(is_array($handler)){ if(is_array($handler)){
$method = $handler[1]; $method = $handler[1];
$result = $handler[0]->$method($data, $event); $result = $handler[0]->$method($data, $event);
} else{ }else{
$result = $handler($data, $event); $result = $handler($data, $event);
} }
} else{ }else{
break; break;
} }
} }
@ -499,7 +499,7 @@ class Server{
$CID = Server::clientID($packet->ip, $packet->port); $CID = Server::clientID($packet->ip, $packet->port);
if(isset(Player::$list[$CID])){ if(isset(Player::$list[$CID])){
Player::$list[$CID]->handlePacket($packet); Player::$list[$CID]->handlePacket($packet);
} else{ }else{
switch($packet->pid()){ switch($packet->pid()){
case RakNetInfo::UNCONNECTED_PING: case RakNetInfo::UNCONNECTED_PING:
case RakNetInfo::UNCONNECTED_PING_OPEN_CONNECTIONS: case RakNetInfo::UNCONNECTED_PING_OPEN_CONNECTIONS:
@ -539,7 +539,7 @@ class Server{
$pk->ip = $packet->ip; $pk->ip = $packet->ip;
$pk->port = $packet->port; $pk->port = $packet->port;
$this->send($pk); $this->send($pk);
} else{ }else{
$pk = new RakNetPacket(RakNetInfo::OPEN_CONNECTION_REPLY_1); $pk = new RakNetPacket(RakNetInfo::OPEN_CONNECTION_REPLY_1);
$pk->serverID = $this->serverID; $pk->serverID = $this->serverID;
$pk->mtuSize = strlen($packet->buffer); $pk->mtuSize = strlen($packet->buffer);
@ -582,11 +582,11 @@ class Server{
++$lastLoop; ++$lastLoop;
if($lastLoop < 16){ if($lastLoop < 16){
usleep(1); usleep(1);
} elseif($lastLoop < 128){ }elseif($lastLoop < 128){
usleep(1000); usleep(1000);
} elseif($lastLoop < 256){ }elseif($lastLoop < 256){
usleep(2000); usleep(2000);
} else{ }else{
usleep(4000); usleep(4000);
} }
} }
@ -603,7 +603,7 @@ class Server{
if(is_array($ev)){ if(is_array($ev)){
$method = $ev[1]; $method = $ev[1];
$ev[0]->$method($data, $event); $ev[0]->$method($data, $event);
} else{ }else{
$ev($data, $event); $ev($data, $event);
} }
} }
@ -637,7 +637,7 @@ class Server{
$this->preparedSQL->updateAction->execute(); $this->preparedSQL->updateAction->execute();
if(!@is_callable($this->schedule[$cid][0])){ if(!@is_callable($this->schedule[$cid][0])){
$return = false; $return = false;
} else{ }else{
++$actionCount; ++$actionCount;
$return = call_user_func($this->schedule[$cid][0], $this->schedule[$cid][1], $this->schedule[$cid][2]); $return = call_user_func($this->schedule[$cid][0], $this->schedule[$cid][1], $this->schedule[$cid][2]);
} }
@ -657,7 +657,7 @@ class Server{
public function event($event, callable $func){ public function event($event, callable $func){
if(!is_callable($func)){ if(!is_callable($func)){
return false; return false;
} elseif(isset(Deprecation::$events[$event])){ }elseif(isset(Deprecation::$events[$event])){
$sub = ""; $sub = "";
if(Deprecation::$events[$event] !== false){ if(Deprecation::$events[$event] !== false){
$sub = " Substitute \"" . Deprecation::$events[$event] . "\" found."; $sub = " Substitute \"" . Deprecation::$events[$event] . "\" found.";

View File

@ -30,7 +30,6 @@ use PocketMine\Network\Query\QueryHandler;
use PocketMine\Network\RCON\RCON; use PocketMine\Network\RCON\RCON;
use PocketMine\Network\UPnP\UPnP; use PocketMine\Network\UPnP\UPnP;
use PocketMine\Plugin\PluginManager; use PocketMine\Plugin\PluginManager;
use PocketMine\PMF\Plugin;
use PocketMine\Recipes\Crafting; use PocketMine\Recipes\Crafting;
use PocketMine\Tile\Tile; use PocketMine\Tile\Tile;
use PocketMine\Utils\Config; use PocketMine\Utils\Config;
@ -169,7 +168,7 @@ class ServerAPI{
$info = json_decode(Utils::getURL("https://api.github.com/repos/PocketMine/PocketMine-MP/commits"), true); $info = json_decode(Utils::getURL("https://api.github.com/repos/PocketMine/PocketMine-MP/commits"), true);
if($info === false or !isset($info[0])){ if($info === false or !isset($info[0])){
console("[ERROR] Github API error"); console("[ERROR] Github API error");
} else{ }else{
$last = new \DateTime($info[0]["commit"]["committer"]["date"]); $last = new \DateTime($info[0]["commit"]["committer"]["date"]);
$last = $last->getTimestamp(); $last = $last->getTimestamp();
if($last >= $this->getProperty("last-update") and $this->getProperty("last-update") !== false and \PocketMine\GIT_COMMIT != $info[0]["sha"]){ if($last >= $this->getProperty("last-update") and $this->getProperty("last-update") !== false and \PocketMine\GIT_COMMIT != $info[0]["sha"]){
@ -177,16 +176,16 @@ class ServerAPI{
console("[NOTICE] " . TextFormat::YELLOW . "Commit \"" . $info[0]["commit"]["message"] . "\" [" . substr($info[0]["sha"], 0, 10) . "] by " . $info[0]["commit"]["committer"]["name"]); console("[NOTICE] " . TextFormat::YELLOW . "Commit \"" . $info[0]["commit"]["message"] . "\" [" . substr($info[0]["sha"], 0, 10) . "] by " . $info[0]["commit"]["committer"]["name"]);
console("[NOTICE] " . TextFormat::YELLOW . "Get it at PocketMine.net or at https://github.com/PocketMine/PocketMine-MP/archive/" . $info[0]["sha"] . ".zip"); console("[NOTICE] " . TextFormat::YELLOW . "Get it at PocketMine.net or at https://github.com/PocketMine/PocketMine-MP/archive/" . $info[0]["sha"] . ".zip");
console("[NOTICE] This message will disappear after issuing the command \"/update-done\""); console("[NOTICE] This message will disappear after issuing the command \"/update-done\"");
} else{ }else{
$this->setProperty("last-update", time()); $this->setProperty("last-update", time());
console("[INFO] " . TextFormat::AQUA . "This is the latest DEVELOPMENT version"); console("[INFO] " . TextFormat::AQUA . "This is the latest DEVELOPMENT version");
} }
} }
} else{ }else{
$info = json_decode(Utils::getURL("https://api.github.com/repos/PocketMine/PocketMine-MP/tags"), true); $info = json_decode(Utils::getURL("https://api.github.com/repos/PocketMine/PocketMine-MP/tags"), true);
if($info === false or !isset($info[0])){ if($info === false or !isset($info[0])){
console("[ERROR] Github API error"); console("[ERROR] Github API error");
} else{ }else{
$newest = new VersionString(VERSION); $newest = new VersionString(VERSION);
$newestN = $newest->getNumber(); $newestN = $newest->getNumber();
$update = new VersionString($info[0]["name"]); $update = new VersionString($info[0]["name"]);
@ -196,7 +195,7 @@ class ServerAPI{
console("[NOTICE] " . TextFormat::GREEN . "Version \"" . $info[0]["name"] . "\" #" . $updateN); console("[NOTICE] " . TextFormat::GREEN . "Version \"" . $info[0]["name"] . "\" #" . $updateN);
console("[NOTICE] Get it at PocketMine.net or at " . $info[0]["zipball_url"]); console("[NOTICE] Get it at PocketMine.net or at " . $info[0]["zipball_url"]);
console("[NOTICE] This message will disappear as soon as you update"); console("[NOTICE] This message will disappear as soon as you update");
} else{ }else{
$this->setProperty("last-update", time()); $this->setProperty("last-update", time());
console("[INFO] " . TextFormat::AQUA . "This is the latest STABLE version"); console("[INFO] " . TextFormat::AQUA . "This is the latest STABLE version");
} }
@ -222,7 +221,7 @@ class ServerAPI{
} }
} }
console("[INFO] Loaded ".count(PluginManager::loadPlugins(\PocketMine\DATA . "plugins/")). " plugin(s)."); console("[INFO] Loaded " . count(PluginManager::loadPlugins(\PocketMine\DATA . "plugins/")) . " plugin(s).");
} }
@ -314,7 +313,7 @@ class ServerAPI{
console("[WARNING] PocketMine-MP may not work right with less than 128MB of RAM", true, true, 0); console("[WARNING] PocketMine-MP may not work right with less than 128MB of RAM", true, true, 0);
} }
@ini_set("memory_limit", $memory); @ini_set("memory_limit", $memory);
} else{ }else{
$this->setProperty("memory-limit", "128M"); $this->setProperty("memory-limit", "128M");
} }
@ -339,7 +338,7 @@ class ServerAPI{
case "last-update": case "last-update":
if($v === false){ if($v === false){
$v = time(); $v = time();
} else{ }else{
$v = (int) $v; $v = (int) $v;
} }
break; break;
@ -464,7 +463,7 @@ class ServerAPI{
case "last-update": case "last-update":
if($v === false){ if($v === false){
$v = time(); $v = time();
} else{ }else{
$v = (int) $v; $v = (int) $v;
} }
break; break;

View File

@ -116,11 +116,11 @@ class TimeAPI{
$time = !is_integer($time) ? $this->get(false, $time) : $time; $time = !is_integer($time) ? $this->get(false, $time) : $time;
if($time < TimeAPI::$phases["sunset"]){ if($time < TimeAPI::$phases["sunset"]){
$time = "day"; $time = "day";
} elseif($time < TimeAPI::$phases["night"]){ }elseif($time < TimeAPI::$phases["night"]){
$time = "sunset"; $time = "sunset";
} elseif($time < TimeAPI::$phases["sunrise"]){ }elseif($time < TimeAPI::$phases["sunrise"]){
$time = "night"; $time = "night";
} else{ }else{
$time = "sunrise"; $time = "sunrise";
} }
@ -133,7 +133,7 @@ class TimeAPI{
} }
if(is_string($time) and isset(TimeAPI::$phases[$time])){ if(is_string($time) and isset(TimeAPI::$phases[$time])){
$level->setTime(TimeAPI::$phases[$time]); $level->setTime(TimeAPI::$phases[$time]);
} else{ }else{
$level->setTime((int) $time); $level->setTime((int) $time);
} }

View File

@ -21,10 +21,10 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Network\Protocol\ChatPacket; use PocketMine\Network\Protocol\ChatPacket;
use PocketMine\ServerAPI; use PocketMine\ServerAPI;
use PocketMine;
class Bed extends Transparent{ class Bed extends Transparent{
public function __construct($type = 0){ public function __construct($type = 0){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class Beetroot extends Flowable{ class Beetroot extends Flowable{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -24,10 +24,10 @@
*/ */
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Level\Position; use PocketMine\Level\Position;
use PocketMine;
abstract class Block extends Position{ abstract class Block extends Position{
const AIR = 0; const AIR = 0;

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class BrownMushroom extends Flowable{ class BrownMushroom extends Flowable{
public function __construct(){ public function __construct(){

View File

@ -22,13 +22,13 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine;
use PocketMine\NBT\NBT; use PocketMine\NBT\NBT;
use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Compound;
use PocketMine\NBT\Tag\Enum; use PocketMine\NBT\Tag\Enum;
use PocketMine\NBT\Tag\Int; use PocketMine\NBT\Tag\Int;
use PocketMine\NBT\Tag\String; use PocketMine\NBT\Tag\String;
use PocketMine\Tile\Furnace; use PocketMine\Tile\Furnace;
use PocketMine;
use PocketMine\Tile\Tile; use PocketMine\Tile\Tile;
class BurningFurnace extends Solid{ class BurningFurnace extends Solid{

View File

@ -21,11 +21,11 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\ServerAPI; use PocketMine\ServerAPI;
use PocketMine;
class Cactus extends Transparent{ class Cactus extends Transparent{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class Cake extends Transparent{ class Cake extends Transparent{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class Carpet extends Flowable{ class Carpet extends Flowable{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class Carrot extends Flowable{ class Carrot extends Flowable{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -22,13 +22,13 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine;
use PocketMine\NBT\NBT; use PocketMine\NBT\NBT;
use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Compound;
use PocketMine\NBT\Tag\Enum; use PocketMine\NBT\Tag\Enum;
use PocketMine\NBT\Tag\Int; use PocketMine\NBT\Tag\Int;
use PocketMine\NBT\Tag\String; use PocketMine\NBT\Tag\String;
use PocketMine\Tile\Chest as TileChest; use PocketMine\Tile\Chest as TileChest;
use PocketMine;
use PocketMine\Tile\Tile; use PocketMine\Tile\Tile;
class Chest extends Transparent{ class Chest extends Transparent{

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class CyanFlower extends Flowable{ class CyanFlower extends Flowable{
public function __construct(){ public function __construct(){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class Dandelion extends Flowable{ class Dandelion extends Flowable{
public function __construct(){ public function __construct(){

View File

@ -21,11 +21,11 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Network\Protocol\LevelEventPacket; use PocketMine\Network\Protocol\LevelEventPacket;
use PocketMine\Player; use PocketMine\Player;
use PocketMine;
abstract class Door extends Transparent{ abstract class Door extends Transparent{

View File

@ -21,10 +21,10 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\ServerAPI; use PocketMine\ServerAPI;
use PocketMine;
class Fallable extends Solid{ class Fallable extends Solid{

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class Fire extends Flowable{ class Fire extends Flowable{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -21,10 +21,10 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\ServerAPI; use PocketMine\ServerAPI;
use PocketMine;
class Generic extends Block{ class Generic extends Block{

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class GlowingRedstoneOre extends Solid{ class GlowingRedstoneOre extends Solid{
public function __construct(){ public function __construct(){

View File

@ -21,10 +21,10 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Generator\Object\TallGrass; use PocketMine\Level\Generator\Object\TallGrass;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class Grass extends Solid{ class Grass extends Solid{
public function __construct(){ public function __construct(){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class Ladder extends Transparent{ class Ladder extends Transparent{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -21,11 +21,11 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Level\Position; use PocketMine\Level\Position;
use PocketMine\ServerAPI; use PocketMine\ServerAPI;
use PocketMine;
class Lava extends Liquid{ class Lava extends Liquid{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class Leaves extends Transparent{ class Leaves extends Transparent{
const OAK = 0; const OAK = 0;

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class MelonStem extends Flowable{ class MelonStem extends Flowable{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class Potato extends Flowable{ class Potato extends Flowable{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class PumpkinStem extends Flowable{ class PumpkinStem extends Flowable{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class RedMushroom extends Flowable{ class RedMushroom extends Flowable{
public function __construct(){ public function __construct(){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class RedstoneOre extends Solid{ class RedstoneOre extends Solid{
public function __construct(){ public function __construct(){

View File

@ -21,11 +21,11 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Generator\Object\Tree; use PocketMine\Level\Generator\Object\Tree;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class Sapling extends Flowable{ class Sapling extends Flowable{
const OAK = 0; const OAK = 0;

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class SignPost extends Transparent{ class SignPost extends Transparent{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class SnowLayer extends Flowable{ class SnowLayer extends Flowable{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -21,10 +21,10 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine;
class Sugarcane extends Flowable{ class Sugarcane extends Flowable{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class TallGrass extends Flowable{ class TallGrass extends Flowable{
public function __construct($meta = 1){ public function __construct($meta = 1){

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class Torch extends Flowable{ class Torch extends Flowable{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -22,9 +22,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Level\Position; use PocketMine\Level\Position;
use PocketMine;
use PocketMine\ServerAPI; use PocketMine\ServerAPI;
class Water extends Liquid{ class Water extends Liquid{

View File

@ -21,9 +21,9 @@
namespace PocketMine\Block; namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
class Wheat extends Flowable{ class Wheat extends Flowable{
public function __construct($meta = 0){ public function __construct($meta = 0){

View File

@ -24,6 +24,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine;
use PocketMine\Event\Entity\EntityLevelChangeEvent; use PocketMine\Event\Entity\EntityLevelChangeEvent;
use PocketMine\Event\Entity\EntityMotionEvent; use PocketMine\Event\Entity\EntityMotionEvent;
use PocketMine\Event\Entity\EntityMoveEvent; use PocketMine\Event\Entity\EntityMoveEvent;
@ -34,15 +35,14 @@ use PocketMine\Level\Position;
use PocketMine\Math\AxisAlignedBB; use PocketMine\Math\AxisAlignedBB;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Compound;
use PocketMine\Network;
use PocketMine\Network\Protocol\MoveEntityPacket_PosRot; use PocketMine\Network\Protocol\MoveEntityPacket_PosRot;
use PocketMine\Network\Protocol\MovePlayerPacket; use PocketMine\Network\Protocol\MovePlayerPacket;
use PocketMine\Network\Protocol\RemoveEntityPacket; use PocketMine\Network\Protocol\RemoveEntityPacket;
use PocketMine\Network\Protocol\SetEntityMotionPacket; use PocketMine\Network\Protocol\SetEntityMotionPacket;
use PocketMine\Network;
use PocketMine\Player; use PocketMine\Player;
use PocketMine\PMF\LevelFormat; use PocketMine\PMF\LevelFormat;
use PocketMine\ServerAPI; use PocketMine\ServerAPI;
use PocketMine;
abstract class Entity extends Position{ abstract class Entity extends Position{
public static $entityCount = 1; public static $entityCount = 1;
@ -185,7 +185,7 @@ abstract class Entity extends Position{
$this->fallDistance = 0; $this->fallDistance = 0;
$this->inWater = true; $this->inWater = true;
$this->extinguish(); $this->extinguish();
} else{ }else{
$this->inWater = false; $this->inWater = false;
} }
@ -195,7 +195,7 @@ abstract class Entity extends Position{
if($this->fireTicks < 0){ if($this->fireTicks < 0){
$this->fireTicks = 0; $this->fireTicks = 0;
} }
} else{ }else{
if(($this->fireTicks % 20) === 0){ if(($this->fireTicks % 20) === 0){
$this->attackEntity(1, "onFire"); $this->attackEntity(1, "onFire");
} }
@ -230,7 +230,7 @@ abstract class Entity extends Position{
$pk->yaw = $this->yaw; $pk->yaw = $this->yaw;
$pk->pitch = $this->pitch; $pk->pitch = $this->pitch;
$pk->bodyYaw = $this->yaw; $pk->bodyYaw = $this->yaw;
} else{ }else{
$pk = new MoveEntityPacket_PosRot; $pk = new MoveEntityPacket_PosRot;
$pk->eid = $this->id; $pk->eid = $this->id;
$pk->x = $this->x; $pk->x = $this->x;
@ -273,7 +273,7 @@ abstract class Entity extends Position{
public function getDirection(){ public function getDirection(){
$rotation = ($this->yaw - 90) % 360; $rotation = ($this->yaw - 90) % 360;
if($rotation < 0) { if($rotation < 0){
$rotation += 360.0; $rotation += 360.0;
} }
if((0 <= $rotation and $rotation < 45) or (315 <= $rotation and $rotation < 360)){ if((0 <= $rotation and $rotation < 45) or (315 <= $rotation and $rotation < 360)){
@ -307,7 +307,7 @@ abstract class Entity extends Position{
$this->fall($this->fallDistance); $this->fall($this->fallDistance);
$this->fallDistance = 0; $this->fallDistance = 0;
} }
} elseif($distanceThisTick < 0){ }elseif($distanceThisTick < 0){
$this->fallDistance -= $distanceThisTick; $this->fallDistance -= $distanceThisTick;
} }
} }
@ -431,7 +431,7 @@ abstract class Entity extends Position{
foreach($this->hasSpawned as $player){ foreach($this->hasSpawned as $player){
if(!isset($newChunk[$player->CID])){ if(!isset($newChunk[$player->CID])){
$this->despawnFrom($player); $this->despawnFrom($player);
} else{ }else{
unset($newChunk[$player->CID]); unset($newChunk[$player->CID]);
} }
} }

View File

@ -21,7 +21,6 @@
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine;
use PocketMine\Event\Entity\EntityArmorChangeEvent; use PocketMine\Event\Entity\EntityArmorChangeEvent;
use PocketMine\Event\Entity\EntityInventoryChangeEvent; use PocketMine\Event\Entity\EntityInventoryChangeEvent;
use PocketMine\Event\Event; use PocketMine\Event\Event;
@ -30,13 +29,14 @@ use PocketMine\Item\Item;
use PocketMine\NBT\Tag\Byte; use PocketMine\NBT\Tag\Byte;
use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Compound;
use PocketMine\NBT\Tag\Short; use PocketMine\NBT\Tag\Short;
use PocketMine\Network;
use PocketMine\Network\Protocol\AddPlayerPacket; use PocketMine\Network\Protocol\AddPlayerPacket;
use PocketMine\Network\Protocol\ContainerSetContentPacket; use PocketMine\Network\Protocol\ContainerSetContentPacket;
use PocketMine\Network\Protocol\PlayerEquipmentPacket; use PocketMine\Network\Protocol\PlayerEquipmentPacket;
use PocketMine\Network\Protocol\RemovePlayerPacket; use PocketMine\Network\Protocol\RemovePlayerPacket;
use PocketMine\Network\Protocol\SetEntityMotionPacket; use PocketMine\Network\Protocol\SetEntityMotionPacket;
use PocketMine\Network;
use PocketMine\Player; use PocketMine\Player;
use PocketMine;
class Human extends Creature implements ProjectileSource, InventorySource{ class Human extends Creature implements ProjectileSource, InventorySource{
@ -224,7 +224,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
for($i = 0; $i < 4; ++$i){ for($i = 0; $i < 4; ++$i){
if(isset($this->armor[$i]) and ($this->armor[$i] instanceof Item) and $this->armor[$i]->getID() > Item::AIR){ if(isset($this->armor[$i]) and ($this->armor[$i] instanceof Item) and $this->armor[$i]->getID() > Item::AIR){
$slots[$i] = $this->armor[$i]->getID() !== Item::AIR ? $this->armor[$i]->getID() - 256 : 0; $slots[$i] = $this->armor[$i]->getID() !== Item::AIR ? $this->armor[$i]->getID() - 256 : 0;
} else{ }else{
$this->armor[$i] = Item::get(Item::AIR, 0, 0); $this->armor[$i] = Item::get(Item::AIR, 0, 0);
$slots[$i] = 255; $slots[$i] = 255;
} }
@ -234,7 +234,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
$pk->eid = $this->id; $pk->eid = $this->id;
$pk->slots = $slots; $pk->slots = $slots;
$player->dataPacket($pk); $player->dataPacket($pk);
} elseif($this instanceof Player){ }elseif($this instanceof Player){
$pk = new ContainerSetContentPacket; $pk = new ContainerSetContentPacket;
$pk->windowid = 0x78; //Armor window id $pk->windowid = 0x78; //Armor window id
$pk->slots = $this->armor; $pk->slots = $this->armor;
@ -300,7 +300,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
$inv[$s] = clone $item; $inv[$s] = clone $item;
$inv[$s]->setCount($add); $inv[$s]->setCount($add);
break; break;
} elseif($i->equals($item)){ }elseif($i->equals($item)){
$add = min($i->getMaxStackSize() - $i->getCount(), $item->getCount()); $add = min($i->getMaxStackSize() - $i->getCount(), $item->getCount());
if($add <= 0){ if($add <= 0){
continue; continue;
@ -329,7 +329,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
$i2->setCount($add); $i2->setCount($add);
$this->setSlot($s, $i2); $this->setSlot($s, $i2);
break; break;
} elseif($i->equals($item)){ }elseif($i->equals($item)){
$add = min($i->getMaxStackSize() - $i->getCount(), $item->getCount()); $add = min($i->getMaxStackSize() - $i->getCount(), $item->getCount());
if($add <= 0){ if($add <= 0){
continue; continue;
@ -362,7 +362,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
if($item->getCount() < $i->getCount()){ if($item->getCount() < $i->getCount()){
$i->setCount($i->getCount() - $item->getCount()); $i->setCount($i->getCount() - $item->getCount());
$this->setSlot($s, $i); $this->setSlot($s, $i);
} else{ }else{
$this->setSlot($s, Item::get(Item::AIR, 0, 0)); $this->setSlot($s, Item::get(Item::AIR, 0, 0));
} }
break; break;

View File

@ -62,7 +62,7 @@ abstract class Event{
$identifier = Utils::getCallableIdentifier($handler); $identifier = Utils::getCallableIdentifier($handler);
if(isset(static::$handlers[$identifier])){ //Already registered if(isset(static::$handlers[$identifier])){ //Already registered
return false; return false;
} else{ }else{
static::$handlers[$identifier] = $handler; static::$handlers[$identifier] = $handler;
if(!isset(static::$handlerPriority[(int) $priority])){ if(!isset(static::$handlerPriority[(int) $priority])){
static::$handlerPriority[(int) $priority] = array(); static::$handlerPriority[(int) $priority] = array();
@ -79,7 +79,7 @@ abstract class Event{
if(isset(static::$handlers[$identifier])){ if(isset(static::$handlers[$identifier])){
if(isset(static::$handlerPriority[(int) $priority][$identifier])){ if(isset(static::$handlerPriority[(int) $priority][$identifier])){
unset(static::$handlerPriority[(int) $priority][$identifier]); unset(static::$handlerPriority[(int) $priority][$identifier]);
} else{ }else{
for($priority = EventPriority::MONITOR; $priority <= EventPriority::LOWEST; ++$priority){ for($priority = EventPriority::MONITOR; $priority <= EventPriority::LOWEST; ++$priority){
unset(static::$handlerPriority[$priority][$identifier]); unset(static::$handlerPriority[$priority][$identifier]);
if(count(static::$handlerPriority[$priority]) === 0){ if(count(static::$handlerPriority[$priority]) === 0){
@ -90,7 +90,7 @@ abstract class Event{
unset(static::$handlers[$identifier]); unset(static::$handlers[$identifier]);
return true; return true;
} else{ }else{
return false; return false;
} }
} }

View File

@ -41,7 +41,7 @@ abstract class EventHandler{
if($event->isForced()){ if($event->isForced()){
if($event instanceof CancellableEvent and $event->isCancelled()){ if($event instanceof CancellableEvent and $event->isCancelled()){
return Event::DENY; return Event::DENY;
} else{ }else{
return Event::ALLOW; return Event::ALLOW;
} }
} }
@ -50,9 +50,9 @@ abstract class EventHandler{
if($event instanceof CancellableEvent and $event->isCancelled()){ if($event instanceof CancellableEvent and $event->isCancelled()){
return Event::DENY; return Event::DENY;
} elseif($event->isAllowed()){ }elseif($event->isAllowed()){
return Event::ALLOW; return Event::ALLOW;
} else{ }else{
return Event::NORMAL; return Event::NORMAL;
} }
} }

View File

@ -21,11 +21,11 @@
namespace PocketMine\Event\Block; namespace PocketMine\Event\Block;
use PocketMine;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine\Event\CancellableEvent; use PocketMine\Event\CancellableEvent;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Player; use PocketMine\Player;
use PocketMine;
class BlockBreakEvent extends BlockEvent implements CancellableEvent{ class BlockBreakEvent extends BlockEvent implements CancellableEvent{
public static $handlers; public static $handlers;

View File

@ -21,11 +21,11 @@
namespace PocketMine\Event\Block; namespace PocketMine\Event\Block;
use PocketMine;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine\Event\CancellableEvent; use PocketMine\Event\CancellableEvent;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Player; use PocketMine\Player;
use PocketMine;
/** /**
* Called when a player places a block * Called when a player places a block

View File

@ -22,9 +22,9 @@
namespace PocketMine\Event\Entity; namespace PocketMine\Event\Entity;
use PocketMine\Entity\Entity; use PocketMine\Entity\Entity;
use PocketMine;
use PocketMine\Event\CancellableEvent; use PocketMine\Event\CancellableEvent;
use PocketMine\Event; use PocketMine\Event;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
class EntityArmorChangeEvent extends EntityEvent implements CancellableEvent{ class EntityArmorChangeEvent extends EntityEvent implements CancellableEvent{

View File

@ -22,9 +22,9 @@
namespace PocketMine\Event\Entity; namespace PocketMine\Event\Entity;
use PocketMine\Entity\Entity; use PocketMine\Entity\Entity;
use PocketMine;
use PocketMine\Event\CancellableEvent; use PocketMine\Event\CancellableEvent;
use PocketMine\Event; use PocketMine\Event;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
class EntityInventoryChangeEvent extends EntityEvent implements CancellableEvent{ class EntityInventoryChangeEvent extends EntityEvent implements CancellableEvent{

View File

@ -22,9 +22,9 @@
namespace PocketMine\Event\Entity; namespace PocketMine\Event\Entity;
use PocketMine\Entity\Entity; use PocketMine\Entity\Entity;
use PocketMine;
use PocketMine\Event\CancellableEvent; use PocketMine\Event\CancellableEvent;
use PocketMine\Event; use PocketMine\Event;
use PocketMine;
use PocketMine\Level\Level; use PocketMine\Level\Level;
class EntityLevelChangeEvent extends EntityEvent implements CancellableEvent{ class EntityLevelChangeEvent extends EntityEvent implements CancellableEvent{

View File

@ -22,9 +22,9 @@
namespace PocketMine\Event\Entity; namespace PocketMine\Event\Entity;
use PocketMine\Entity\Entity; use PocketMine\Entity\Entity;
use PocketMine;
use PocketMine\Event\CancellableEvent; use PocketMine\Event\CancellableEvent;
use PocketMine\Event; use PocketMine\Event;
use PocketMine;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
class EntityMotionEvent extends EntityEvent implements CancellableEvent{ class EntityMotionEvent extends EntityEvent implements CancellableEvent{

View File

@ -22,9 +22,9 @@
namespace PocketMine\Event\Entity; namespace PocketMine\Event\Entity;
use PocketMine\Entity\Entity; use PocketMine\Entity\Entity;
use PocketMine;
use PocketMine\Event\CancellableEvent; use PocketMine\Event\CancellableEvent;
use PocketMine\Event; use PocketMine\Event;
use PocketMine;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
class EntityMoveEvent extends EntityEvent implements CancellableEvent{ class EntityMoveEvent extends EntityEvent implements CancellableEvent{

View File

@ -21,11 +21,11 @@
namespace PocketMine\Event\Player; namespace PocketMine\Event\Player;
use PocketMine;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine\Event\CancellableEvent; use PocketMine\Event\CancellableEvent;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Player; use PocketMine\Player;
use PocketMine;
/** /**
* Called when a player interacts or touches a block (including air?) * Called when a player interacts or touches a block (including air?)

View File

@ -21,10 +21,10 @@
namespace PocketMine\Event\Player; namespace PocketMine\Event\Player;
use PocketMine\Event\CancellableEvent;
use PocketMine;
use PocketMine\Event; use PocketMine\Event;
use PocketMine\Event\CancellableEvent;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine;
use PocketMine\Player; use PocketMine\Player;
class PlayerItemHeldEvent extends PlayerEvent implements CancellableEvent{ class PlayerItemHeldEvent extends PlayerEvent implements CancellableEvent{

View File

@ -21,10 +21,10 @@
namespace PocketMine\Event\Server; namespace PocketMine\Event\Server;
use PocketMine\Event;
use PocketMine\Event\CancellableEvent; use PocketMine\Event\CancellableEvent;
use PocketMine\Network\Protocol\DataPacket;
use PocketMine; use PocketMine;
use PocketMine\Event;
use PocketMine\Network\Protocol\DataPacket;
use PocketMine\Player; use PocketMine\Player;
class DataPacketReceiveEvent extends ServerEvent implements CancellableEvent{ class DataPacketReceiveEvent extends ServerEvent implements CancellableEvent{

View File

@ -21,10 +21,10 @@
namespace PocketMine\Event\Server; namespace PocketMine\Event\Server;
use PocketMine\Event;
use PocketMine\Event\CancellableEvent; use PocketMine\Event\CancellableEvent;
use PocketMine\Network\Protocol\DataPacket;
use PocketMine; use PocketMine;
use PocketMine\Event;
use PocketMine\Network\Protocol\DataPacket;
use PocketMine\Player; use PocketMine\Player;
class DataPacketSendEvent extends ServerEvent implements CancellableEvent{ class DataPacketSendEvent extends ServerEvent implements CancellableEvent{

View File

@ -22,8 +22,8 @@
namespace PocketMine\Event\Server; namespace PocketMine\Event\Server;
use PocketMine\Event\CancellableEvent; use PocketMine\Event\CancellableEvent;
use PocketMine\Event;
use PocketMine; use PocketMine;
use PocketMine\Event;
use PocketMine\Network\Packet; use PocketMine\Network\Packet;
class PacketReceiveEvent extends ServerEvent implements CancellableEvent{ class PacketReceiveEvent extends ServerEvent implements CancellableEvent{

View File

@ -22,8 +22,8 @@
namespace PocketMine\Event\Server; namespace PocketMine\Event\Server;
use PocketMine\Event\CancellableEvent; use PocketMine\Event\CancellableEvent;
use PocketMine\Event;
use PocketMine; use PocketMine;
use PocketMine\Event;
use PocketMine\Network\Packet; use PocketMine\Network\Packet;
class PacketSendEvent extends ServerEvent implements CancellableEvent{ class PacketSendEvent extends ServerEvent implements CancellableEvent{

View File

@ -21,11 +21,11 @@
namespace PocketMine\Event\Tile; namespace PocketMine\Event\Tile;
use PocketMine\Event;
use PocketMine\Item\Item;
use PocketMine;
use PocketMine\Tile\Tile;
use PocketMine\Event\CancellableEvent; use PocketMine\Event\CancellableEvent;
use PocketMine\Event;
use PocketMine;
use PocketMine\Item\Item;
use PocketMine\Tile\Tile;
class TileInventoryChangeEvent extends TileEvent implements CancellableEvent{ class TileInventoryChangeEvent extends TileEvent implements CancellableEvent{
public static $handlers; public static $handlers;

View File

@ -22,12 +22,12 @@
namespace PocketMine\Item; namespace PocketMine\Item;
use PocketMine\Block\Air; use PocketMine\Block\Air;
use PocketMine;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine\Block\Lava; use PocketMine\Block\Lava;
use PocketMine\Block\Liquid; use PocketMine\Block\Liquid;
use PocketMine\Block\Water; use PocketMine\Block\Water;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player; use PocketMine\Player;
class Bucket extends Item{ class Bucket extends Item{

View File

@ -22,10 +22,10 @@
namespace PocketMine\Item; namespace PocketMine\Item;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine;
use PocketMine\Block\Fire; use PocketMine\Block\Fire;
use PocketMine\Block\Solid; use PocketMine\Block\Solid;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player; use PocketMine\Player;
class FlintSteel extends Item{ class FlintSteel extends Item{

View File

@ -25,13 +25,13 @@
namespace PocketMine\Item; namespace PocketMine\Item;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine;
use PocketMine\Entity\Entity; use PocketMine\Entity\Entity;
use PocketMine\Item\Block as ItemBlock; use PocketMine\Item\Block as ItemBlock;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Player;
use PocketMine\Recipes\Fuel; use PocketMine\Recipes\Fuel;
use PocketMine\Recipes\Smelt; use PocketMine\Recipes\Smelt;
use PocketMine;
use PocketMine\Player;
class Item{ class Item{
//All Block IDs are here too //All Block IDs are here too
@ -420,7 +420,7 @@ class Item{
$item = clone self::$list[$id]; $item = clone self::$list[$id];
$item->setMetadata($meta); $item->setMetadata($meta);
$item->setCount($count); $item->setCount($count);
} else{ }else{
$item = new Item($id, $meta, $count); $item = new Item($id, $meta, $count);
} }
@ -435,11 +435,11 @@ class Item{
} }
return $blocks; return $blocks;
} else{ }else{
$b = explode(":", str_replace(" ", "_", trim($str))); $b = explode(":", str_replace(" ", "_", trim($str)));
if(!isset($b[1])){ if(!isset($b[1])){
$meta = 0; $meta = 0;
} else{ }else{
$meta = ((int) $b[1]) & 0xFFFF; $meta = ((int) $b[1]) & 0xFFFF;
} }
@ -448,7 +448,7 @@ class Item{
if($item->getID() === self::AIR and strtoupper($b[0]) !== "AIR"){ if($item->getID() === self::AIR and strtoupper($b[0]) !== "AIR"){
$item = self::get(((int) $b[0]) & 0xFFFF, $meta); $item = self::get(((int) $b[0]) & 0xFFFF, $meta);
} }
} else{ }else{
$item = self::get(((int) $b[0]) & 0xFFFF, $meta); $item = self::get(((int) $b[0]) & 0xFFFF, $meta);
} }
@ -490,7 +490,7 @@ class Item{
public function getBlock(){ public function getBlock(){
if($this->block instanceof Block){ if($this->block instanceof Block){
return $this->block; return $this->block;
} else{ }else{
return Block::get(self::AIR); return Block::get(self::AIR);
} }
} }
@ -543,12 +543,12 @@ class Item{
if($this->isTool() or $force === true){ if($this->isTool() or $force === true){
if(($object instanceof Entity) and !$this->isSword()){ if(($object instanceof Entity) and !$this->isSword()){
$this->meta += 2; $this->meta += 2;
} else{ }else{
$this->meta++; $this->meta++;
} }
return true; return true;
} elseif($this->isHoe()){ }elseif($this->isHoe()){
if(($object instanceof Block) and ($object->getID() === self::GRASS or $object->getID() === self::DIRT)){ if(($object instanceof Block) and ($object->getID() === self::GRASS or $object->getID() === self::DIRT)){
$this->meta++; $this->meta++;
} }

View File

@ -22,10 +22,10 @@
namespace PocketMine\Item; namespace PocketMine\Item;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine\Level\Level;
use PocketMine\ServerAPI;
use PocketMine; use PocketMine;
use PocketMine\Level\Level;
use PocketMine\Player; use PocketMine\Player;
use PocketMine\ServerAPI;
class Painting extends Item{ class Painting extends Item{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){

View File

@ -21,11 +21,11 @@
namespace PocketMine\Item; namespace PocketMine\Item;
use PocketMine\Entity; use PocketMine;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine\Entity;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Player; use PocketMine\Player;
use PocketMine;
class SpawnEgg extends Item{ class SpawnEgg extends Item{
public function __construct($meta = 0, $count = 1){ public function __construct($meta = 0, $count = 1){

View File

@ -22,13 +22,13 @@
namespace PocketMine\Level; namespace PocketMine\Level;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine;
use PocketMine\Block\TNT; use PocketMine\Block\TNT;
use PocketMine\Item\Item;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Network\Protocol\ExplodePacket; use PocketMine\Network\Protocol\ExplodePacket;
use PocketMine\Player; use PocketMine\Player;
use PocketMine\ServerAPI; use PocketMine\ServerAPI;
use PocketMine;
use PocketMine\Item\Item;
class Explosion{ class Explosion{
public static $specialDrops = array( public static $specialDrops = array(
@ -118,11 +118,11 @@ class Explosion{
//TODO //TODO
//$e = $server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data); //$e = $server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
//$e->spawnToAll(); //$e->spawnToAll();
} elseif(mt_rand(0, 10000) < ((1 / $this->size) * 10000)){ }elseif(mt_rand(0, 10000) < ((1 / $this->size) * 10000)){
if(isset(self::$specialDrops[$block->getID()])){ if(isset(self::$specialDrops[$block->getID()])){
//TODO //TODO
//$server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), Item::get(self::$specialDrops[$block->getID()], 0)); //$server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), Item::get(self::$specialDrops[$block->getID()], 0));
} else{ }else{
//TODO //TODO
//$server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), Item::get($block->getID(), $this->level->level->getBlockDamage($block->x, $block->y, $block->z))); //$server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), Item::get($block->getID(), $this->level->level->getBlockDamage($block->x, $block->y, $block->z)));
} }

View File

@ -24,7 +24,6 @@
*/ */
namespace PocketMine\Level; namespace PocketMine\Level;
use PocketMine;
use PocketMine\Block\Air; use PocketMine\Block\Air;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine\Item\Item; use PocketMine\Item\Item;
@ -52,6 +51,7 @@ use PocketMine\Utils\Cache;
use PocketMine\Utils\Config; use PocketMine\Utils\Config;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine\Utils\Utils; use PocketMine\Utils\Utils;
use PocketMine;
/** /**
* Class Level * Class Level

View File

@ -21,10 +21,10 @@
namespace PocketMine\Level; namespace PocketMine\Level;
use PocketMine\NBT\NBT;
use PocketMine;
use PocketMine\PMF\LevelFormat; use PocketMine\PMF\LevelFormat;
use PocketMine\Utils\Config; use PocketMine\Utils\Config;
use PocketMine;
use PocketMine\NBT\NBT;
class LevelImport{ class LevelImport{
private $path; private $path;
@ -41,7 +41,7 @@ class LevelImport{
$entities->save(); $entities->save();
$tiles = new Config($this->path . "tiles.yml", Config::YAML, unserialize(file_get_contents($this->path . "tileEntities.dat"))); $tiles = new Config($this->path . "tiles.yml", Config::YAML, unserialize(file_get_contents($this->path . "tileEntities.dat")));
$tiles->save(); $tiles->save();
} elseif(file_exists($this->path . "chunks.dat") and file_exists($this->path . "level.dat")){ //Pocket }elseif(file_exists($this->path . "chunks.dat") and file_exists($this->path . "level.dat")){ //Pocket
$nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt = new NBT(NBT::LITTLE_ENDIAN);
$nbt->read(substr(file_get_contents($this->path . "level.dat"), 8)); $nbt->read(substr(file_get_contents($this->path . "level.dat"), 8));
$level = $nbt->getData(); $level = $nbt->getData();
@ -61,7 +61,7 @@ class LevelImport{
$entities->save(); $entities->save();
$tiles = new Config($this->path . "tiles.yml", Config::YAML, $tiles); $tiles = new Config($this->path . "tiles.yml", Config::YAML, $tiles);
$tiles->save(); $tiles->save();
} else{ }else{
return false; return false;
} }

View File

@ -63,9 +63,9 @@ class PocketChunkParser{
} }
@unlink($file . ".gz"); @unlink($file . ".gz");
file_put_contents($file, $this->raw); file_put_contents($file, $this->raw);
} elseif(!file_exists($file)){ }elseif(!file_exists($file)){
return false; return false;
} else{ }else{
$this->raw = file_get_contents($file); $this->raw = file_get_contents($file);
} }
$this->file = $file; $this->file = $file;
@ -200,7 +200,7 @@ class PocketChunkParser{
$meta = ord($this->map[$X][$Z][1][$index]{$y >> 1}); $meta = ord($this->map[$X][$Z][1][$index]{$y >> 1});
if(($y & 1) === 0){ if(($y & 1) === 0){
$meta = $meta & 0x0F; $meta = $meta & 0x0F;
} else{ }else{
$meta = $meta >> 4; $meta = $meta >> 4;
} }
@ -226,7 +226,7 @@ class PocketChunkParser{
$old_meta = ord($this->map[$X][$Z][1][$index]{$y >> 1}); $old_meta = ord($this->map[$X][$Z][1][$index]{$y >> 1});
if(($y & 1) === 0){ if(($y & 1) === 0){
$meta = ($old_meta & 0xF0) | ($meta & 0x0F); $meta = ($old_meta & 0xF0) | ($meta & 0x0F);
} else{ }else{
$meta = (($meta << 4) & 0xF0) | ($old_meta & 0x0F); $meta = (($meta << 4) & 0xF0) | ($old_meta & 0x0F);
} }
$this->map[$X][$Z][1][$index]{$y >> 1} = chr($meta); $this->map[$X][$Z][1][$index]{$y >> 1} = chr($meta);

View File

@ -21,12 +21,12 @@
namespace PocketMine\Level; namespace PocketMine\Level;
use PocketMine;
use PocketMine\Level\Generator\Generator; use PocketMine\Level\Generator\Generator;
use PocketMine\PMF\LevelFormat; use PocketMine\PMF\LevelFormat;
use PocketMine\Utils\Config; use PocketMine\Utils\Config;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine\Utils\Utils; use PocketMine\Utils\Utils;
use PocketMine;
class WorldGenerator{ class WorldGenerator{
private $seed, $level, $path, $random, $generator, $height; private $seed, $level, $path, $random, $generator, $height;

View File

@ -21,7 +21,6 @@
namespace PocketMine\Level\Generator; namespace PocketMine\Level\Generator;
use PocketMine;
use PocketMine\Block\CoalOre; use PocketMine\Block\CoalOre;
use PocketMine\Block\DiamondOre; use PocketMine\Block\DiamondOre;
use PocketMine\Block\Dirt; use PocketMine\Block\Dirt;
@ -35,6 +34,7 @@ use PocketMine\Level\Generator\Populator\Ore;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class Flat extends Generator{ class Flat extends Generator{
private $level, $random, $structure, $chunks, $options, $floorLevel, $preset, $populators = array(); private $level, $random, $structure, $chunks, $options, $floorLevel, $preset, $populators = array();
@ -52,7 +52,7 @@ class Flat extends Generator{
$this->options = $options; $this->options = $options;
if(isset($options["preset"])){ if(isset($options["preset"])){
$this->parsePreset($options["preset"]); $this->parsePreset($options["preset"]);
} else{ }else{
$this->parsePreset($this->preset); $this->parsePreset($this->preset);
} }
if(isset($this->options["decoration"])){ if(isset($this->options["decoration"])){

View File

@ -24,9 +24,9 @@
*/ */
namespace PocketMine\Level\Generator; namespace PocketMine\Level\Generator;
use PocketMine;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
abstract class Generator{ abstract class Generator{
private static $list = array(); private static $list = array();

View File

@ -21,6 +21,7 @@
namespace PocketMine\Level\Generator; namespace PocketMine\Level\Generator;
use PocketMine;
use PocketMine\Block\CoalOre; use PocketMine\Block\CoalOre;
use PocketMine\Block\DiamondOre; use PocketMine\Block\DiamondOre;
use PocketMine\Block\Dirt; use PocketMine\Block\Dirt;
@ -37,7 +38,6 @@ use PocketMine\Level\Generator\Populator\Tree;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class Normal extends Generator{ class Normal extends Generator{
@ -131,39 +131,39 @@ class Normal extends Generator{
$diff = $height - $y; $diff = $height - $y;
if($y <= 4 and ($y === 0 or $this->random->nextFloat() < 0.75)){ if($y <= 4 and ($y === 0 or $this->random->nextFloat() < 0.75)){
$chunk .= "\x07"; //bedrock $chunk .= "\x07"; //bedrock
} elseif($diff > 2){ }elseif($diff > 2){
$chunk .= "\x01"; //stone $chunk .= "\x01"; //stone
} elseif($diff > 0){ }elseif($diff > 0){
if($patches[$i] > 0.7){ if($patches[$i] > 0.7){
$chunk .= "\x01"; //stone $chunk .= "\x01"; //stone
} elseif($patches[$i] < -0.8){ }elseif($patches[$i] < -0.8){
$chunk .= "\x0d"; //gravel $chunk .= "\x0d"; //gravel
} else{ }else{
$chunk .= "\x03"; //dirt $chunk .= "\x03"; //dirt
} }
} elseif($y <= $this->waterHeight){ }elseif($y <= $this->waterHeight){
if(($this->waterHeight - $y) <= 1 and $diff === 0){ if(($this->waterHeight - $y) <= 1 and $diff === 0){
$chunk .= "\x0c"; //sand $chunk .= "\x0c"; //sand
} elseif($diff === 0){ }elseif($diff === 0){
if($patchesSmall[$i] > 0.3){ if($patchesSmall[$i] > 0.3){
$chunk .= "\x0d"; //gravel $chunk .= "\x0d"; //gravel
} elseif($patchesSmall[$i] < -0.45){ }elseif($patchesSmall[$i] < -0.45){
$chunk .= "\x0c"; //sand $chunk .= "\x0c"; //sand
} else{ }else{
$chunk .= "\x03"; //dirt $chunk .= "\x03"; //dirt
} }
} else{ }else{
$chunk .= "\x09"; //still_water $chunk .= "\x09"; //still_water
} }
} elseif($diff === 0){ }elseif($diff === 0){
if($patches[$i] > 0.7){ if($patches[$i] > 0.7){
$chunk .= "\x01"; //stone $chunk .= "\x01"; //stone
} elseif($patches[$i] < -0.8){ }elseif($patches[$i] < -0.8){
$chunk .= "\x0d"; //gravel $chunk .= "\x0d"; //gravel
} else{ }else{
$chunk .= "\x02"; //grass $chunk .= "\x02"; //grass
} }
} else{ }else{
$chunk .= "\x00"; $chunk .= "\x00";
} }
} }

View File

@ -141,7 +141,7 @@ class Simplex extends Perlin{
$k2 = 1; $k2 = 1;
} }
// Z X Y order // Z X Y order
} else{ // x0<y0 }else{ // x0<y0
if($y0 < $z0){ if($y0 < $z0){
$i1 = 0; $i1 = 0;
$j1 = 0; $j1 = 0;
@ -196,7 +196,7 @@ class Simplex extends Perlin{
$t0 = 0.6 - $x0 * $x0 - $y0 * $y0 - $z0 * $z0; $t0 = 0.6 - $x0 * $x0 - $y0 * $y0 - $z0 * $z0;
if($t0 < 0){ if($t0 < 0){
$n0 = 0.0; $n0 = 0.0;
} else{ }else{
$t0 *= $t0; $t0 *= $t0;
$n0 = $t0 * $t0 * self::dot3D(self::$grad3[$gi0], $x0, $y0, $z0); $n0 = $t0 * $t0 * self::dot3D(self::$grad3[$gi0], $x0, $y0, $z0);
} }
@ -204,7 +204,7 @@ class Simplex extends Perlin{
$t1 = 0.6 - $x1 * $x1 - $y1 * $y1 - $z1 * $z1; $t1 = 0.6 - $x1 * $x1 - $y1 * $y1 - $z1 * $z1;
if($t1 < 0){ if($t1 < 0){
$n1 = 0.0; $n1 = 0.0;
} else{ }else{
$t1 *= $t1; $t1 *= $t1;
$n1 = $t1 * $t1 * self::dot3D(self::$grad3[$gi1], $x1, $y1, $z1); $n1 = $t1 * $t1 * self::dot3D(self::$grad3[$gi1], $x1, $y1, $z1);
} }
@ -212,7 +212,7 @@ class Simplex extends Perlin{
$t2 = 0.6 - $x2 * $x2 - $y2 * $y2 - $z2 * $z2; $t2 = 0.6 - $x2 * $x2 - $y2 * $y2 - $z2 * $z2;
if($t2 < 0){ if($t2 < 0){
$n2 = 0.0; $n2 = 0.0;
} else{ }else{
$t2 *= $t2; $t2 *= $t2;
$n2 = $t2 * $t2 * self::dot3D(self::$grad3[$gi2], $x2, $y2, $z2); $n2 = $t2 * $t2 * self::dot3D(self::$grad3[$gi2], $x2, $y2, $z2);
} }
@ -220,7 +220,7 @@ class Simplex extends Perlin{
$t3 = 0.6 - $x3 * $x3 - $y3 * $y3 - $z3 * $z3; $t3 = 0.6 - $x3 * $x3 - $y3 * $y3 - $z3 * $z3;
if($t3 < 0){ if($t3 < 0){
$n3 = 0.0; $n3 = 0.0;
} else{ }else{
$t3 *= $t3; $t3 *= $t3;
$n3 = $t3 * $t3 * self::dot3D(self::$grad3[$gi3], $x3, $y3, $z3); $n3 = $t3 * $t3 * self::dot3D(self::$grad3[$gi3], $x3, $y3, $z3);
} }
@ -277,7 +277,7 @@ class Simplex extends Perlin{
$t0 = 0.5 - $x0 * $x0 - $y0 * $y0; $t0 = 0.5 - $x0 * $x0 - $y0 * $y0;
if($t0 < 0){ if($t0 < 0){
$n0 = 0.0; $n0 = 0.0;
} else{ }else{
$t0 *= $t0; $t0 *= $t0;
$n0 = $t0 * $t0 * self::dot2D(self::$grad3[$gi0], $x0, $y0); // (x,y) of grad3 used for 2D gradient $n0 = $t0 * $t0 * self::dot2D(self::$grad3[$gi0], $x0, $y0); // (x,y) of grad3 used for 2D gradient
} }
@ -285,7 +285,7 @@ class Simplex extends Perlin{
$t1 = 0.5 - $x1 * $x1 - $y1 * $y1; $t1 = 0.5 - $x1 * $x1 - $y1 * $y1;
if($t1 < 0){ if($t1 < 0){
$n1 = 0.0; $n1 = 0.0;
} else{ }else{
$t1 *= $t1; $t1 *= $t1;
$n1 = $t1 * $t1 * self::dot2D(self::$grad3[$gi1], $x1, $y1); $n1 = $t1 * $t1 * self::dot2D(self::$grad3[$gi1], $x1, $y1);
} }
@ -293,7 +293,7 @@ class Simplex extends Perlin{
$t2 = 0.5 - $x2 * $x2 - $y2 * $y2; $t2 = 0.5 - $x2 * $x2 - $y2 * $y2;
if($t2 < 0){ if($t2 < 0){
$n2 = 0.0; $n2 = 0.0;
} else{ }else{
$t2 *= $t2; $t2 *= $t2;
$n2 = $t2 * $t2 * self::dot2D(self::$grad3[$gi2], $x2, $y2); $n2 = $t2 * $t2 * self::dot2D(self::$grad3[$gi2], $x2, $y2);
} }

View File

@ -21,9 +21,9 @@
namespace PocketMine\Level\Generator\Object; namespace PocketMine\Level\Generator\Object;
use PocketMine;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine;
class BigTree extends Tree{ class BigTree extends Tree{
private $trunkHeightMultiplier = 0.618; private $trunkHeightMultiplier = 0.618;

View File

@ -21,11 +21,11 @@
namespace PocketMine\Level\Generator\Object; namespace PocketMine\Level\Generator\Object;
use PocketMine;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Math\VectorMath; use PocketMine\Math\VectorMath;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class Ore{ class Ore{
private $random; private $random;

View File

@ -21,13 +21,13 @@
namespace PocketMine\Level\Generator\Object; namespace PocketMine\Level\Generator\Object;
use PocketMine;
use PocketMine\Block\Dirt; use PocketMine\Block\Dirt;
use PocketMine\Block\Leaves; use PocketMine\Block\Leaves;
use PocketMine\Block\Wood; use PocketMine\Block\Wood;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class PineTree extends Tree{ class PineTree extends Tree{
var $type = 1; var $type = 1;
@ -84,7 +84,7 @@ class PineTree extends Tree{
if(++$leavesMaxRadius > $this->leavesAbsoluteMaxRadius){ if(++$leavesMaxRadius > $this->leavesAbsoluteMaxRadius){
$leavesMaxRadius = $this->leavesAbsoluteMaxRadius; $leavesMaxRadius = $this->leavesAbsoluteMaxRadius;
} }
} else{ }else{
++$leavesRadius; ++$leavesRadius;
} }
} }

View File

@ -21,11 +21,11 @@
namespace PocketMine\Level\Generator\Object; namespace PocketMine\Level\Generator\Object;
use PocketMine;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class Pond{ class Pond{
private $random; private $random;

View File

@ -21,13 +21,13 @@
namespace PocketMine\Level\Generator\Object; namespace PocketMine\Level\Generator\Object;
use PocketMine;
use PocketMine\Block\Dirt; use PocketMine\Block\Dirt;
use PocketMine\Block\Leaves; use PocketMine\Block\Leaves;
use PocketMine\Block\Wood; use PocketMine\Block\Wood;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class SmallTree extends Tree{ class SmallTree extends Tree{
public $type = 0; public $type = 0;

View File

@ -21,13 +21,13 @@
namespace PocketMine\Level\Generator\Object; namespace PocketMine\Level\Generator\Object;
use PocketMine;
use PocketMine\Block\Dirt; use PocketMine\Block\Dirt;
use PocketMine\Block\Leaves; use PocketMine\Block\Leaves;
use PocketMine\Block\Wood; use PocketMine\Block\Wood;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class SpruceTree extends Tree{ class SpruceTree extends Tree{
var $type = 1; var $type = 1;
@ -76,7 +76,7 @@ class SpruceTree extends Tree{
} }
if($leavesRadius > 0 and $yy === ($pos->y + $this->leavesBottomY + 1)){ if($leavesRadius > 0 and $yy === ($pos->y + $this->leavesBottomY + 1)){
--$leavesRadius; --$leavesRadius;
} elseif($leavesRadius < $this->leavesMaxRadius){ }elseif($leavesRadius < $this->leavesMaxRadius){
++$leavesRadius; ++$leavesRadius;
} }
} }

View File

@ -21,11 +21,11 @@
namespace PocketMine\Level\Generator\Object; namespace PocketMine\Level\Generator\Object;
use PocketMine;
use PocketMine\Block\Sapling; use PocketMine\Block\Sapling;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class Tree{ class Tree{
public $overridable = array( public $overridable = array(
@ -42,7 +42,7 @@ class Tree{
case Sapling::SPRUCE: case Sapling::SPRUCE:
if($random->nextRange(0, 1) === 1){ if($random->nextRange(0, 1) === 1){
$tree = new SpruceTree(); $tree = new SpruceTree();
} else{ }else{
$tree = new PineTree(); $tree = new PineTree();
} }
break; break;

View File

@ -21,9 +21,9 @@
namespace PocketMine\Level\Generator\Populator; namespace PocketMine\Level\Generator\Populator;
use PocketMine;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class Mineshaft extends Populator{ class Mineshaft extends Populator{
private static $DISTANCE = 256; private static $DISTANCE = 256;

View File

@ -21,11 +21,11 @@
namespace PocketMine\Level\Generator\Populator; namespace PocketMine\Level\Generator\Populator;
use PocketMine;
use PocketMine\Level\Generator\Object\Ore as ObjectOre; use PocketMine\Level\Generator\Object\Ore as ObjectOre;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class Ore extends Populator{ class Ore extends Populator{
private $oreTypes = array(); private $oreTypes = array();

View File

@ -21,11 +21,11 @@
namespace PocketMine\Level\Generator\Populator; namespace PocketMine\Level\Generator\Populator;
use PocketMine;
use PocketMine\Block\Water; use PocketMine\Block\Water;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class Pond extends Populator{ class Pond extends Populator{
private $waterOdd = 4; private $waterOdd = 4;

View File

@ -24,9 +24,9 @@
*/ */
namespace PocketMine\Level\Generator\Populator; namespace PocketMine\Level\Generator\Populator;
use PocketMine;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
abstract class Populator{ abstract class Populator{
public abstract function populate(Level $level, $chunkX, $chunkZ, Random $random); public abstract function populate(Level $level, $chunkX, $chunkZ, Random $random);

View File

@ -21,12 +21,12 @@
namespace PocketMine\Level\Generator\Populator; namespace PocketMine\Level\Generator\Populator;
use PocketMine;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine\Block\TallGrass as BlockTallGrass; use PocketMine\Block\TallGrass as BlockTallGrass;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class TallGrass extends Populator{ class TallGrass extends Populator{
/** /**
@ -73,7 +73,7 @@ class TallGrass extends Populator{
if(--$y <= 0){ if(--$y <= 0){
return -1; return -1;
} }
} else{ }else{
break; break;
} }
} }

View File

@ -21,13 +21,13 @@
namespace PocketMine\Level\Generator\Populator; namespace PocketMine\Level\Generator\Populator;
use PocketMine;
use PocketMine\Block\Block; use PocketMine\Block\Block;
use PocketMine\Block\Sapling; use PocketMine\Block\Sapling;
use PocketMine\Level\Generator\Object\Tree as ObjectTree; use PocketMine\Level\Generator\Object\Tree as ObjectTree;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3; use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Utils\Random; use PocketMine\Utils\Random;
use PocketMine;
class Tree extends Populator{ class Tree extends Populator{
private $level; private $level;
@ -54,7 +54,7 @@ class Tree extends Populator{
} }
if($random->nextFloat() > 0.75){ if($random->nextFloat() > 0.75){
$meta = Sapling::BIRCH; $meta = Sapling::BIRCH;
} else{ }else{
$meta = Sapling::OAK; $meta = Sapling::OAK;
} }
ObjectTree::growTree($this->level, new Vector3($x, $y, $z), $random, $meta); ObjectTree::growTree($this->level, new Vector3($x, $y, $z), $random, $meta);
@ -68,7 +68,7 @@ class Tree extends Populator{
if(--$y <= 0){ if(--$y <= 0){
return -1; return -1;
} }
} else{ }else{
break; break;
} }
} }

View File

@ -55,19 +55,19 @@ class AxisAlignedBB{
$vec = clone $this; $vec = clone $this;
if($x < 0){ if($x < 0){
$vec->minX += $x; $vec->minX += $x;
} elseif($x > 0){ }elseif($x > 0){
$vec->maxX += $x; $vec->maxX += $x;
} }
if($y < 0){ if($y < 0){
$vec->minY += $y; $vec->minY += $y;
} elseif($y > 0){ }elseif($y > 0){
$vec->maxY += $y; $vec->maxY += $y;
} }
if($z < 0){ if($z < 0){
$vec->minZ += $z; $vec->minZ += $z;
} elseif($z > 0){ }elseif($z > 0){
$vec->maxZ += $z; $vec->maxZ += $z;
} }

View File

@ -50,7 +50,7 @@ class Vector2{
public function add($x = 0, $y = 0){ public function add($x = 0, $y = 0){
if(($x instanceof Vector2) === true){ if(($x instanceof Vector2) === true){
return $this->add($x->x, $x->y); return $this->add($x->x, $x->y);
} else{ }else{
$this->x += $x; $this->x += $x;
$this->y += $y; $this->y += $y;
@ -61,7 +61,7 @@ class Vector2{
public function subtract($x = 0, $y = 0){ public function subtract($x = 0, $y = 0){
if(($x instanceof Vector2) === true){ if(($x instanceof Vector2) === true){
return $this->add(-$x->x, -$x->y); return $this->add(-$x->x, -$x->y);
} else{ }else{
return $this->add(-$x, -$y); return $this->add(-$x, -$y);
} }
} }
@ -93,7 +93,7 @@ class Vector2{
public function distance($x = 0, $y = 0){ public function distance($x = 0, $y = 0){
if(($x instanceof Vector2) === true){ if(($x instanceof Vector2) === true){
return sqrt($this->distanceSquared($x->x, $x->y)); return sqrt($this->distanceSquared($x->x, $x->y));
} else{ }else{
return sqrt($this->distanceSquared($x, $y)); return sqrt($this->distanceSquared($x, $y));
} }
} }
@ -101,7 +101,7 @@ class Vector2{
public function distanceSquared($x = 0, $y = 0){ public function distanceSquared($x = 0, $y = 0){
if(($x instanceof Vector2) === true){ if(($x instanceof Vector2) === true){
return $this->distanceSquared($x->x, $x->y); return $this->distanceSquared($x->x, $x->y);
} else{ }else{
return pow($this->x - $x, 2) + pow($this->y - $y, 2); return pow($this->x - $x, 2) + pow($this->y - $y, 2);
} }
} }

View File

@ -81,7 +81,7 @@ class Vector3{
public function add($x = 0, $y = 0, $z = 0){ public function add($x = 0, $y = 0, $z = 0){
if(($x instanceof Vector3) === true){ if(($x instanceof Vector3) === true){
return $this->add($x->x, $x->y, $x->z); return $this->add($x->x, $x->y, $x->z);
} else{ }else{
return new Vector3($this->x + $x, $this->y + $y, $this->z + $z); return new Vector3($this->x + $x, $this->y + $y, $this->z + $z);
} }
} }
@ -89,7 +89,7 @@ class Vector3{
public function subtract($x = 0, $y = 0, $z = 0){ public function subtract($x = 0, $y = 0, $z = 0){
if(($x instanceof Vector3) === true){ if(($x instanceof Vector3) === true){
return $this->add(-$x->x, -$x->y, -$x->z); return $this->add(-$x->x, -$x->y, -$x->z);
} else{ }else{
return $this->add(-$x, -$y, -$z); return $this->add(-$x, -$y, -$z);
} }
} }
@ -148,7 +148,7 @@ class Vector3{
public function maxPlainDistance($x = 0, $z = 0){ public function maxPlainDistance($x = 0, $z = 0){
if(($x instanceof Vector3) === true){ if(($x instanceof Vector3) === true){
return $this->maxPlainDistance($x->x, $x->z); return $this->maxPlainDistance($x->x, $x->z);
} else{ }else{
return max(abs($this->x - $x), abs($this->z - $z)); return max(abs($this->x - $x), abs($this->z - $z));
} }
} }

View File

@ -24,7 +24,6 @@
*/ */
namespace PocketMine\NBT; namespace PocketMine\NBT;
use PocketMine;
use PocketMine\NBT\Tag\Byte; use PocketMine\NBT\Tag\Byte;
use PocketMine\NBT\Tag\Byte_Array; use PocketMine\NBT\Tag\Byte_Array;
use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Compound;
@ -40,6 +39,7 @@ use PocketMine\NBT\Tag\Short;
use PocketMine\NBT\Tag\String; use PocketMine\NBT\Tag\String;
use PocketMine\NBT\Tag\Tag; use PocketMine\NBT\Tag\Tag;
use PocketMine\Utils\Utils; use PocketMine\Utils\Utils;
use PocketMine;
/** /**
* Named Binary Tag encoder/decoder * Named Binary Tag encoder/decoder
@ -73,7 +73,7 @@ class NBT{
$this->offset = strlen($this->buffer) - 1; $this->offset = strlen($this->buffer) - 1;
return ""; return "";
} elseif($len === true){ }elseif($len === true){
return substr($this->buffer, $this->offset); return substr($this->buffer, $this->offset);
} }
@ -115,7 +115,7 @@ class NBT{
$this->writeTag($this->data); $this->writeTag($this->data);
return $this->buffer; return $this->buffer;
} else{ }else{
return false; return false;
} }
} }
@ -124,6 +124,7 @@ class NBT{
if(($write = $this->write()) !== false){ if(($write = $this->write()) !== false){
return \gzencode($write, 9); return \gzencode($write, 9);
} }
return false; return false;
} }

View File

@ -45,6 +45,7 @@ class Compound extends NamedTag implements \ArrayAccess{
return $this->{$offset}->getValue(); return $this->{$offset}->getValue();
} }
} }
return null; return null;
} }
@ -71,7 +72,7 @@ class Compound extends NamedTag implements \ArrayAccess{
if($tag instanceof NamedTag and $tag->getName() !== ""){ if($tag instanceof NamedTag and $tag->getName() !== ""){
$this->{$tag->getName()} = $tag; $this->{$tag->getName()} = $tag;
} }
} while(!($tag instanceof End) and !$nbt->feof()); }while(!($tag instanceof End) and !$nbt->feof());
} }
public function write(NBT $nbt){ public function write(NBT $nbt){

View File

@ -48,6 +48,7 @@ class Enum extends NamedTag implements \ArrayAccess{
return $this->{$offset}->getValue(); return $this->{$offset}->getValue();
} }
} }
return null; return null;
} }

View File

@ -24,6 +24,7 @@
*/ */
namespace PocketMine\Network; namespace PocketMine\Network;
use PocketMine;
use PocketMine\Event\Event; use PocketMine\Event\Event;
use PocketMine\Event\EventHandler; use PocketMine\Event\EventHandler;
use PocketMine\Event\Server\PacketReceiveEvent; use PocketMine\Event\Server\PacketReceiveEvent;
@ -33,7 +34,6 @@ use PocketMine\Network\Query\QueryPacket;
use PocketMine\Network\RakNet\Info; use PocketMine\Network\RakNet\Info;
use PocketMine\Network\RakNet\Packet; use PocketMine\Network\RakNet\Packet;
use PocketMine\ServerAPI; use PocketMine\ServerAPI;
use PocketMine;
class Handler{ class Handler{
public $bandwidth; public $bandwidth;
@ -77,7 +77,7 @@ class Handler{
} }
return $packet; return $packet;
} elseif($pid === 0xfe and $buffer{1} === "\xfd" and ServerAPI::request()->api->query instanceof QueryHandler){ }elseif($pid === 0xfe and $buffer{1} === "\xfd" and ServerAPI::request()->api->query instanceof QueryHandler){
$packet = new QueryPacket; $packet = new QueryPacket;
$packet->ip = $source; $packet->ip = $source;
$packet->port = $port; $packet->port = $port;
@ -86,7 +86,7 @@ class Handler{
return false; return false;
} }
ServerAPI::request()->api->query->handle($packet); ServerAPI::request()->api->query->handle($packet);
} else{ }else{
$packet = new Packet($pid); $packet = new Packet($pid);
$packet->ip = $source; $packet->ip = $source;
$packet->port = $port; $packet->port = $port;
@ -102,7 +102,7 @@ class Handler{
public function writePacket(Packet $packet){ public function writePacket(Packet $packet){
if(EventHandler::callEvent(new PacketSendEvent($packet)) === Event::DENY){ if(EventHandler::callEvent(new PacketSendEvent($packet)) === Event::DENY){
return 0; return 0;
} elseif($packet instanceof Packet){ }elseif($packet instanceof Packet){
$packet->encode(); $packet->encode();
} }
$write = $this->socket->write($packet->buffer, $packet->ip, $packet->port); $write = $this->socket->write($packet->buffer, $packet->ip, $packet->port);

View File

@ -34,14 +34,14 @@ class UDPSocket{
if($listen !== true){ if($listen !== true){
$this->connected = true; $this->connected = true;
$this->unblock(); $this->unblock();
} else{ }else{
if(socket_bind($this->sock, $serverip, $port) === true){ if(socket_bind($this->sock, $serverip, $port) === true){
socket_set_option($this->sock, SOL_SOCKET, SO_REUSEADDR, 0); socket_set_option($this->sock, SOL_SOCKET, SO_REUSEADDR, 0);
@socket_set_option($this->sock, SOL_SOCKET, SO_SNDBUF, 1024 * 1024 * 2); //2MB @socket_set_option($this->sock, SOL_SOCKET, SO_SNDBUF, 1024 * 1024 * 2); //2MB
@socket_set_option($this->sock, SOL_SOCKET, SO_RCVBUF, 1024 * 1024); //1MB @socket_set_option($this->sock, SOL_SOCKET, SO_RCVBUF, 1024 * 1024); //1MB
$this->unblock(); $this->unblock();
$this->connected = true; $this->connected = true;
} else{ }else{
$this->connected = false; $this->connected = false;
} }
} }

View File

@ -21,9 +21,9 @@
namespace PocketMine\Network\Protocol; namespace PocketMine\Network\Protocol;
use PocketMine;
use PocketMine\Item\Item; use PocketMine\Item\Item;
use PocketMine\Utils\Utils; use PocketMine\Utils\Utils;
use PocketMine;
abstract class DataPacket{ abstract class DataPacket{
private $offset = 0; private $offset = 0;
@ -63,7 +63,7 @@ abstract class DataPacket{
$this->offset = strlen($this->buffer) - 1; $this->offset = strlen($this->buffer) - 1;
return ""; return "";
} elseif($len === true){ }elseif($len === true){
return substr($this->buffer, $this->offset); return substr($this->buffer, $this->offset);
} }

View File

@ -25,11 +25,11 @@
*/ */
namespace PocketMine\Network\Query; namespace PocketMine\Network\Query;
use PocketMine;
use PocketMine\Level\Level; use PocketMine\Level\Level;
use PocketMine\Player; use PocketMine\Player;
use PocketMine\ServerAPI; use PocketMine\ServerAPI;
use PocketMine\Utils\Utils; use PocketMine\Utils\Utils;
use PocketMine;
class QueryHandler{ class QueryHandler{
private $socket, $server, $lastToken, $token, $longData, $timeout; private $socket, $server, $lastToken, $token, $longData, $timeout;
@ -134,7 +134,7 @@ class QueryHandler{
$this->regenerateInfo(); $this->regenerateInfo();
} }
$pk->payload = $this->longData; $pk->payload = $this->longData;
} else{ }else{
$pk->payload = $this->server->name . "\x00" . (($this->server->gamemode & 0x01) === 0 ? "SMP" : "CMP") . "\x00" . Level::getDefault()->getName() . "\x00" . count(Player::$list) . "\x00" . $this->server->maxClients . "\x00" . Utils::writeLShort($this->server->api->getProperty("server-port")) . $this->server->api->getProperty("server-ip", "0.0.0.0") . "\x00"; $pk->payload = $this->server->name . "\x00" . (($this->server->gamemode & 0x01) === 0 ? "SMP" : "CMP") . "\x00" . Level::getDefault()->getName() . "\x00" . count(Player::$list) . "\x00" . $this->server->maxClients . "\x00" . Utils::writeLShort($this->server->api->getProperty("server-port")) . $this->server->api->getProperty("server-ip", "0.0.0.0") . "\x00";
} }
$pk->encode(); $pk->encode();

Some files were not shown because too many files have changed in this diff Show More