From 80cfa7cc84dc61f5ed5d8dfa6867a72ad8a07fdd Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 23 Mar 2014 00:32:05 +0100 Subject: [PATCH] Formatting code --- src/PocketMine/BanAPI.php | 24 ++-- src/PocketMine/BlockAPI.php | 8 +- src/PocketMine/ChatAPI.php | 6 +- src/PocketMine/ConsoleAPI.php | 16 +-- src/PocketMine/LevelAPI.php | 4 +- src/PocketMine/Player.php | 105 +++++++++--------- src/PocketMine/PlayerAPI.php | 40 +++---- src/PocketMine/PocketMine.php | 24 ++-- src/PocketMine/Server.php | 22 ++-- src/PocketMine/ServerAPI.php | 19 ++-- src/PocketMine/TimeAPI.php | 8 +- src/PocketMine/block/Bed.php | 2 +- src/PocketMine/block/Beetroot.php | 2 +- src/PocketMine/block/Block.php | 2 +- src/PocketMine/block/BrownMushroom.php | 2 +- src/PocketMine/block/BurningFurnace.php | 2 +- src/PocketMine/block/Cactus.php | 2 +- src/PocketMine/block/Cake.php | 2 +- src/PocketMine/block/Carpet.php | 2 +- src/PocketMine/block/Carrot.php | 2 +- src/PocketMine/block/Chest.php | 2 +- src/PocketMine/block/CyanFlower.php | 2 +- src/PocketMine/block/Dandelion.php | 2 +- src/PocketMine/block/Door.php | 2 +- src/PocketMine/block/Fallable.php | 2 +- src/PocketMine/block/Fire.php | 2 +- src/PocketMine/block/Generic.php | 2 +- src/PocketMine/block/GlowingRedstoneOre.php | 2 +- src/PocketMine/block/Grass.php | 2 +- src/PocketMine/block/Ladder.php | 2 +- src/PocketMine/block/Lava.php | 2 +- src/PocketMine/block/Leaves.php | 2 +- src/PocketMine/block/MelonStem.php | 2 +- src/PocketMine/block/Potato.php | 2 +- src/PocketMine/block/PumpkinStem.php | 2 +- src/PocketMine/block/RedMushroom.php | 2 +- src/PocketMine/block/RedstoneOre.php | 2 +- src/PocketMine/block/Sapling.php | 2 +- src/PocketMine/block/SignPost.php | 2 +- src/PocketMine/block/SnowLayer.php | 2 +- src/PocketMine/block/Sugarcane.php | 2 +- src/PocketMine/block/TallGrass.php | 2 +- src/PocketMine/block/Torch.php | 2 +- src/PocketMine/block/Water.php | 2 +- src/PocketMine/block/Wheat.php | 2 +- src/PocketMine/entity/Entity.php | 16 +-- src/PocketMine/entity/Human.php | 14 +-- src/PocketMine/entity/InventorySource.php | 2 +- src/PocketMine/event/Event.php | 6 +- src/PocketMine/event/EventHandler.php | 6 +- .../event/block/BlockBreakEvent.php | 2 +- .../event/block/BlockPlaceEvent.php | 2 +- .../event/entity/EntityArmorChangeEvent.php | 2 +- .../entity/EntityInventoryChangeEvent.php | 2 +- .../event/entity/EntityLevelChangeEvent.php | 2 +- .../event/entity/EntityMotionEvent.php | 2 +- .../event/entity/EntityMoveEvent.php | 2 +- .../event/player/PlayerInteractEvent.php | 2 +- .../event/player/PlayerItemHeldEvent.php | 4 +- .../event/server/DataPacketReceiveEvent.php | 4 +- .../event/server/DataPacketSendEvent.php | 4 +- .../event/server/PacketReceiveEvent.php | 2 +- .../event/server/PacketSendEvent.php | 2 +- .../event/tile/TileInventoryChangeEvent.php | 8 +- src/PocketMine/item/Bucket.php | 2 +- src/PocketMine/item/FlintSteel.php | 2 +- src/PocketMine/item/Item.php | 18 +-- src/PocketMine/item/Painting.php | 4 +- src/PocketMine/item/SpawnEgg.php | 4 +- src/PocketMine/level/Explosion.php | 8 +- src/PocketMine/level/Level.php | 12 +- src/PocketMine/level/LevelImport.php | 8 +- src/PocketMine/level/PocketChunkParser.php | 8 +- src/PocketMine/level/WorldGenerator.php | 2 +- src/PocketMine/level/generator/Flat.php | 4 +- src/PocketMine/level/generator/Generator.php | 2 +- src/PocketMine/level/generator/Normal.php | 28 ++--- .../level/generator/noise/Simplex.php | 16 +-- .../level/generator/object/BigTree.php | 2 +- src/PocketMine/level/generator/object/Ore.php | 2 +- .../level/generator/object/PineTree.php | 4 +- .../level/generator/object/Pond.php | 2 +- .../level/generator/object/SmallTree.php | 2 +- .../level/generator/object/SpruceTree.php | 4 +- .../level/generator/object/Tree.php | 4 +- .../level/generator/populator/Mineshaft.php | 2 +- .../level/generator/populator/Ore.php | 2 +- .../level/generator/populator/Pond.php | 2 +- .../level/generator/populator/Populator.php | 2 +- .../level/generator/populator/TallGrass.php | 4 +- .../level/generator/populator/Tree.php | 6 +- src/PocketMine/math/AxisAlignedBB.php | 6 +- src/PocketMine/math/Vector2.php | 8 +- src/PocketMine/math/Vector3.php | 6 +- src/PocketMine/nbt/NBT.php | 7 +- src/PocketMine/nbt/tag/Compound.php | 3 +- src/PocketMine/nbt/tag/Enum.php | 1 + src/PocketMine/nbt/tag/NamedTag.php | 4 +- src/PocketMine/network/Handler.php | 8 +- src/PocketMine/network/UDPSocket.php | 4 +- .../network/protocol/DataPacket.php | 4 +- src/PocketMine/network/query/QueryHandler.php | 4 +- src/PocketMine/network/query/QueryPacket.php | 2 +- src/PocketMine/network/raknet/Packet.php | 18 +-- src/PocketMine/network/rcon/RCON.php | 4 +- src/PocketMine/network/rcon/RCONInstance.php | 10 +- src/PocketMine/network/upnp/UPnP.php | 4 +- src/PocketMine/permission/Permission.php | 8 +- src/PocketMine/plugin/PluginBase.php | 10 +- src/PocketMine/plugin/PluginDescription.php | 33 +++--- src/PocketMine/plugin/PluginManager.php | 28 +++-- src/PocketMine/pmf/LevelFormat.php | 36 +++--- src/PocketMine/pmf/PMF.php | 2 +- src/PocketMine/pmf/Plugin.php | 4 +- src/PocketMine/recipes/Crafting.php | 4 +- src/PocketMine/tile/Chest.php | 6 +- src/PocketMine/tile/Container.php | 24 ++-- src/PocketMine/tile/Furnace.php | 8 +- src/PocketMine/tile/Sign.php | 2 +- src/PocketMine/tile/Tile.php | 2 +- src/PocketMine/utils/Config.php | 24 ++-- src/PocketMine/utils/Utils.php | 32 +++--- src/PocketMine/utils/VersionString.php | 6 +- src/PocketMine/wizard/Installer.php | 22 ++-- src/PocketMine/wizard/InstallerLang.php | 10 +- src/pthreads.php | 4 +- 126 files changed, 473 insertions(+), 469 deletions(-) diff --git a/src/PocketMine/BanAPI.php b/src/PocketMine/BanAPI.php index 910fdcee8..4340bb0b6 100644 --- a/src/PocketMine/BanAPI.php +++ b/src/PocketMine/BanAPI.php @@ -81,7 +81,7 @@ class BanAPI{ $username = strtolower($username); if($this->server->api->dhandle("op.check", $username) === true){ return true; - } elseif($this->ops->exists($username)){ + }elseif($this->ops->exists($username)){ return true; } @@ -121,7 +121,7 @@ class BanAPI{ if($this->server->api->handle("console.check", $data) === true or $this->isOp($data["issuer"]->getUsername())){ return; } - } elseif($data["issuer"] === "console" or $data["issuer"] === "rcon"){ + }elseif($data["issuer"] === "console" or $data["issuer"] === "rcon"){ return; } @@ -185,12 +185,12 @@ class BanAPI{ case "kick": if(!isset($params[0])){ $output .= "Usage: /kick [reason ...]\n"; - } else{ + }else{ $name = strtolower(array_shift($params)); $player = Player::get($name); if($player === false){ $output .= "Player \"" . $name . "\" does not exist\n"; - } else{ + }else{ $reason = implode(" ", $params); $reason = $reason == "" ? "No reason" : $reason; @@ -198,7 +198,7 @@ class BanAPI{ $player->blocked = true; if($issuer instanceof Player){ Player::broadcastChat($player->getUsername() . " has been kicked by " . $issuer->getUsername() . ": $reason\n"); - } else{ + }else{ Player::broadcastChat($player->getUsername() . " has been kicked: $reason\n"); } } @@ -296,7 +296,7 @@ class BanAPI{ } if($issuer instanceof Player){ Player::broadcastChat($user . " has been banned by " . $issuer->getUsername() . "\n"); - } else{ + }else{ Player::broadcastChat($user . " has been banned\n"); } $this->kick($user, "Banned"); @@ -368,9 +368,9 @@ class BanAPI{ public function isIPBanned($ip){ if($this->server->api->dhandle("api.ban.ip.check", $ip) === false){ return true; - } elseif($this->bannedIPs->exists($ip, true)){ + }elseif($this->bannedIPs->exists($ip, true)){ return true; - } else{ + }else{ return false; } } @@ -384,9 +384,9 @@ class BanAPI{ $username = strtolower($username); if($this->server->api->dhandle("api.ban.check", $username) === false){ return true; - } elseif($this->banned->exists($username, true)){ + }elseif($this->banned->exists($username, true)){ return true; - } else{ + }else{ return false; } } @@ -400,9 +400,9 @@ class BanAPI{ $username = strtolower($username); if($this->isOp($username)){ 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; - } elseif($this->whitelist->exists($username, true)){ + }elseif($this->whitelist->exists($username, true)){ return true; } diff --git a/src/PocketMine/BlockAPI.php b/src/PocketMine/BlockAPI.php index 107f5f739..6e3b99673 100644 --- a/src/PocketMine/BlockAPI.php +++ b/src/PocketMine/BlockAPI.php @@ -248,7 +248,7 @@ class BlockAPI{ if(!isset($params[2])){ $item->setCount($item->getMaxStackSize()); - } else{ + }else{ $item->setCount((int) $params[2]); } @@ -263,7 +263,7 @@ class BlockAPI{ } $player->addItem(clone $item); $output .= "Giving " . $item->getCount() . " of " . $item->getName() . " (" . $item->getID() . ":" . $item->getMetadata() . ") to " . $player->getUsername() . "\n"; - } else{ + }else{ $output .= "Unknown player.\n"; } @@ -281,7 +281,7 @@ class BlockAPI{ $this->scheduleBlockUpdate($pos->getSide(3), $delay, $type); $this->scheduleBlockUpdate($pos->getSide(4), $delay, $type); $this->scheduleBlockUpdate($pos->getSide(5), $delay, $type); - } else{ + }else{ $this->blockUpdate($pos->getSide(0), $type); $this->blockUpdate($pos->getSide(1), $type); $this->blockUpdate($pos->getSide(2), $type); @@ -294,7 +294,7 @@ class BlockAPI{ public function blockUpdate(Position $pos, $type = Level::BLOCK_UPDATE_NORMAL){ if(!($pos instanceof BLock\Block)){ $block = $pos->level->getBlock($pos); - } else{ + }else{ $pos = new Position($pos->x, $pos->y, $pos->z, $pos->level); $block = $pos->level->getBlock($pos); } diff --git a/src/PocketMine/ChatAPI.php b/src/PocketMine/ChatAPI.php index 4cbc24d78..dcc5cce94 100644 --- a/src/PocketMine/ChatAPI.php +++ b/src/PocketMine/ChatAPI.php @@ -65,10 +65,10 @@ class ChatAPI{ if(!($issuer instanceof Player)){ if($issuer === "rcon"){ $sender = "Rcon"; - } else{ + }else{ $sender = ucfirst($issuer); } - } else{ + }else{ $sender = $issuer->getUsername(); } Player::broadcastChat("* $sender " . implode(" ", $params)); @@ -80,7 +80,7 @@ class ChatAPI{ } if(!($issuer instanceof Player)){ $sender = ucfirst($issuer); - } else{ + }else{ $sender = $issuer; } $n = array_shift($params); diff --git a/src/PocketMine/ConsoleAPI.php b/src/PocketMine/ConsoleAPI.php index 32134a5a8..865bcc7db 100644 --- a/src/PocketMine/ConsoleAPI.php +++ b/src/PocketMine/ConsoleAPI.php @@ -142,7 +142,7 @@ class ConsoleAPI{ $curpage = (int) ceil($current / 5); if($curpage === $page){ $output .= "/$c " . $h . "\n"; - } elseif($curpage > $page){ + }elseif($curpage > $page){ break; } ++$current; @@ -186,7 +186,7 @@ class ConsoleAPI{ } if($issuer instanceof Player){ 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); } @@ -220,10 +220,10 @@ class ConsoleAPI{ foreach(Player::getAll() as $p){ $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"); } - } else{ + }else{ $output = ""; foreach(Player::getAll() as $p){ $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 ){ $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])){ $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); } } @@ -289,7 +289,7 @@ class ConsoleAPI{ console("[CMD] " . $m); } } - } else{ + }else{ $this->loop->notify(); } } @@ -316,7 +316,7 @@ class ConsoleLoop extends \Thread{ private function readLine(){ if($this->fp){ $line = trim(fgets($this->fp)); - } else{ + }else{ $line = trim(readline("")); if($line != ""){ readline_add_history($line); diff --git a/src/PocketMine/LevelAPI.php b/src/PocketMine/LevelAPI.php index 080de806a..1b1e08c30 100644 --- a/src/PocketMine/LevelAPI.php +++ b/src/PocketMine/LevelAPI.php @@ -55,11 +55,11 @@ class LevelAPI{ case "seed": if(!isset($params[0]) and ($issuer instanceof Player)){ $output .= "Seed: " . $issuer->level->getSeed() . "\n"; - } elseif(isset($params[0])){ + }elseif(isset($params[0])){ if(($lv = Level::get(trim(implode(" ", $params)))) !== false){ $output .= "Seed: " . $lv->getSeed() . "\n"; } - } else{ + }else{ $output .= "Seed: " . Level::getDefault()->getSeed() . "\n"; } } diff --git a/src/PocketMine/Player.php b/src/PocketMine/Player.php index 0fa6c399b..355e8814a 100644 --- a/src/PocketMine/Player.php +++ b/src/PocketMine/Player.php @@ -22,8 +22,8 @@ namespace PocketMine; use PocketMine\Entity\RealHuman; -use PocketMine\Event; use PocketMine\Event\EventHandler; +use PocketMine\Event; use PocketMine\Item\Item; use PocketMine\Level\Level; use PocketMine\Level\Position; @@ -83,8 +83,8 @@ use PocketMine\Utils\Utils; class Player extends RealHuman{ const MAX_QUEUE = 2048; const SURVIVAL_SLOTS = 36; -const CREATIVE_SLOTS = 112; - public static $list = array(); //???? + const CREATIVE_SLOTS = 112; + public static $list = array(); //???? public $auth = false; public $CID; public $MTU; @@ -246,7 +246,7 @@ const CREATIVE_SLOTS = 112; } return; - } else{ + }else{ unset($this->chunkCount[$count]); } } @@ -492,7 +492,7 @@ const CREATIVE_SLOTS = 112; public function setSpawn(Vector3 $pos){ if(!($pos instanceof Position)){ $level = $this->level; - } else{ + }else{ $level = $pos->level; } $this->spawnPosition = new Position($pos->x, $pos->y, $pos->z, $level); @@ -584,7 +584,7 @@ const CREATIVE_SLOTS = 112; $this->awardAchievement("diamond"); break; } - } elseif($data["entity"]->level === $this->level){ + }elseif($data["entity"]->level === $this->level){ $pk = new TakeItemEntityPacket; $pk->eid = $data["eid"]; $pk->target = $data["entity"]->getID(); @@ -603,7 +603,7 @@ const CREATIVE_SLOTS = 112; case "entity.metadata": if($data->getID() === $this->id){ $eid = 0; - } else{ + }else{ $eid = $data->getID(); } if($data->level === $this->level){ @@ -616,7 +616,7 @@ const CREATIVE_SLOTS = 112; case "entity.event": if($data["entity"]->getID() === $this->id){ $eid = 0; - } else{ + }else{ $eid = $data["entity"]->getID(); } if($data["entity"]->level === $this->level){ @@ -641,7 +641,7 @@ const CREATIVE_SLOTS = 112; Achievement::broadcast($this, $achievementId); return true; - } else{ + }else{ return false; } } @@ -665,7 +665,7 @@ const CREATIVE_SLOTS = 112; if(($this->gamemode & 0x01) === ($gm & 0x01)){ $this->gamemode = $gm; $this->sendChat("Your gamemode has been changed to " . $this->getGamemode() . ".\n"); - } else{ + }else{ $this->blocked = true; $this->gamemode = $gm; $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){ $this->packetLoss = $this->packetStats[1] / max(1, $this->packetStats[0] + $this->packetStats[1]); - } else{ + }else{ $this->packetLoss = 0; } $this->packetStats = array(0, 0); @@ -824,7 +824,7 @@ const CREATIVE_SLOTS = 112; if(isset($p->messageIndex) and $p->messageIndex !== false){ if($p->messageIndex > $this->receiveCount){ $this->receiveCount = $p->messageIndex; - } elseif($p->messageIndex !== 0){ + }elseif($p->messageIndex !== 0){ if(isset($this->received[$p->messageIndex])){ continue; } @@ -934,7 +934,7 @@ const CREATIVE_SLOTS = 112; $pk = new LoginStatusPacket; $pk->status = 1; $this->directDataPacket($pk); - } else{ + }else{ $pk = new LoginStatusPacket; $pk->status = 2; $this->directDataPacket($pk); @@ -959,7 +959,7 @@ const CREATIVE_SLOTS = 112; $this->close($this->username . " has left the game", "Server is white-listed"); 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"); return; @@ -1009,7 +1009,7 @@ const CREATIVE_SLOTS = 112; if(($this->gamemode & 0x01) === 0x01){ $this->slot = 0; $this->hotbar[0] = 0; - } else{ + }else{ $this->slot = $this->hotbar[0]; } @@ -1108,7 +1108,7 @@ const CREATIVE_SLOTS = 112; if($this->forceMovement instanceof Vector3){ if($this->forceMovement->distance($newPos) <= 0.7){ $this->forceMovement = false; - } else{ + }else{ $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 $packet->slot = -1; //Air - } else{ + }else{ $packet->slot -= 9; //Get real block slot } @@ -1240,7 +1240,7 @@ const CREATIVE_SLOTS = 112; $pk->meta = $block->getMetadata(); $this->dataPacket($pk); 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->startAction = microtime(true); //$this->updateMetadata(); @@ -1365,7 +1365,7 @@ const CREATIVE_SLOTS = 112; $s = $packet->slots[$i]; if($s === 0 or $s === 255){ $s = Item::get(Item::AIR, 0, 0); - } else{ + }else{ $s = Item::get($s + 256, 0, 1); } $slot = $this->getArmorSlot($i); @@ -1373,7 +1373,7 @@ const CREATIVE_SLOTS = 112; if($this->setArmorSlot($i, Item::get(Item::AIR, 0, 0)) === false){ $this->sendArmor(); $this->sendInventory(); - } else{ + }else{ $this->addItem($slot); $packet->slots[$i] = 255; } @@ -1381,17 +1381,17 @@ const CREATIVE_SLOTS = 112; if($this->setArmorSlot($i, $this->getSlot($sl)) === false){ $this->sendArmor(); $this->sendInventory(); - } else{ + }else{ $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){ if($this->setArmorSlot($i, $this->getSlot($sl)) === false){ $this->sendArmor(); $this->sendInventory(); - } else{ + }else{ $this->setSlot($sl, $slot); } - } else{ + }else{ $packet->slots[$i] = 255; } @@ -1606,7 +1606,7 @@ const CREATIVE_SLOTS = 112; $message = $packet->message; if($message{0} === "/"){ //Command $this->server->api->console->run(substr($message, 1), $this); - } else{ + }else{ $ev = new Event\Player\PlayerChatEvent($this, $message); if(EventHandler::callEvent($ev) !== Event\Event::DENY){ Player::groupChat(sprintf($ev->getFormat(), $ev->getPlayer()->getUsername(), $ev->getMessage()), $ev->getRecipients()); @@ -1631,7 +1631,7 @@ const CREATIVE_SLOTS = 112; $pk->case2 = 0; Player::broadcastPacket($this->level->players, $pk); } - } elseif($this->windows[$packet->windowid] instanceof Chest){ + }elseif($this->windows[$packet->windowid] instanceof Chest){ $pk = new TileEventPacket; $pk->x = $this->windows[$packet->windowid]->x; $pk->y = $this->windows[$packet->windowid]->y; @@ -1655,7 +1655,7 @@ const CREATIVE_SLOTS = 112; if($this->lastCraft <= (microtime(true) - 1)){ if(isset($this->toCraft[-1])){ $this->toCraft = array(-1 => $this->toCraft[-1]); - } else{ + }else{ $this->toCraft = array(); } $this->craftingItems = array(); @@ -1668,14 +1668,14 @@ const CREATIVE_SLOTS = 112; $use = Item::get($slot->getID(), $slot->getMetadata(), $slot->getCount() - $packet->item->getCount()); $this->craftingItems[$packet->slot] = $use; $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()); if(count($this->toCraft) === 0){ $this->toCraft[-1] = 0; } $this->toCraft[$packet->slot] = $craftItem; $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()); if(count($this->toCraft) === 0){ $this->toCraft[-1] = 0; @@ -1694,12 +1694,12 @@ const CREATIVE_SLOTS = 112; if($recipe === false){ $this->sendInventory(); $this->toCraft = array(); - } else{ + }else{ $this->toCraft = array(-1 => $this->toCraft[-1]); } $this->craftingItems = array(); } - } else{ + }else{ $this->toCraft = array(); $this->craftingItems = array(); } @@ -1713,11 +1713,11 @@ const CREATIVE_SLOTS = 112; $tile = $tiles[0]; $slotn = $packet->slot; $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]; $slotn = $packet->slot - Chest::SLOTS; $offset = Chest::SLOTS; - } else{ + }else{ break; } @@ -1748,12 +1748,12 @@ const CREATIVE_SLOTS = 112; $this->sendInventory(); break; } - } elseif($slot->getCount() > $item->getCount()){ + }elseif($slot->getCount() > $item->getCount()){ $it = clone $item; $it->setCount($slot->getCount() - $item->getCount()); $this->addItem($it); } - } else{ + }else{ if($this->removeItem($item) === false){ $this->sendInventory(); break; @@ -1761,7 +1761,7 @@ const CREATIVE_SLOTS = 112; $this->addItem($slot); } $tile->setSlot($slotn, $item, true, $offset); - } else{ + }else{ $tile = $this->windows[$packet->windowid]; if( !($tile instanceof Chest or $tile instanceof Furnace) @@ -1810,12 +1810,12 @@ const CREATIVE_SLOTS = 112; $this->sendInventory(); break; } - } elseif($slot->getCount() > $item->getCount()){ + }elseif($slot->getCount() > $item->getCount()){ $it = clone $item; $it->setCount($slot->count - $item->count); $this->addItem($it); } - } else{ + }else{ if($this->removeItem($item) === false){ $this->sendInventory(); break; @@ -1840,12 +1840,12 @@ const CREATIVE_SLOTS = 112; if($t instanceof Sign){ if($t->namedtag->creator !== $this->username){ $t->spawnTo($this); - } else{ + }else{ $nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt->read($packet->namedtag); if($nbt->id !== Tile::SIGN){ $t->spawnTo($this); - } else{ + }else{ $t->setText($nbt->Text1, $nbt->Text2, $nbt->Text3, $nbt->Text4); } } @@ -2022,9 +2022,9 @@ const CREATIVE_SLOTS = 112; /** * Gets a player, or multiple * - * @param string $name name/partial name to search - * @param bool $alike = true, if false, will only return exact matches - * @param bool $multiple = false, if true, will return an array with all the players that match + * @param string $name name/partial name to search + * @param bool $alike = true, if false, will only return exact matches + * @param bool $multiple = false, if true, will return an array with all the players that match * * @return Player[]|bool|Player */ @@ -2037,7 +2037,7 @@ const CREATIVE_SLOTS = 112; foreach(Player::$list as $player){ if($multiple === false and $player->iusername === $name){ return $player; - } elseif(strpos($player->iusername, $name) !== false){ + }elseif(strpos($player->iusername, $name) !== false){ $players[$player->CID] = $player; } } @@ -2045,10 +2045,10 @@ const CREATIVE_SLOTS = 112; if($multiple === false){ if(count($players) > 0){ return array_shift($players); - } else{ + }else{ return false; } - } else{ + }else{ return $players; } } @@ -2149,23 +2149,24 @@ const CREATIVE_SLOTS = 112; $nbt->Achievements[$achievement] = new Byte($achievement, $status == true ? 1 : 0); } unlink(\PocketMine\DATA . "players/" . $iname . ".yml"); - } else{ + }else{ console("[NOTICE] Player data not found for \"" . $iname . "\", creating new profile"); Player::saveOffline($name, $nbt); } - } else{ + }else{ $nbt = new NBT(NBT::BIG_ENDIAN); $nbt->readCompressed(file_get_contents(\PocketMine\DATA . "players/" . $iname . ".dat")); $nbt = $nbt->getData(); } + return $nbt; } /** * Saves a compressed NBT Coumpound tag as a player data * - * @param string $name + * @param string $name * @param Compound $nbtTag */ public static function saveOffline($name, Compound $nbtTag){ @@ -2222,7 +2223,7 @@ const CREATIVE_SLOTS = 112; $craftItem[0] = $item->getID(); if($item->getMetadata() !== $craftItem[1] and $craftItem[1] !== true){ $craftItem[1] = false; - } else{ + }else{ $craftItem[1] = $item->getMetadata(); } $craftItem[2] += $item->getCount(); @@ -2234,7 +2235,7 @@ const CREATIVE_SLOTS = 112; foreach($recipe as $slot => $item){ if(!isset($recipeItems[$item->getID()])){ $recipeItems[$item->getID()] = array($item->getID(), $item->getMetadata(), $item->getCount()); - } else{ + }else{ if($item->getMetadata() !== $recipeItems[$item->getID()][1]){ $recipeItems[$item->getID()][1] = false; } @@ -2267,7 +2268,7 @@ const CREATIVE_SLOTS = 112; $s = $this->getSlot($slot); if($s->getCount() <= 0 or $s->getID() === Item::AIR){ $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())); } @@ -2424,6 +2425,4 @@ const CREATIVE_SLOTS = 112; } - - } diff --git a/src/PocketMine/PlayerAPI.php b/src/PocketMine/PlayerAPI.php index cc3d161e8..47ab26dc1 100644 --- a/src/PocketMine/PlayerAPI.php +++ b/src/PocketMine/PlayerAPI.php @@ -82,7 +82,7 @@ class PlayerAPI{ break; } } - } else{ + }else{ switch($data["cause"]){ case "cactus": $message = " was pricked to death"; @@ -140,10 +140,10 @@ class PlayerAPI{ $tg = array_shift($params); if(count($params) === 3 and substr($tg, 0, 2) === "w:"){ $target = Level::get(substr($tg, 2)); - } else{ + }else{ $target = Player::get($tg); } - } else{ + }else{ $target = $issuer; } @@ -155,19 +155,19 @@ class PlayerAPI{ if(count($params) === 3){ if($target instanceof Level){ $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); } - } else{ + }else{ $spawn = new Position($issuer->entity->x, $issuer->entity->y, $issuer->entity->z, $issuer->entity->level); } $target->setSpawn($spawn); if($target instanceof Level){ $output .= "Spawnpoint of world " . $target->getName() . " set correctly!\n"; - } elseif($target !== $issuer){ + }elseif($target !== $issuer){ $output .= "Spawnpoint of " . $target->getUsername() . " set correctly!\n"; - } else{ + }else{ $output .= "Spawnpoint set correctly!\n"; } break; @@ -208,14 +208,14 @@ class PlayerAPI{ if(Player::get($params[1]) instanceof Player){ $player = Player::get($params[1]); $setgm = $params[0]; - } elseif(Player::get($params[0]) instanceof Player){ + }elseif(Player::get($params[0]) instanceof Player){ $player = Player::get($params[0]); $setgm = $params[1]; - } else{ + }else{ $output .= "Usage: /$cmd [player] or /$cmd [player] \n"; break; } - } elseif(isset($params[0])){ + }elseif(isset($params[0])){ if(!(Player::get($params[0]) instanceof Player)){ if($issuer instanceof Player){ $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)){ $name = $issuer->getUsername(); $target = implode(" ", $params); - } elseif(isset($params[1]) and isset($params[0])){ + }elseif(isset($params[1]) and isset($params[0])){ $name = array_shift($params); $target = implode(" ", $params); - } else{ + }else{ $output .= "Usage: /$cmd [target player] \n"; break; } if($this->teleport($name, $target) !== false){ $output .= "\"$name\" teleported to \"$target\"\n"; - } else{ + }else{ $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)){ $name = $issuer->getUsername(); $x = $params[0]; $y = $params[1]; $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]; $x = $params[1]; $y = $params[2]; $z = $params[3]; - } else{ + }else{ $output .= "Usage: /$cmd [player] \n"; break; } if($this->tppos($name, $x, $y, $z)){ $output .= "\"$name\" teleported to ($x, $y, $z)\n"; - } else{ + }else{ $output .= "Couldn't teleport.\n"; } } @@ -275,13 +275,13 @@ class PlayerAPI{ case "suicide": if(!isset($params[0]) and ($issuer instanceof Player)){ $player = $issuer; - } else{ + }else{ $player = Player::get($params[0]); } if($player instanceof Player){ $player->harm(1000, "console", true); $player->sendChat("Ouch. That looks like it hurt.\n"); - } else{ + }else{ $output .= "Usage: /$cmd [player]\n"; } break; @@ -310,7 +310,7 @@ class PlayerAPI{ return $origin->teleport($lv->getSafeSpawn()); } - } else{ + }else{ return false; } } diff --git a/src/PocketMine/PocketMine.php b/src/PocketMine/PocketMine.php index 80713742b..78e31e292 100644 --- a/src/PocketMine/PocketMine.php +++ b/src/PocketMine/PocketMine.php @@ -46,18 +46,18 @@ namespace PocketMine { $className = array_pop($path); if(count($path) > 0){ $path = implode(DIRECTORY_SEPARATOR, array_map("strtolower", $path)) . DIRECTORY_SEPARATOR; - } else{ + }else{ $path = ""; } $fPath = \PocketMine\PATH . "src" . DIRECTORY_SEPARATOR . "PocketMine" . DIRECTORY_SEPARATOR . $path . $className . ".php"; if(file_exists($fPath)){ require_once($fPath); } - } else{ //Try plugin + }else{ //Try plugin $className = array_pop($path); if(count($path) > 0){ $path = implode(DIRECTORY_SEPARATOR, array_map("strtolower", $path)) . DIRECTORY_SEPARATOR; - } else{ + }else{ $path = ""; } $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); $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; - } else{ + }else{ exec("date +%s", $t); $offset = round((intval(trim($t[0])) - time()) / 60) * 60; } @@ -94,7 +94,7 @@ namespace PocketMine { $d = timezone_name_from_abbr("", $offset, $daylight); @ini_set("date.timezone", $d); date_default_timezone_set($d); - } else{ + }else{ $d = @date_default_timezone_get(); if(strpos($d, "/") === false){ $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"])){ define("PocketMine\\ANSI", true); - } else{ + }else{ define("PocketMine\\ANSI", false); } @@ -168,7 +168,7 @@ namespace PocketMine { case "mac": case "linux": default: - exec("kill -9 " . ((int) $pid) . " > /dev/null 2>&1"); + exec("kill -9 " . ((int) $pid) . " > /dev/null 2>&1"); } } @@ -182,13 +182,13 @@ namespace PocketMine { } $var = null; unset($var); - } elseif(is_array($var)){ + }elseif(is_array($var)){ foreach($var as $i => $v){ hard_unset($var[$i]); } $var = null; unset($var); - } else{ + }else{ $var = null; unset($var); } @@ -235,7 +235,7 @@ namespace PocketMine { } } $message = Utils\TextFormat::toANSI($time . $add . $message . Utils\TextFormat::RESET); - } else{ + }else{ $message = $replaced; } echo $message; @@ -332,7 +332,7 @@ namespace PocketMine { if(!extension_loaded("pthreads")){ console("[ERROR] Unable to find the pthreads extension.", true, true, 0); ++$errors; - } else{ + }else{ $pthreads_version = phpversion("pthreads"); if(substr_count($pthreads_version, ".") < 2){ $pthreads_version = "0.$pthreads_version"; @@ -371,7 +371,7 @@ namespace PocketMine { $gitsha1 = false; 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")))); - } else{ //Unknown :( + }else{ //Unknown :( define("PocketMine\\GIT_COMMIT", str_repeat("00", 20)); } diff --git a/src/PocketMine/Server.php b/src/PocketMine/Server.php index baa15e9ec..913eb01a5 100644 --- a/src/PocketMine/Server.php +++ b/src/PocketMine/Server.php @@ -284,7 +284,7 @@ class Server{ if(is_array($this->async[$ID])){ $method = $this->async[$ID][1]; $result = $this->async[$ID][0]->$method($data, $type, $ID); - } else{ + }else{ $result = $this->async[$ID]($data, $type, $ID); } } @@ -334,10 +334,10 @@ class Server{ if(is_array($handler)){ $method = $handler[1]; $result = $handler[0]->$method($data, $event); - } else{ + }else{ $result = $handler($data, $event); } - } else{ + }else{ break; } } @@ -499,7 +499,7 @@ class Server{ $CID = Server::clientID($packet->ip, $packet->port); if(isset(Player::$list[$CID])){ Player::$list[$CID]->handlePacket($packet); - } else{ + }else{ switch($packet->pid()){ case RakNetInfo::UNCONNECTED_PING: case RakNetInfo::UNCONNECTED_PING_OPEN_CONNECTIONS: @@ -539,7 +539,7 @@ class Server{ $pk->ip = $packet->ip; $pk->port = $packet->port; $this->send($pk); - } else{ + }else{ $pk = new RakNetPacket(RakNetInfo::OPEN_CONNECTION_REPLY_1); $pk->serverID = $this->serverID; $pk->mtuSize = strlen($packet->buffer); @@ -582,11 +582,11 @@ class Server{ ++$lastLoop; if($lastLoop < 16){ usleep(1); - } elseif($lastLoop < 128){ + }elseif($lastLoop < 128){ usleep(1000); - } elseif($lastLoop < 256){ + }elseif($lastLoop < 256){ usleep(2000); - } else{ + }else{ usleep(4000); } } @@ -603,7 +603,7 @@ class Server{ if(is_array($ev)){ $method = $ev[1]; $ev[0]->$method($data, $event); - } else{ + }else{ $ev($data, $event); } } @@ -637,7 +637,7 @@ class Server{ $this->preparedSQL->updateAction->execute(); if(!@is_callable($this->schedule[$cid][0])){ $return = false; - } else{ + }else{ ++$actionCount; $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){ if(!is_callable($func)){ return false; - } elseif(isset(Deprecation::$events[$event])){ + }elseif(isset(Deprecation::$events[$event])){ $sub = ""; if(Deprecation::$events[$event] !== false){ $sub = " Substitute \"" . Deprecation::$events[$event] . "\" found."; diff --git a/src/PocketMine/ServerAPI.php b/src/PocketMine/ServerAPI.php index fafd652a5..9bcd3ea25 100644 --- a/src/PocketMine/ServerAPI.php +++ b/src/PocketMine/ServerAPI.php @@ -30,7 +30,6 @@ use PocketMine\Network\Query\QueryHandler; use PocketMine\Network\RCON\RCON; use PocketMine\Network\UPnP\UPnP; use PocketMine\Plugin\PluginManager; -use PocketMine\PMF\Plugin; use PocketMine\Recipes\Crafting; use PocketMine\Tile\Tile; 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); if($info === false or !isset($info[0])){ console("[ERROR] Github API error"); - } else{ + }else{ $last = new \DateTime($info[0]["commit"]["committer"]["date"]); $last = $last->getTimestamp(); 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 . "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\""); - } else{ + }else{ $this->setProperty("last-update", time()); 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); if($info === false or !isset($info[0])){ console("[ERROR] Github API error"); - } else{ + }else{ $newest = new VersionString(VERSION); $newestN = $newest->getNumber(); $update = new VersionString($info[0]["name"]); @@ -196,7 +195,7 @@ class ServerAPI{ console("[NOTICE] " . TextFormat::GREEN . "Version \"" . $info[0]["name"] . "\" #" . $updateN); console("[NOTICE] Get it at PocketMine.net or at " . $info[0]["zipball_url"]); console("[NOTICE] This message will disappear as soon as you update"); - } else{ + }else{ $this->setProperty("last-update", time()); 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); } @ini_set("memory_limit", $memory); - } else{ + }else{ $this->setProperty("memory-limit", "128M"); } @@ -339,7 +338,7 @@ class ServerAPI{ case "last-update": if($v === false){ $v = time(); - } else{ + }else{ $v = (int) $v; } break; @@ -464,7 +463,7 @@ class ServerAPI{ case "last-update": if($v === false){ $v = time(); - } else{ + }else{ $v = (int) $v; } break; diff --git a/src/PocketMine/TimeAPI.php b/src/PocketMine/TimeAPI.php index dd135714a..1f222b96d 100644 --- a/src/PocketMine/TimeAPI.php +++ b/src/PocketMine/TimeAPI.php @@ -116,11 +116,11 @@ class TimeAPI{ $time = !is_integer($time) ? $this->get(false, $time) : $time; if($time < TimeAPI::$phases["sunset"]){ $time = "day"; - } elseif($time < TimeAPI::$phases["night"]){ + }elseif($time < TimeAPI::$phases["night"]){ $time = "sunset"; - } elseif($time < TimeAPI::$phases["sunrise"]){ + }elseif($time < TimeAPI::$phases["sunrise"]){ $time = "night"; - } else{ + }else{ $time = "sunrise"; } @@ -133,7 +133,7 @@ class TimeAPI{ } if(is_string($time) and isset(TimeAPI::$phases[$time])){ $level->setTime(TimeAPI::$phases[$time]); - } else{ + }else{ $level->setTime((int) $time); } diff --git a/src/PocketMine/block/Bed.php b/src/PocketMine/block/Bed.php index 5138ad882..329af3308 100644 --- a/src/PocketMine/block/Bed.php +++ b/src/PocketMine/block/Bed.php @@ -21,10 +21,10 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Network\Protocol\ChatPacket; use PocketMine\ServerAPI; +use PocketMine; class Bed extends Transparent{ public function __construct($type = 0){ diff --git a/src/PocketMine/block/Beetroot.php b/src/PocketMine/block/Beetroot.php index 335e47944..cce09b322 100644 --- a/src/PocketMine/block/Beetroot.php +++ b/src/PocketMine/block/Beetroot.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class Beetroot extends Flowable{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/Block.php b/src/PocketMine/block/Block.php index 914a09a2e..768da8b5e 100644 --- a/src/PocketMine/block/Block.php +++ b/src/PocketMine/block/Block.php @@ -24,10 +24,10 @@ */ namespace PocketMine\Block; +use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; use PocketMine\Level\Position; -use PocketMine; abstract class Block extends Position{ const AIR = 0; diff --git a/src/PocketMine/block/BrownMushroom.php b/src/PocketMine/block/BrownMushroom.php index a81a8039f..40d06b899 100644 --- a/src/PocketMine/block/BrownMushroom.php +++ b/src/PocketMine/block/BrownMushroom.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class BrownMushroom extends Flowable{ public function __construct(){ diff --git a/src/PocketMine/block/BurningFurnace.php b/src/PocketMine/block/BurningFurnace.php index 97f13aa32..6bd7ca4c6 100644 --- a/src/PocketMine/block/BurningFurnace.php +++ b/src/PocketMine/block/BurningFurnace.php @@ -22,13 +22,13 @@ namespace PocketMine\Block; use PocketMine\Item\Item; -use PocketMine; use PocketMine\NBT\NBT; use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Enum; use PocketMine\NBT\Tag\Int; use PocketMine\NBT\Tag\String; use PocketMine\Tile\Furnace; +use PocketMine; use PocketMine\Tile\Tile; class BurningFurnace extends Solid{ diff --git a/src/PocketMine/block/Cactus.php b/src/PocketMine/block/Cactus.php index 52dc1c782..bb544ddec 100644 --- a/src/PocketMine/block/Cactus.php +++ b/src/PocketMine/block/Cactus.php @@ -21,11 +21,11 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; use PocketMine\Math\Vector3 as Vector3; use PocketMine\ServerAPI; +use PocketMine; class Cactus extends Transparent{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/Cake.php b/src/PocketMine/block/Cake.php index 5ce39baf9..44898c49c 100644 --- a/src/PocketMine/block/Cake.php +++ b/src/PocketMine/block/Cake.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class Cake extends Transparent{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/Carpet.php b/src/PocketMine/block/Carpet.php index 8e00c774c..8953e47ee 100644 --- a/src/PocketMine/block/Carpet.php +++ b/src/PocketMine/block/Carpet.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class Carpet extends Flowable{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/Carrot.php b/src/PocketMine/block/Carrot.php index dc5a99a8d..5fb6fb8f7 100644 --- a/src/PocketMine/block/Carrot.php +++ b/src/PocketMine/block/Carrot.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class Carrot extends Flowable{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/Chest.php b/src/PocketMine/block/Chest.php index 2f4b5bd17..214104dad 100644 --- a/src/PocketMine/block/Chest.php +++ b/src/PocketMine/block/Chest.php @@ -22,13 +22,13 @@ namespace PocketMine\Block; use PocketMine\Item\Item; -use PocketMine; use PocketMine\NBT\NBT; use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Enum; use PocketMine\NBT\Tag\Int; use PocketMine\NBT\Tag\String; use PocketMine\Tile\Chest as TileChest; +use PocketMine; use PocketMine\Tile\Tile; class Chest extends Transparent{ diff --git a/src/PocketMine/block/CyanFlower.php b/src/PocketMine/block/CyanFlower.php index 628b69b5a..6bd48c3ae 100644 --- a/src/PocketMine/block/CyanFlower.php +++ b/src/PocketMine/block/CyanFlower.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class CyanFlower extends Flowable{ public function __construct(){ diff --git a/src/PocketMine/block/Dandelion.php b/src/PocketMine/block/Dandelion.php index 6b91921b3..f9158d8ac 100644 --- a/src/PocketMine/block/Dandelion.php +++ b/src/PocketMine/block/Dandelion.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class Dandelion extends Flowable{ public function __construct(){ diff --git a/src/PocketMine/block/Door.php b/src/PocketMine/block/Door.php index 2df766354..5bca9da8f 100644 --- a/src/PocketMine/block/Door.php +++ b/src/PocketMine/block/Door.php @@ -21,11 +21,11 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; use PocketMine\Network\Protocol\LevelEventPacket; use PocketMine\Player; +use PocketMine; abstract class Door extends Transparent{ diff --git a/src/PocketMine/block/Fallable.php b/src/PocketMine/block/Fallable.php index 5854e53f7..68ac07ef5 100644 --- a/src/PocketMine/block/Fallable.php +++ b/src/PocketMine/block/Fallable.php @@ -21,10 +21,10 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; use PocketMine\ServerAPI; +use PocketMine; class Fallable extends Solid{ diff --git a/src/PocketMine/block/Fire.php b/src/PocketMine/block/Fire.php index 0bc2466b3..4e4d8a211 100644 --- a/src/PocketMine/block/Fire.php +++ b/src/PocketMine/block/Fire.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class Fire extends Flowable{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/Generic.php b/src/PocketMine/block/Generic.php index 9baf4db34..4cc4ae0c7 100644 --- a/src/PocketMine/block/Generic.php +++ b/src/PocketMine/block/Generic.php @@ -21,10 +21,10 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; use PocketMine\ServerAPI; +use PocketMine; class Generic extends Block{ diff --git a/src/PocketMine/block/GlowingRedstoneOre.php b/src/PocketMine/block/GlowingRedstoneOre.php index 604894ac6..1744fde81 100644 --- a/src/PocketMine/block/GlowingRedstoneOre.php +++ b/src/PocketMine/block/GlowingRedstoneOre.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class GlowingRedstoneOre extends Solid{ public function __construct(){ diff --git a/src/PocketMine/block/Grass.php b/src/PocketMine/block/Grass.php index 0da1929e4..a2c9e1043 100644 --- a/src/PocketMine/block/Grass.php +++ b/src/PocketMine/block/Grass.php @@ -21,10 +21,10 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Generator\Object\TallGrass; use PocketMine\Utils\Random; +use PocketMine; class Grass extends Solid{ public function __construct(){ diff --git a/src/PocketMine/block/Ladder.php b/src/PocketMine/block/Ladder.php index a5996cb0d..58d88174f 100644 --- a/src/PocketMine/block/Ladder.php +++ b/src/PocketMine/block/Ladder.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class Ladder extends Transparent{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/Lava.php b/src/PocketMine/block/Lava.php index f90dff027..27e9640a1 100644 --- a/src/PocketMine/block/Lava.php +++ b/src/PocketMine/block/Lava.php @@ -21,11 +21,11 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; use PocketMine\Level\Position; use PocketMine\ServerAPI; +use PocketMine; class Lava extends Liquid{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/Leaves.php b/src/PocketMine/block/Leaves.php index f3585a172..8c2cbecf8 100644 --- a/src/PocketMine/block/Leaves.php +++ b/src/PocketMine/block/Leaves.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class Leaves extends Transparent{ const OAK = 0; diff --git a/src/PocketMine/block/MelonStem.php b/src/PocketMine/block/MelonStem.php index bd9d37c04..363ff2438 100644 --- a/src/PocketMine/block/MelonStem.php +++ b/src/PocketMine/block/MelonStem.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class MelonStem extends Flowable{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/Potato.php b/src/PocketMine/block/Potato.php index b5206b20f..e83aa2194 100644 --- a/src/PocketMine/block/Potato.php +++ b/src/PocketMine/block/Potato.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class Potato extends Flowable{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/PumpkinStem.php b/src/PocketMine/block/PumpkinStem.php index 43bad40a2..a407efd85 100644 --- a/src/PocketMine/block/PumpkinStem.php +++ b/src/PocketMine/block/PumpkinStem.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class PumpkinStem extends Flowable{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/RedMushroom.php b/src/PocketMine/block/RedMushroom.php index 7bb3a91f3..4997db200 100644 --- a/src/PocketMine/block/RedMushroom.php +++ b/src/PocketMine/block/RedMushroom.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class RedMushroom extends Flowable{ public function __construct(){ diff --git a/src/PocketMine/block/RedstoneOre.php b/src/PocketMine/block/RedstoneOre.php index 37206d898..a2c2d8715 100644 --- a/src/PocketMine/block/RedstoneOre.php +++ b/src/PocketMine/block/RedstoneOre.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class RedstoneOre extends Solid{ public function __construct(){ diff --git a/src/PocketMine/block/Sapling.php b/src/PocketMine/block/Sapling.php index bb9501a26..084ff463e 100644 --- a/src/PocketMine/block/Sapling.php +++ b/src/PocketMine/block/Sapling.php @@ -21,11 +21,11 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Generator\Object\Tree; use PocketMine\Level\Level; use PocketMine\Utils\Random; +use PocketMine; class Sapling extends Flowable{ const OAK = 0; diff --git a/src/PocketMine/block/SignPost.php b/src/PocketMine/block/SignPost.php index 2ef596259..416d4120d 100644 --- a/src/PocketMine/block/SignPost.php +++ b/src/PocketMine/block/SignPost.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class SignPost extends Transparent{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/SnowLayer.php b/src/PocketMine/block/SnowLayer.php index 9ad520a72..fee49211b 100644 --- a/src/PocketMine/block/SnowLayer.php +++ b/src/PocketMine/block/SnowLayer.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class SnowLayer extends Flowable{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/Sugarcane.php b/src/PocketMine/block/Sugarcane.php index 178d4324a..7faf32310 100644 --- a/src/PocketMine/block/Sugarcane.php +++ b/src/PocketMine/block/Sugarcane.php @@ -21,10 +21,10 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; use PocketMine\Math\Vector3 as Vector3; +use PocketMine; class Sugarcane extends Flowable{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/TallGrass.php b/src/PocketMine/block/TallGrass.php index ff16fadde..13327987f 100644 --- a/src/PocketMine/block/TallGrass.php +++ b/src/PocketMine/block/TallGrass.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class TallGrass extends Flowable{ public function __construct($meta = 1){ diff --git a/src/PocketMine/block/Torch.php b/src/PocketMine/block/Torch.php index c2a5c6672..95d34aaba 100644 --- a/src/PocketMine/block/Torch.php +++ b/src/PocketMine/block/Torch.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class Torch extends Flowable{ public function __construct($meta = 0){ diff --git a/src/PocketMine/block/Water.php b/src/PocketMine/block/Water.php index 50b5a5bd6..69ba9172d 100644 --- a/src/PocketMine/block/Water.php +++ b/src/PocketMine/block/Water.php @@ -22,9 +22,9 @@ namespace PocketMine\Block; use PocketMine\Item\Item; -use PocketMine; use PocketMine\Level\Level; use PocketMine\Level\Position; +use PocketMine; use PocketMine\ServerAPI; class Water extends Liquid{ diff --git a/src/PocketMine/block/Wheat.php b/src/PocketMine/block/Wheat.php index 9d4d0211a..60f918616 100644 --- a/src/PocketMine/block/Wheat.php +++ b/src/PocketMine/block/Wheat.php @@ -21,9 +21,9 @@ namespace PocketMine\Block; -use PocketMine; use PocketMine\Item\Item; use PocketMine\Level\Level; +use PocketMine; class Wheat extends Flowable{ public function __construct($meta = 0){ diff --git a/src/PocketMine/entity/Entity.php b/src/PocketMine/entity/Entity.php index f2ddc4ac7..59f6d2c24 100644 --- a/src/PocketMine/entity/Entity.php +++ b/src/PocketMine/entity/Entity.php @@ -24,6 +24,7 @@ */ namespace PocketMine\Entity; +use PocketMine; use PocketMine\Event\Entity\EntityLevelChangeEvent; use PocketMine\Event\Entity\EntityMotionEvent; use PocketMine\Event\Entity\EntityMoveEvent; @@ -34,15 +35,14 @@ use PocketMine\Level\Position; use PocketMine\Math\AxisAlignedBB; use PocketMine\Math\Vector3 as Vector3; use PocketMine\NBT\Tag\Compound; -use PocketMine\Network; use PocketMine\Network\Protocol\MoveEntityPacket_PosRot; use PocketMine\Network\Protocol\MovePlayerPacket; use PocketMine\Network\Protocol\RemoveEntityPacket; use PocketMine\Network\Protocol\SetEntityMotionPacket; +use PocketMine\Network; use PocketMine\Player; use PocketMine\PMF\LevelFormat; use PocketMine\ServerAPI; -use PocketMine; abstract class Entity extends Position{ public static $entityCount = 1; @@ -185,7 +185,7 @@ abstract class Entity extends Position{ $this->fallDistance = 0; $this->inWater = true; $this->extinguish(); - } else{ + }else{ $this->inWater = false; } @@ -195,7 +195,7 @@ abstract class Entity extends Position{ if($this->fireTicks < 0){ $this->fireTicks = 0; } - } else{ + }else{ if(($this->fireTicks % 20) === 0){ $this->attackEntity(1, "onFire"); } @@ -230,7 +230,7 @@ abstract class Entity extends Position{ $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->bodyYaw = $this->yaw; - } else{ + }else{ $pk = new MoveEntityPacket_PosRot; $pk->eid = $this->id; $pk->x = $this->x; @@ -273,7 +273,7 @@ abstract class Entity extends Position{ public function getDirection(){ $rotation = ($this->yaw - 90) % 360; - if($rotation < 0) { + if($rotation < 0){ $rotation += 360.0; } 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->fallDistance = 0; } - } elseif($distanceThisTick < 0){ + }elseif($distanceThisTick < 0){ $this->fallDistance -= $distanceThisTick; } } @@ -431,7 +431,7 @@ abstract class Entity extends Position{ foreach($this->hasSpawned as $player){ if(!isset($newChunk[$player->CID])){ $this->despawnFrom($player); - } else{ + }else{ unset($newChunk[$player->CID]); } } diff --git a/src/PocketMine/entity/Human.php b/src/PocketMine/entity/Human.php index ff746c211..48650a888 100644 --- a/src/PocketMine/entity/Human.php +++ b/src/PocketMine/entity/Human.php @@ -21,7 +21,6 @@ namespace PocketMine\Entity; -use PocketMine; use PocketMine\Event\Entity\EntityArmorChangeEvent; use PocketMine\Event\Entity\EntityInventoryChangeEvent; use PocketMine\Event\Event; @@ -30,13 +29,14 @@ use PocketMine\Item\Item; use PocketMine\NBT\Tag\Byte; use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Short; +use PocketMine\Network; use PocketMine\Network\Protocol\AddPlayerPacket; use PocketMine\Network\Protocol\ContainerSetContentPacket; use PocketMine\Network\Protocol\PlayerEquipmentPacket; use PocketMine\Network\Protocol\RemovePlayerPacket; use PocketMine\Network\Protocol\SetEntityMotionPacket; -use PocketMine\Network; use PocketMine\Player; +use PocketMine; class Human extends Creature implements ProjectileSource, InventorySource{ @@ -224,7 +224,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{ for($i = 0; $i < 4; ++$i){ 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; - } else{ + }else{ $this->armor[$i] = Item::get(Item::AIR, 0, 0); $slots[$i] = 255; } @@ -234,7 +234,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{ $pk->eid = $this->id; $pk->slots = $slots; $player->dataPacket($pk); - } elseif($this instanceof Player){ + }elseif($this instanceof Player){ $pk = new ContainerSetContentPacket; $pk->windowid = 0x78; //Armor window id $pk->slots = $this->armor; @@ -300,7 +300,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{ $inv[$s] = clone $item; $inv[$s]->setCount($add); break; - } elseif($i->equals($item)){ + }elseif($i->equals($item)){ $add = min($i->getMaxStackSize() - $i->getCount(), $item->getCount()); if($add <= 0){ continue; @@ -329,7 +329,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{ $i2->setCount($add); $this->setSlot($s, $i2); break; - } elseif($i->equals($item)){ + }elseif($i->equals($item)){ $add = min($i->getMaxStackSize() - $i->getCount(), $item->getCount()); if($add <= 0){ continue; @@ -362,7 +362,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{ if($item->getCount() < $i->getCount()){ $i->setCount($i->getCount() - $item->getCount()); $this->setSlot($s, $i); - } else{ + }else{ $this->setSlot($s, Item::get(Item::AIR, 0, 0)); } break; diff --git a/src/PocketMine/entity/InventorySource.php b/src/PocketMine/entity/InventorySource.php index bf345df62..354bfedb8 100644 --- a/src/PocketMine/entity/InventorySource.php +++ b/src/PocketMine/entity/InventorySource.php @@ -40,7 +40,7 @@ interface InventorySource{ public function canRemoveItem(Item $item, $checkDamage = true); /** - * @param Item $item + * @param Item $item * @param boolean $checkDamage * * @return boolean hasBeenRemoved diff --git a/src/PocketMine/event/Event.php b/src/PocketMine/event/Event.php index ebd053d95..dceca345b 100644 --- a/src/PocketMine/event/Event.php +++ b/src/PocketMine/event/Event.php @@ -62,7 +62,7 @@ abstract class Event{ $identifier = Utils::getCallableIdentifier($handler); if(isset(static::$handlers[$identifier])){ //Already registered return false; - } else{ + }else{ static::$handlers[$identifier] = $handler; if(!isset(static::$handlerPriority[(int) $priority])){ static::$handlerPriority[(int) $priority] = array(); @@ -79,7 +79,7 @@ abstract class Event{ if(isset(static::$handlers[$identifier])){ if(isset(static::$handlerPriority[(int) $priority][$identifier])){ unset(static::$handlerPriority[(int) $priority][$identifier]); - } else{ + }else{ for($priority = EventPriority::MONITOR; $priority <= EventPriority::LOWEST; ++$priority){ unset(static::$handlerPriority[$priority][$identifier]); if(count(static::$handlerPriority[$priority]) === 0){ @@ -90,7 +90,7 @@ abstract class Event{ unset(static::$handlers[$identifier]); return true; - } else{ + }else{ return false; } } diff --git a/src/PocketMine/event/EventHandler.php b/src/PocketMine/event/EventHandler.php index a75d250ca..a028ed414 100644 --- a/src/PocketMine/event/EventHandler.php +++ b/src/PocketMine/event/EventHandler.php @@ -41,7 +41,7 @@ abstract class EventHandler{ if($event->isForced()){ if($event instanceof CancellableEvent and $event->isCancelled()){ return Event::DENY; - } else{ + }else{ return Event::ALLOW; } } @@ -50,9 +50,9 @@ abstract class EventHandler{ if($event instanceof CancellableEvent and $event->isCancelled()){ return Event::DENY; - } elseif($event->isAllowed()){ + }elseif($event->isAllowed()){ return Event::ALLOW; - } else{ + }else{ return Event::NORMAL; } } diff --git a/src/PocketMine/event/block/BlockBreakEvent.php b/src/PocketMine/event/block/BlockBreakEvent.php index bc32b92aa..df917baec 100644 --- a/src/PocketMine/event/block/BlockBreakEvent.php +++ b/src/PocketMine/event/block/BlockBreakEvent.php @@ -21,11 +21,11 @@ namespace PocketMine\Event\Block; +use PocketMine; use PocketMine\Block\Block; use PocketMine\Event\CancellableEvent; use PocketMine\Item\Item; use PocketMine\Player; -use PocketMine; class BlockBreakEvent extends BlockEvent implements CancellableEvent{ public static $handlers; diff --git a/src/PocketMine/event/block/BlockPlaceEvent.php b/src/PocketMine/event/block/BlockPlaceEvent.php index 47c5d3a07..2866aada5 100644 --- a/src/PocketMine/event/block/BlockPlaceEvent.php +++ b/src/PocketMine/event/block/BlockPlaceEvent.php @@ -21,11 +21,11 @@ namespace PocketMine\Event\Block; +use PocketMine; use PocketMine\Block\Block; use PocketMine\Event\CancellableEvent; use PocketMine\Item\Item; use PocketMine\Player; -use PocketMine; /** * Called when a player places a block diff --git a/src/PocketMine/event/entity/EntityArmorChangeEvent.php b/src/PocketMine/event/entity/EntityArmorChangeEvent.php index 402b364b4..2b0f8143d 100644 --- a/src/PocketMine/event/entity/EntityArmorChangeEvent.php +++ b/src/PocketMine/event/entity/EntityArmorChangeEvent.php @@ -22,9 +22,9 @@ namespace PocketMine\Event\Entity; use PocketMine\Entity\Entity; +use PocketMine; use PocketMine\Event\CancellableEvent; use PocketMine\Event; -use PocketMine; use PocketMine\Item\Item; class EntityArmorChangeEvent extends EntityEvent implements CancellableEvent{ diff --git a/src/PocketMine/event/entity/EntityInventoryChangeEvent.php b/src/PocketMine/event/entity/EntityInventoryChangeEvent.php index cf5ca37b1..41061b3c8 100644 --- a/src/PocketMine/event/entity/EntityInventoryChangeEvent.php +++ b/src/PocketMine/event/entity/EntityInventoryChangeEvent.php @@ -22,9 +22,9 @@ namespace PocketMine\Event\Entity; use PocketMine\Entity\Entity; +use PocketMine; use PocketMine\Event\CancellableEvent; use PocketMine\Event; -use PocketMine; use PocketMine\Item\Item; class EntityInventoryChangeEvent extends EntityEvent implements CancellableEvent{ diff --git a/src/PocketMine/event/entity/EntityLevelChangeEvent.php b/src/PocketMine/event/entity/EntityLevelChangeEvent.php index fc604b3e7..100c6bd3d 100644 --- a/src/PocketMine/event/entity/EntityLevelChangeEvent.php +++ b/src/PocketMine/event/entity/EntityLevelChangeEvent.php @@ -22,9 +22,9 @@ namespace PocketMine\Event\Entity; use PocketMine\Entity\Entity; +use PocketMine; use PocketMine\Event\CancellableEvent; use PocketMine\Event; -use PocketMine; use PocketMine\Level\Level; class EntityLevelChangeEvent extends EntityEvent implements CancellableEvent{ diff --git a/src/PocketMine/event/entity/EntityMotionEvent.php b/src/PocketMine/event/entity/EntityMotionEvent.php index 74a08d71f..1ee81f4a8 100644 --- a/src/PocketMine/event/entity/EntityMotionEvent.php +++ b/src/PocketMine/event/entity/EntityMotionEvent.php @@ -22,9 +22,9 @@ namespace PocketMine\Event\Entity; use PocketMine\Entity\Entity; +use PocketMine; use PocketMine\Event\CancellableEvent; use PocketMine\Event; -use PocketMine; use PocketMine\Math\Vector3 as Vector3; class EntityMotionEvent extends EntityEvent implements CancellableEvent{ diff --git a/src/PocketMine/event/entity/EntityMoveEvent.php b/src/PocketMine/event/entity/EntityMoveEvent.php index 493c0a67f..3971900d5 100644 --- a/src/PocketMine/event/entity/EntityMoveEvent.php +++ b/src/PocketMine/event/entity/EntityMoveEvent.php @@ -22,9 +22,9 @@ namespace PocketMine\Event\Entity; use PocketMine\Entity\Entity; +use PocketMine; use PocketMine\Event\CancellableEvent; use PocketMine\Event; -use PocketMine; use PocketMine\Math\Vector3 as Vector3; class EntityMoveEvent extends EntityEvent implements CancellableEvent{ diff --git a/src/PocketMine/event/player/PlayerInteractEvent.php b/src/PocketMine/event/player/PlayerInteractEvent.php index f3ff53ee0..ca2034612 100644 --- a/src/PocketMine/event/player/PlayerInteractEvent.php +++ b/src/PocketMine/event/player/PlayerInteractEvent.php @@ -21,11 +21,11 @@ namespace PocketMine\Event\Player; +use PocketMine; use PocketMine\Block\Block; use PocketMine\Event\CancellableEvent; use PocketMine\Item\Item; use PocketMine\Player; -use PocketMine; /** * Called when a player interacts or touches a block (including air?) diff --git a/src/PocketMine/event/player/PlayerItemHeldEvent.php b/src/PocketMine/event/player/PlayerItemHeldEvent.php index 9362cc222..633063a91 100644 --- a/src/PocketMine/event/player/PlayerItemHeldEvent.php +++ b/src/PocketMine/event/player/PlayerItemHeldEvent.php @@ -21,10 +21,10 @@ namespace PocketMine\Event\Player; -use PocketMine\Event\CancellableEvent; -use PocketMine; use PocketMine\Event; +use PocketMine\Event\CancellableEvent; use PocketMine\Item\Item; +use PocketMine; use PocketMine\Player; class PlayerItemHeldEvent extends PlayerEvent implements CancellableEvent{ diff --git a/src/PocketMine/event/server/DataPacketReceiveEvent.php b/src/PocketMine/event/server/DataPacketReceiveEvent.php index a83f51d68..73cf5f9ca 100644 --- a/src/PocketMine/event/server/DataPacketReceiveEvent.php +++ b/src/PocketMine/event/server/DataPacketReceiveEvent.php @@ -21,10 +21,10 @@ namespace PocketMine\Event\Server; -use PocketMine\Event; use PocketMine\Event\CancellableEvent; -use PocketMine\Network\Protocol\DataPacket; use PocketMine; +use PocketMine\Event; +use PocketMine\Network\Protocol\DataPacket; use PocketMine\Player; class DataPacketReceiveEvent extends ServerEvent implements CancellableEvent{ diff --git a/src/PocketMine/event/server/DataPacketSendEvent.php b/src/PocketMine/event/server/DataPacketSendEvent.php index 98a421d4c..2b57894c3 100644 --- a/src/PocketMine/event/server/DataPacketSendEvent.php +++ b/src/PocketMine/event/server/DataPacketSendEvent.php @@ -21,10 +21,10 @@ namespace PocketMine\Event\Server; -use PocketMine\Event; use PocketMine\Event\CancellableEvent; -use PocketMine\Network\Protocol\DataPacket; use PocketMine; +use PocketMine\Event; +use PocketMine\Network\Protocol\DataPacket; use PocketMine\Player; class DataPacketSendEvent extends ServerEvent implements CancellableEvent{ diff --git a/src/PocketMine/event/server/PacketReceiveEvent.php b/src/PocketMine/event/server/PacketReceiveEvent.php index b1b6bad78..e0d34799c 100644 --- a/src/PocketMine/event/server/PacketReceiveEvent.php +++ b/src/PocketMine/event/server/PacketReceiveEvent.php @@ -22,8 +22,8 @@ namespace PocketMine\Event\Server; use PocketMine\Event\CancellableEvent; -use PocketMine\Event; use PocketMine; +use PocketMine\Event; use PocketMine\Network\Packet; class PacketReceiveEvent extends ServerEvent implements CancellableEvent{ diff --git a/src/PocketMine/event/server/PacketSendEvent.php b/src/PocketMine/event/server/PacketSendEvent.php index 2537eef5c..745309d2e 100644 --- a/src/PocketMine/event/server/PacketSendEvent.php +++ b/src/PocketMine/event/server/PacketSendEvent.php @@ -22,8 +22,8 @@ namespace PocketMine\Event\Server; use PocketMine\Event\CancellableEvent; -use PocketMine\Event; use PocketMine; +use PocketMine\Event; use PocketMine\Network\Packet; class PacketSendEvent extends ServerEvent implements CancellableEvent{ diff --git a/src/PocketMine/event/tile/TileInventoryChangeEvent.php b/src/PocketMine/event/tile/TileInventoryChangeEvent.php index f45df9dda..fcd235d45 100644 --- a/src/PocketMine/event/tile/TileInventoryChangeEvent.php +++ b/src/PocketMine/event/tile/TileInventoryChangeEvent.php @@ -21,11 +21,11 @@ namespace PocketMine\Event\Tile; -use PocketMine\Event; -use PocketMine\Item\Item; -use PocketMine; -use PocketMine\Tile\Tile; use PocketMine\Event\CancellableEvent; +use PocketMine\Event; +use PocketMine; +use PocketMine\Item\Item; +use PocketMine\Tile\Tile; class TileInventoryChangeEvent extends TileEvent implements CancellableEvent{ public static $handlers; diff --git a/src/PocketMine/item/Bucket.php b/src/PocketMine/item/Bucket.php index 7090694d3..9d3e281fd 100644 --- a/src/PocketMine/item/Bucket.php +++ b/src/PocketMine/item/Bucket.php @@ -22,12 +22,12 @@ namespace PocketMine\Item; use PocketMine\Block\Air; -use PocketMine; use PocketMine\Block\Block; use PocketMine\Block\Lava; use PocketMine\Block\Liquid; use PocketMine\Block\Water; use PocketMine\Level\Level; +use PocketMine; use PocketMine\Player; class Bucket extends Item{ diff --git a/src/PocketMine/item/FlintSteel.php b/src/PocketMine/item/FlintSteel.php index 802f9e04e..ca5049a7d 100644 --- a/src/PocketMine/item/FlintSteel.php +++ b/src/PocketMine/item/FlintSteel.php @@ -22,10 +22,10 @@ namespace PocketMine\Item; use PocketMine\Block\Block; +use PocketMine; use PocketMine\Block\Fire; use PocketMine\Block\Solid; use PocketMine\Level\Level; -use PocketMine; use PocketMine\Player; class FlintSteel extends Item{ diff --git a/src/PocketMine/item/Item.php b/src/PocketMine/item/Item.php index 127524145..2ca846576 100644 --- a/src/PocketMine/item/Item.php +++ b/src/PocketMine/item/Item.php @@ -25,13 +25,13 @@ namespace PocketMine\Item; use PocketMine\Block\Block; +use PocketMine; use PocketMine\Entity\Entity; use PocketMine\Item\Block as ItemBlock; use PocketMine\Level\Level; +use PocketMine\Player; use PocketMine\Recipes\Fuel; use PocketMine\Recipes\Smelt; -use PocketMine; -use PocketMine\Player; class Item{ //All Block IDs are here too @@ -420,7 +420,7 @@ class Item{ $item = clone self::$list[$id]; $item->setMetadata($meta); $item->setCount($count); - } else{ + }else{ $item = new Item($id, $meta, $count); } @@ -435,11 +435,11 @@ class Item{ } return $blocks; - } else{ + }else{ $b = explode(":", str_replace(" ", "_", trim($str))); if(!isset($b[1])){ $meta = 0; - } else{ + }else{ $meta = ((int) $b[1]) & 0xFFFF; } @@ -448,7 +448,7 @@ class Item{ if($item->getID() === self::AIR and strtoupper($b[0]) !== "AIR"){ $item = self::get(((int) $b[0]) & 0xFFFF, $meta); } - } else{ + }else{ $item = self::get(((int) $b[0]) & 0xFFFF, $meta); } @@ -490,7 +490,7 @@ class Item{ public function getBlock(){ if($this->block instanceof Block){ return $this->block; - } else{ + }else{ return Block::get(self::AIR); } } @@ -543,12 +543,12 @@ class Item{ if($this->isTool() or $force === true){ if(($object instanceof Entity) and !$this->isSword()){ $this->meta += 2; - } else{ + }else{ $this->meta++; } return true; - } elseif($this->isHoe()){ + }elseif($this->isHoe()){ if(($object instanceof Block) and ($object->getID() === self::GRASS or $object->getID() === self::DIRT)){ $this->meta++; } diff --git a/src/PocketMine/item/Painting.php b/src/PocketMine/item/Painting.php index b843332c3..f88887dcc 100644 --- a/src/PocketMine/item/Painting.php +++ b/src/PocketMine/item/Painting.php @@ -22,10 +22,10 @@ namespace PocketMine\Item; use PocketMine\Block\Block; -use PocketMine\Level\Level; -use PocketMine\ServerAPI; use PocketMine; +use PocketMine\Level\Level; use PocketMine\Player; +use PocketMine\ServerAPI; class Painting extends Item{ public function __construct($meta = 0, $count = 1){ diff --git a/src/PocketMine/item/SpawnEgg.php b/src/PocketMine/item/SpawnEgg.php index 86c342417..f47d8bc32 100644 --- a/src/PocketMine/item/SpawnEgg.php +++ b/src/PocketMine/item/SpawnEgg.php @@ -21,11 +21,11 @@ namespace PocketMine\Item; -use PocketMine\Entity; +use PocketMine; use PocketMine\Block\Block; +use PocketMine\Entity; use PocketMine\Level\Level; use PocketMine\Player; -use PocketMine; class SpawnEgg extends Item{ public function __construct($meta = 0, $count = 1){ diff --git a/src/PocketMine/level/Explosion.php b/src/PocketMine/level/Explosion.php index c5a22600d..7739dc09d 100644 --- a/src/PocketMine/level/Explosion.php +++ b/src/PocketMine/level/Explosion.php @@ -22,13 +22,13 @@ namespace PocketMine\Level; use PocketMine\Block\Block; +use PocketMine; use PocketMine\Block\TNT; +use PocketMine\Item\Item; use PocketMine\Math\Vector3 as Vector3; use PocketMine\Network\Protocol\ExplodePacket; use PocketMine\Player; use PocketMine\ServerAPI; -use PocketMine; -use PocketMine\Item\Item; class Explosion{ public static $specialDrops = array( @@ -118,11 +118,11 @@ class Explosion{ //TODO //$e = $server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data); //$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()])){ //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)); - } else{ + }else{ //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))); } diff --git a/src/PocketMine/level/Level.php b/src/PocketMine/level/Level.php index 503eee13a..2f55341e9 100644 --- a/src/PocketMine/level/Level.php +++ b/src/PocketMine/level/Level.php @@ -24,7 +24,6 @@ */ namespace PocketMine\Level; -use PocketMine; use PocketMine\Block\Air; use PocketMine\Block\Block; use PocketMine\Item\Item; @@ -52,6 +51,7 @@ use PocketMine\Utils\Cache; use PocketMine\Utils\Config; use PocketMine\Utils\Random; use PocketMine\Utils\Utils; +use PocketMine; /** * Class Level @@ -909,9 +909,9 @@ class Level{ /** * Sets a raw minichunk * - * @param int $X - * @param int $Z - * @param int $Y + * @param int $X + * @param int $Z + * @param int $Y * @param string $data (must be 4096 bytes) * * @return bool @@ -1011,8 +1011,8 @@ class Level{ /** * Unloads a chunk * - * @param int $X - * @param int $Z + * @param int $X + * @param int $Z * @param bool $force * * @return bool diff --git a/src/PocketMine/level/LevelImport.php b/src/PocketMine/level/LevelImport.php index 8a74c52df..8ead69d6b 100644 --- a/src/PocketMine/level/LevelImport.php +++ b/src/PocketMine/level/LevelImport.php @@ -21,10 +21,10 @@ namespace PocketMine\Level; +use PocketMine\NBT\NBT; +use PocketMine; use PocketMine\PMF\LevelFormat; use PocketMine\Utils\Config; -use PocketMine; -use PocketMine\NBT\NBT; class LevelImport{ private $path; @@ -41,7 +41,7 @@ class LevelImport{ $entities->save(); $tiles = new Config($this->path . "tiles.yml", Config::YAML, unserialize(file_get_contents($this->path . "tileEntities.dat"))); $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->read(substr(file_get_contents($this->path . "level.dat"), 8)); $level = $nbt->getData(); @@ -61,7 +61,7 @@ class LevelImport{ $entities->save(); $tiles = new Config($this->path . "tiles.yml", Config::YAML, $tiles); $tiles->save(); - } else{ + }else{ return false; } diff --git a/src/PocketMine/level/PocketChunkParser.php b/src/PocketMine/level/PocketChunkParser.php index f6459762f..b2e1d7653 100644 --- a/src/PocketMine/level/PocketChunkParser.php +++ b/src/PocketMine/level/PocketChunkParser.php @@ -63,9 +63,9 @@ class PocketChunkParser{ } @unlink($file . ".gz"); file_put_contents($file, $this->raw); - } elseif(!file_exists($file)){ + }elseif(!file_exists($file)){ return false; - } else{ + }else{ $this->raw = file_get_contents($file); } $this->file = $file; @@ -200,7 +200,7 @@ class PocketChunkParser{ $meta = ord($this->map[$X][$Z][1][$index]{$y >> 1}); if(($y & 1) === 0){ $meta = $meta & 0x0F; - } else{ + }else{ $meta = $meta >> 4; } @@ -226,7 +226,7 @@ class PocketChunkParser{ $old_meta = ord($this->map[$X][$Z][1][$index]{$y >> 1}); if(($y & 1) === 0){ $meta = ($old_meta & 0xF0) | ($meta & 0x0F); - } else{ + }else{ $meta = (($meta << 4) & 0xF0) | ($old_meta & 0x0F); } $this->map[$X][$Z][1][$index]{$y >> 1} = chr($meta); diff --git a/src/PocketMine/level/WorldGenerator.php b/src/PocketMine/level/WorldGenerator.php index c8b38c2d9..edc757826 100644 --- a/src/PocketMine/level/WorldGenerator.php +++ b/src/PocketMine/level/WorldGenerator.php @@ -21,12 +21,12 @@ namespace PocketMine\Level; +use PocketMine; use PocketMine\Level\Generator\Generator; use PocketMine\PMF\LevelFormat; use PocketMine\Utils\Config; use PocketMine\Utils\Random; use PocketMine\Utils\Utils; -use PocketMine; class WorldGenerator{ private $seed, $level, $path, $random, $generator, $height; diff --git a/src/PocketMine/level/generator/Flat.php b/src/PocketMine/level/generator/Flat.php index 4f4e53dd5..711d8570c 100644 --- a/src/PocketMine/level/generator/Flat.php +++ b/src/PocketMine/level/generator/Flat.php @@ -21,7 +21,6 @@ namespace PocketMine\Level\Generator; -use PocketMine; use PocketMine\Block\CoalOre; use PocketMine\Block\DiamondOre; use PocketMine\Block\Dirt; @@ -35,6 +34,7 @@ use PocketMine\Level\Generator\Populator\Ore; use PocketMine\Level\Level; use PocketMine\Math\Vector3 as Vector3; use PocketMine\Utils\Random; +use PocketMine; class Flat extends Generator{ private $level, $random, $structure, $chunks, $options, $floorLevel, $preset, $populators = array(); @@ -52,7 +52,7 @@ class Flat extends Generator{ $this->options = $options; if(isset($options["preset"])){ $this->parsePreset($options["preset"]); - } else{ + }else{ $this->parsePreset($this->preset); } if(isset($this->options["decoration"])){ diff --git a/src/PocketMine/level/generator/Generator.php b/src/PocketMine/level/generator/Generator.php index aec478afe..4237ccafc 100644 --- a/src/PocketMine/level/generator/Generator.php +++ b/src/PocketMine/level/generator/Generator.php @@ -24,9 +24,9 @@ */ namespace PocketMine\Level\Generator; +use PocketMine; use PocketMine\Level\Level; use PocketMine\Utils\Random; -use PocketMine; abstract class Generator{ private static $list = array(); diff --git a/src/PocketMine/level/generator/Normal.php b/src/PocketMine/level/generator/Normal.php index b89b2b145..7fc62f79d 100644 --- a/src/PocketMine/level/generator/Normal.php +++ b/src/PocketMine/level/generator/Normal.php @@ -21,6 +21,7 @@ namespace PocketMine\Level\Generator; +use PocketMine; use PocketMine\Block\CoalOre; use PocketMine\Block\DiamondOre; use PocketMine\Block\Dirt; @@ -37,7 +38,6 @@ use PocketMine\Level\Generator\Populator\Tree; use PocketMine\Level\Level; use PocketMine\Math\Vector3 as Vector3; use PocketMine\Utils\Random; -use PocketMine; class Normal extends Generator{ @@ -131,39 +131,39 @@ class Normal extends Generator{ $diff = $height - $y; if($y <= 4 and ($y === 0 or $this->random->nextFloat() < 0.75)){ $chunk .= "\x07"; //bedrock - } elseif($diff > 2){ + }elseif($diff > 2){ $chunk .= "\x01"; //stone - } elseif($diff > 0){ + }elseif($diff > 0){ if($patches[$i] > 0.7){ $chunk .= "\x01"; //stone - } elseif($patches[$i] < -0.8){ + }elseif($patches[$i] < -0.8){ $chunk .= "\x0d"; //gravel - } else{ + }else{ $chunk .= "\x03"; //dirt } - } elseif($y <= $this->waterHeight){ + }elseif($y <= $this->waterHeight){ if(($this->waterHeight - $y) <= 1 and $diff === 0){ $chunk .= "\x0c"; //sand - } elseif($diff === 0){ + }elseif($diff === 0){ if($patchesSmall[$i] > 0.3){ $chunk .= "\x0d"; //gravel - } elseif($patchesSmall[$i] < -0.45){ + }elseif($patchesSmall[$i] < -0.45){ $chunk .= "\x0c"; //sand - } else{ + }else{ $chunk .= "\x03"; //dirt } - } else{ + }else{ $chunk .= "\x09"; //still_water } - } elseif($diff === 0){ + }elseif($diff === 0){ if($patches[$i] > 0.7){ $chunk .= "\x01"; //stone - } elseif($patches[$i] < -0.8){ + }elseif($patches[$i] < -0.8){ $chunk .= "\x0d"; //gravel - } else{ + }else{ $chunk .= "\x02"; //grass } - } else{ + }else{ $chunk .= "\x00"; } } diff --git a/src/PocketMine/level/generator/noise/Simplex.php b/src/PocketMine/level/generator/noise/Simplex.php index cd8263920..11039e210 100644 --- a/src/PocketMine/level/generator/noise/Simplex.php +++ b/src/PocketMine/level/generator/noise/Simplex.php @@ -141,7 +141,7 @@ class Simplex extends Perlin{ $k2 = 1; } // Z X Y order - } else{ // x0 $this->leavesAbsoluteMaxRadius){ $leavesMaxRadius = $this->leavesAbsoluteMaxRadius; } - } else{ + }else{ ++$leavesRadius; } } diff --git a/src/PocketMine/level/generator/object/Pond.php b/src/PocketMine/level/generator/object/Pond.php index 5310c79e1..959456c60 100644 --- a/src/PocketMine/level/generator/object/Pond.php +++ b/src/PocketMine/level/generator/object/Pond.php @@ -21,11 +21,11 @@ namespace PocketMine\Level\Generator\Object; +use PocketMine; use PocketMine\Block\Block; use PocketMine\Level\Level; use PocketMine\Math\Vector3 as Vector3; use PocketMine\Utils\Random; -use PocketMine; class Pond{ private $random; diff --git a/src/PocketMine/level/generator/object/SmallTree.php b/src/PocketMine/level/generator/object/SmallTree.php index 0e30288c9..c9430da3e 100644 --- a/src/PocketMine/level/generator/object/SmallTree.php +++ b/src/PocketMine/level/generator/object/SmallTree.php @@ -21,13 +21,13 @@ namespace PocketMine\Level\Generator\Object; +use PocketMine; use PocketMine\Block\Dirt; use PocketMine\Block\Leaves; use PocketMine\Block\Wood; use PocketMine\Level\Level; use PocketMine\Math\Vector3 as Vector3; use PocketMine\Utils\Random; -use PocketMine; class SmallTree extends Tree{ public $type = 0; diff --git a/src/PocketMine/level/generator/object/SpruceTree.php b/src/PocketMine/level/generator/object/SpruceTree.php index 357b65950..08b972e9d 100644 --- a/src/PocketMine/level/generator/object/SpruceTree.php +++ b/src/PocketMine/level/generator/object/SpruceTree.php @@ -21,13 +21,13 @@ namespace PocketMine\Level\Generator\Object; +use PocketMine; use PocketMine\Block\Dirt; use PocketMine\Block\Leaves; use PocketMine\Block\Wood; use PocketMine\Level\Level; use PocketMine\Math\Vector3 as Vector3; use PocketMine\Utils\Random; -use PocketMine; class SpruceTree extends Tree{ var $type = 1; @@ -76,7 +76,7 @@ class SpruceTree extends Tree{ } if($leavesRadius > 0 and $yy === ($pos->y + $this->leavesBottomY + 1)){ --$leavesRadius; - } elseif($leavesRadius < $this->leavesMaxRadius){ + }elseif($leavesRadius < $this->leavesMaxRadius){ ++$leavesRadius; } } diff --git a/src/PocketMine/level/generator/object/Tree.php b/src/PocketMine/level/generator/object/Tree.php index e1d6a420e..785d135a9 100644 --- a/src/PocketMine/level/generator/object/Tree.php +++ b/src/PocketMine/level/generator/object/Tree.php @@ -21,11 +21,11 @@ namespace PocketMine\Level\Generator\Object; +use PocketMine; use PocketMine\Block\Sapling; use PocketMine\Level\Level; use PocketMine\Math\Vector3 as Vector3; use PocketMine\Utils\Random; -use PocketMine; class Tree{ public $overridable = array( @@ -42,7 +42,7 @@ class Tree{ case Sapling::SPRUCE: if($random->nextRange(0, 1) === 1){ $tree = new SpruceTree(); - } else{ + }else{ $tree = new PineTree(); } break; diff --git a/src/PocketMine/level/generator/populator/Mineshaft.php b/src/PocketMine/level/generator/populator/Mineshaft.php index 783a39687..a6f564434 100644 --- a/src/PocketMine/level/generator/populator/Mineshaft.php +++ b/src/PocketMine/level/generator/populator/Mineshaft.php @@ -21,9 +21,9 @@ namespace PocketMine\Level\Generator\Populator; +use PocketMine; use PocketMine\Level\Level; use PocketMine\Utils\Random; -use PocketMine; class Mineshaft extends Populator{ private static $DISTANCE = 256; diff --git a/src/PocketMine/level/generator/populator/Ore.php b/src/PocketMine/level/generator/populator/Ore.php index 2f6d19e2d..a266c426b 100644 --- a/src/PocketMine/level/generator/populator/Ore.php +++ b/src/PocketMine/level/generator/populator/Ore.php @@ -21,11 +21,11 @@ namespace PocketMine\Level\Generator\Populator; +use PocketMine; use PocketMine\Level\Generator\Object\Ore as ObjectOre; use PocketMine\Level\Level; use PocketMine\Math\Vector3 as Vector3; use PocketMine\Utils\Random; -use PocketMine; class Ore extends Populator{ private $oreTypes = array(); diff --git a/src/PocketMine/level/generator/populator/Pond.php b/src/PocketMine/level/generator/populator/Pond.php index 36c7df538..6723c38b6 100644 --- a/src/PocketMine/level/generator/populator/Pond.php +++ b/src/PocketMine/level/generator/populator/Pond.php @@ -21,11 +21,11 @@ namespace PocketMine\Level\Generator\Populator; +use PocketMine; use PocketMine\Block\Water; use PocketMine\Level\Level; use PocketMine\Math\Vector3 as Vector3; use PocketMine\Utils\Random; -use PocketMine; class Pond extends Populator{ private $waterOdd = 4; diff --git a/src/PocketMine/level/generator/populator/Populator.php b/src/PocketMine/level/generator/populator/Populator.php index 214dfb6e1..e8ca51459 100644 --- a/src/PocketMine/level/generator/populator/Populator.php +++ b/src/PocketMine/level/generator/populator/Populator.php @@ -24,9 +24,9 @@ */ namespace PocketMine\Level\Generator\Populator; +use PocketMine; use PocketMine\Level\Level; use PocketMine\Utils\Random; -use PocketMine; abstract class Populator{ public abstract function populate(Level $level, $chunkX, $chunkZ, Random $random); diff --git a/src/PocketMine/level/generator/populator/TallGrass.php b/src/PocketMine/level/generator/populator/TallGrass.php index 09d7c4216..2368139c5 100644 --- a/src/PocketMine/level/generator/populator/TallGrass.php +++ b/src/PocketMine/level/generator/populator/TallGrass.php @@ -21,12 +21,12 @@ namespace PocketMine\Level\Generator\Populator; +use PocketMine; use PocketMine\Block\Block; use PocketMine\Block\TallGrass as BlockTallGrass; use PocketMine\Level\Level; use PocketMine\Math\Vector3 as Vector3; use PocketMine\Utils\Random; -use PocketMine; class TallGrass extends Populator{ /** @@ -73,7 +73,7 @@ class TallGrass extends Populator{ if(--$y <= 0){ return -1; } - } else{ + }else{ break; } } diff --git a/src/PocketMine/level/generator/populator/Tree.php b/src/PocketMine/level/generator/populator/Tree.php index 2ad090577..a3ea6fb62 100644 --- a/src/PocketMine/level/generator/populator/Tree.php +++ b/src/PocketMine/level/generator/populator/Tree.php @@ -21,13 +21,13 @@ namespace PocketMine\Level\Generator\Populator; +use PocketMine; use PocketMine\Block\Block; use PocketMine\Block\Sapling; use PocketMine\Level\Generator\Object\Tree as ObjectTree; use PocketMine\Level\Level; use PocketMine\Math\Vector3 as Vector3; use PocketMine\Utils\Random; -use PocketMine; class Tree extends Populator{ private $level; @@ -54,7 +54,7 @@ class Tree extends Populator{ } if($random->nextFloat() > 0.75){ $meta = Sapling::BIRCH; - } else{ + }else{ $meta = Sapling::OAK; } ObjectTree::growTree($this->level, new Vector3($x, $y, $z), $random, $meta); @@ -68,7 +68,7 @@ class Tree extends Populator{ if(--$y <= 0){ return -1; } - } else{ + }else{ break; } } diff --git a/src/PocketMine/math/AxisAlignedBB.php b/src/PocketMine/math/AxisAlignedBB.php index 39e2a6e6f..d1b2547a2 100644 --- a/src/PocketMine/math/AxisAlignedBB.php +++ b/src/PocketMine/math/AxisAlignedBB.php @@ -55,19 +55,19 @@ class AxisAlignedBB{ $vec = clone $this; if($x < 0){ $vec->minX += $x; - } elseif($x > 0){ + }elseif($x > 0){ $vec->maxX += $x; } if($y < 0){ $vec->minY += $y; - } elseif($y > 0){ + }elseif($y > 0){ $vec->maxY += $y; } if($z < 0){ $vec->minZ += $z; - } elseif($z > 0){ + }elseif($z > 0){ $vec->maxZ += $z; } diff --git a/src/PocketMine/math/Vector2.php b/src/PocketMine/math/Vector2.php index a2c6eb9dd..18a024f71 100644 --- a/src/PocketMine/math/Vector2.php +++ b/src/PocketMine/math/Vector2.php @@ -50,7 +50,7 @@ class Vector2{ public function add($x = 0, $y = 0){ if(($x instanceof Vector2) === true){ return $this->add($x->x, $x->y); - } else{ + }else{ $this->x += $x; $this->y += $y; @@ -61,7 +61,7 @@ class Vector2{ public function subtract($x = 0, $y = 0){ if(($x instanceof Vector2) === true){ return $this->add(-$x->x, -$x->y); - } else{ + }else{ return $this->add(-$x, -$y); } } @@ -93,7 +93,7 @@ class Vector2{ public function distance($x = 0, $y = 0){ if(($x instanceof Vector2) === true){ return sqrt($this->distanceSquared($x->x, $x->y)); - } else{ + }else{ return sqrt($this->distanceSquared($x, $y)); } } @@ -101,7 +101,7 @@ class Vector2{ public function distanceSquared($x = 0, $y = 0){ if(($x instanceof Vector2) === true){ return $this->distanceSquared($x->x, $x->y); - } else{ + }else{ return pow($this->x - $x, 2) + pow($this->y - $y, 2); } } diff --git a/src/PocketMine/math/Vector3.php b/src/PocketMine/math/Vector3.php index 81c2543a4..4e95c1427 100644 --- a/src/PocketMine/math/Vector3.php +++ b/src/PocketMine/math/Vector3.php @@ -81,7 +81,7 @@ class Vector3{ public function add($x = 0, $y = 0, $z = 0){ if(($x instanceof Vector3) === true){ return $this->add($x->x, $x->y, $x->z); - } else{ + }else{ 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){ if(($x instanceof Vector3) === true){ return $this->add(-$x->x, -$x->y, -$x->z); - } else{ + }else{ return $this->add(-$x, -$y, -$z); } } @@ -148,7 +148,7 @@ class Vector3{ public function maxPlainDistance($x = 0, $z = 0){ if(($x instanceof Vector3) === true){ return $this->maxPlainDistance($x->x, $x->z); - } else{ + }else{ return max(abs($this->x - $x), abs($this->z - $z)); } } diff --git a/src/PocketMine/nbt/NBT.php b/src/PocketMine/nbt/NBT.php index e22caad24..e51989a7b 100644 --- a/src/PocketMine/nbt/NBT.php +++ b/src/PocketMine/nbt/NBT.php @@ -24,7 +24,6 @@ */ namespace PocketMine\NBT; -use PocketMine; use PocketMine\NBT\Tag\Byte; use PocketMine\NBT\Tag\Byte_Array; use PocketMine\NBT\Tag\Compound; @@ -40,6 +39,7 @@ use PocketMine\NBT\Tag\Short; use PocketMine\NBT\Tag\String; use PocketMine\NBT\Tag\Tag; use PocketMine\Utils\Utils; +use PocketMine; /** * Named Binary Tag encoder/decoder @@ -73,7 +73,7 @@ class NBT{ $this->offset = strlen($this->buffer) - 1; return ""; - } elseif($len === true){ + }elseif($len === true){ return substr($this->buffer, $this->offset); } @@ -115,7 +115,7 @@ class NBT{ $this->writeTag($this->data); return $this->buffer; - } else{ + }else{ return false; } } @@ -124,6 +124,7 @@ class NBT{ if(($write = $this->write()) !== false){ return \gzencode($write, 9); } + return false; } diff --git a/src/PocketMine/nbt/tag/Compound.php b/src/PocketMine/nbt/tag/Compound.php index adf25edf8..9bdae2602 100644 --- a/src/PocketMine/nbt/tag/Compound.php +++ b/src/PocketMine/nbt/tag/Compound.php @@ -45,6 +45,7 @@ class Compound extends NamedTag implements \ArrayAccess{ return $this->{$offset}->getValue(); } } + return null; } @@ -71,7 +72,7 @@ class Compound extends NamedTag implements \ArrayAccess{ if($tag instanceof NamedTag and $tag->getName() !== ""){ $this->{$tag->getName()} = $tag; } - } while(!($tag instanceof End) and !$nbt->feof()); + }while(!($tag instanceof End) and !$nbt->feof()); } public function write(NBT $nbt){ diff --git a/src/PocketMine/nbt/tag/Enum.php b/src/PocketMine/nbt/tag/Enum.php index 97a19fe14..fac0b467f 100644 --- a/src/PocketMine/nbt/tag/Enum.php +++ b/src/PocketMine/nbt/tag/Enum.php @@ -48,6 +48,7 @@ class Enum extends NamedTag implements \ArrayAccess{ return $this->{$offset}->getValue(); } } + return null; } diff --git a/src/PocketMine/nbt/tag/NamedTag.php b/src/PocketMine/nbt/tag/NamedTag.php index 46209e403..591803fdd 100644 --- a/src/PocketMine/nbt/tag/NamedTag.php +++ b/src/PocketMine/nbt/tag/NamedTag.php @@ -28,8 +28,8 @@ abstract class NamedTag extends Tag{ protected $name; /** - * @param string $name - * @param bool|float|double|int|byte|short|array|Compound|Enum|string $value + * @param string $name + * @param bool|float|double|int|byte|short|array|Compound|Enum|string $value */ public function __construct($name = "", $value = false){ $this->name = $name; diff --git a/src/PocketMine/network/Handler.php b/src/PocketMine/network/Handler.php index 2054973e6..fb94d4035 100644 --- a/src/PocketMine/network/Handler.php +++ b/src/PocketMine/network/Handler.php @@ -24,6 +24,7 @@ */ namespace PocketMine\Network; +use PocketMine; use PocketMine\Event\Event; use PocketMine\Event\EventHandler; use PocketMine\Event\Server\PacketReceiveEvent; @@ -33,7 +34,6 @@ use PocketMine\Network\Query\QueryPacket; use PocketMine\Network\RakNet\Info; use PocketMine\Network\RakNet\Packet; use PocketMine\ServerAPI; -use PocketMine; class Handler{ public $bandwidth; @@ -77,7 +77,7 @@ class Handler{ } 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->ip = $source; $packet->port = $port; @@ -86,7 +86,7 @@ class Handler{ return false; } ServerAPI::request()->api->query->handle($packet); - } else{ + }else{ $packet = new Packet($pid); $packet->ip = $source; $packet->port = $port; @@ -102,7 +102,7 @@ class Handler{ public function writePacket(Packet $packet){ if(EventHandler::callEvent(new PacketSendEvent($packet)) === Event::DENY){ return 0; - } elseif($packet instanceof Packet){ + }elseif($packet instanceof Packet){ $packet->encode(); } $write = $this->socket->write($packet->buffer, $packet->ip, $packet->port); diff --git a/src/PocketMine/network/UDPSocket.php b/src/PocketMine/network/UDPSocket.php index 58c7d0c85..9cbbc7e00 100644 --- a/src/PocketMine/network/UDPSocket.php +++ b/src/PocketMine/network/UDPSocket.php @@ -34,14 +34,14 @@ class UDPSocket{ if($listen !== true){ $this->connected = true; $this->unblock(); - } else{ + }else{ 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_SNDBUF, 1024 * 1024 * 2); //2MB @socket_set_option($this->sock, SOL_SOCKET, SO_RCVBUF, 1024 * 1024); //1MB $this->unblock(); $this->connected = true; - } else{ + }else{ $this->connected = false; } } diff --git a/src/PocketMine/network/protocol/DataPacket.php b/src/PocketMine/network/protocol/DataPacket.php index 6278e318e..415902e3d 100644 --- a/src/PocketMine/network/protocol/DataPacket.php +++ b/src/PocketMine/network/protocol/DataPacket.php @@ -21,9 +21,9 @@ namespace PocketMine\Network\Protocol; +use PocketMine; use PocketMine\Item\Item; use PocketMine\Utils\Utils; -use PocketMine; abstract class DataPacket{ private $offset = 0; @@ -63,7 +63,7 @@ abstract class DataPacket{ $this->offset = strlen($this->buffer) - 1; return ""; - } elseif($len === true){ + }elseif($len === true){ return substr($this->buffer, $this->offset); } diff --git a/src/PocketMine/network/query/QueryHandler.php b/src/PocketMine/network/query/QueryHandler.php index faa3b4edd..2409f0309 100644 --- a/src/PocketMine/network/query/QueryHandler.php +++ b/src/PocketMine/network/query/QueryHandler.php @@ -25,11 +25,11 @@ */ namespace PocketMine\Network\Query; +use PocketMine; use PocketMine\Level\Level; use PocketMine\Player; use PocketMine\ServerAPI; use PocketMine\Utils\Utils; -use PocketMine; class QueryHandler{ private $socket, $server, $lastToken, $token, $longData, $timeout; @@ -134,7 +134,7 @@ class QueryHandler{ $this->regenerateInfo(); } $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->encode(); diff --git a/src/PocketMine/network/query/QueryPacket.php b/src/PocketMine/network/query/QueryPacket.php index 0d65f8fc3..9f96a62d7 100644 --- a/src/PocketMine/network/query/QueryPacket.php +++ b/src/PocketMine/network/query/QueryPacket.php @@ -21,9 +21,9 @@ namespace PocketMine\Network\Query; +use PocketMine; use PocketMine\Network\Packet; use PocketMine\Utils\Utils; -use PocketMine; class QueryPacket extends Packet{ const HANDSHAKE = 9; diff --git a/src/PocketMine/network/raknet/Packet.php b/src/PocketMine/network/raknet/Packet.php index 8b585e3ee..b9a115cd8 100644 --- a/src/PocketMine/network/raknet/Packet.php +++ b/src/PocketMine/network/raknet/Packet.php @@ -21,10 +21,10 @@ namespace PocketMine\Network\RakNet; +use PocketMine; use PocketMine\Network; use PocketMine\Network\Protocol\Info as ProtocolInfo; use PocketMine\Utils\Utils; -use PocketMine; class Packet extends Network\Packet{ private $packetID; @@ -44,7 +44,7 @@ class Packet extends Network\Packet{ $this->offset = strlen($this->buffer) - 1; return ""; - } elseif($len === true){ + }elseif($len === true){ return substr($this->buffer, $this->offset); } @@ -136,7 +136,7 @@ class Packet extends Network\Packet{ for($c = $start; $c <= $end; ++$c){ $this->packets[] = $c; } - } else{ + }else{ $this->packets[] = $this->getLTriad(); } } @@ -158,7 +158,7 @@ class Packet extends Network\Packet{ or $reliability === 7 ){ $messageIndex = $this->getLTriad(); - } else{ + }else{ $messageIndex = false; } @@ -169,7 +169,7 @@ class Packet extends Network\Packet{ ){ $orderIndex = $this->getLTriad(); $orderChannel = $this->getByte(); - } else{ + }else{ $orderIndex = false; $orderChannel = false; } @@ -178,7 +178,7 @@ class Packet extends Network\Packet{ $splitCount = $this->getInt(); $splitID = $this->getShort(); $splitIndex = $this->getInt(); - } else{ + }else{ $splitCount = false; $splitID = false; $splitIndex = false; @@ -189,7 +189,7 @@ class Packet extends Network\Packet{ or ($hasSplit === true and $splitIndex >= $splitCount) ){ return false; - } else{ + }else{ $pid = $this->getByte(); $buffer = $this->get($length - 1); if(strlen($buffer) < ($length - 1)){ @@ -445,7 +445,7 @@ class Packet extends Network\Packet{ $curr = $end = $n; $type = false; $pointer = $i + 1; - } else{ + }else{ break; } } @@ -454,7 +454,7 @@ class Packet extends Network\Packet{ $payload .= "\x00"; $payload .= strrev(Utils::writeTriad($start)); $payload .= strrev(Utils::writeTriad($end)); - } else{ + }else{ $payload .= Utils::writeBool(true); $payload .= strrev(Utils::writeTriad($start)); } diff --git a/src/PocketMine/network/rcon/RCON.php b/src/PocketMine/network/rcon/RCON.php index a251cc206..63f344f78 100644 --- a/src/PocketMine/network/rcon/RCON.php +++ b/src/PocketMine/network/rcon/RCON.php @@ -73,11 +73,11 @@ class RCON{ for($n = 0; $n < $this->threads; ++$n){ if($this->workers[$n]->isTerminated() === true){ $this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread); - } elseif($this->workers[$n]->isWaiting()){ + }elseif($this->workers[$n]->isWaiting()){ if($this->workers[$n]->response !== ""){ console($this->workers[$n]->response); $this->workers[$n]->notify(); - } else{ + }else{ $this->workers[$n]->response = ServerAPI::request()->api->console->run($this->workers[$n]->cmd, "rcon"); $this->workers[$n]->notify(); } diff --git a/src/PocketMine/network/rcon/RCONInstance.php b/src/PocketMine/network/rcon/RCONInstance.php index c68e5d46c..da494a1c8 100644 --- a/src/PocketMine/network/rcon/RCONInstance.php +++ b/src/PocketMine/network/rcon/RCONInstance.php @@ -60,9 +60,9 @@ class RCONInstance extends \Thread{ $d = socket_read($client, 4); if($this->stop === true){ return false; - } elseif($d === false){ + }elseif($d === false){ return null; - } elseif($d === "" or strlen($d) < 4){ + }elseif($d === "" or strlen($d) < 4){ return false; } @socket_set_block($client); @@ -118,7 +118,7 @@ class RCONInstance extends \Thread{ if($p === false){ $this->{"status" . $n} = -1; continue; - } elseif($p === null){ + }elseif($p === null){ continue; } @@ -135,7 +135,7 @@ class RCONInstance extends \Thread{ $this->response = ""; $this->writePacket($client, $requestID, 2, ""); $this->{"status" . $n} = 1; - } else{ + }else{ $this->{"status" . $n} = -1; $this->writePacket($client, -1, 2, ""); continue; @@ -156,7 +156,7 @@ class RCONInstance extends \Thread{ break; } usleep(1); - } else{ + }else{ @socket_set_option($client, SOL_SOCKET, SO_LINGER, array("l_onoff" => 1, "l_linger" => 1)); @socket_shutdown($client, 2); @socket_set_block($client); diff --git a/src/PocketMine/network/upnp/UPnP.php b/src/PocketMine/network/upnp/UPnP.php index 0af94d015..73fa2684d 100644 --- a/src/PocketMine/network/upnp/UPnP.php +++ b/src/PocketMine/network/upnp/UPnP.php @@ -43,7 +43,7 @@ abstract class UPnP{ return false; } $com->StaticPortMappingCollection->Add($port, "UDP", $port, $myLocalIP, true, "PocketMine-MP"); - } catch(\Exception $e){ + }catch(\Exception $e){ return false; } @@ -64,7 +64,7 @@ abstract class UPnP{ return false; } $com->StaticPortMappingCollection->Remove($port, "UDP"); - } catch(\Exception $e){ + }catch(\Exception $e){ return false; } diff --git a/src/PocketMine/permission/Permission.php b/src/PocketMine/permission/Permission.php index a2d8b7777..e9c4b1a76 100644 --- a/src/PocketMine/permission/Permission.php +++ b/src/PocketMine/permission/Permission.php @@ -42,10 +42,10 @@ class Permission{ /** * Creates a new Permission object to be attached to Permissible objects * - * @param string $name - * @param string $description - * @param string $defaultValue - * @param array $children + * @param string $name + * @param string $description + * @param string $defaultValue + * @param array $children */ public function __construct($name, $description = null, $defaultValue = null, array $children = array()){ $this->name = $name; diff --git a/src/PocketMine/plugin/PluginBase.php b/src/PocketMine/plugin/PluginBase.php index e0dd3281d..f794029ea 100644 --- a/src/PocketMine/plugin/PluginBase.php +++ b/src/PocketMine/plugin/PluginBase.php @@ -118,6 +118,7 @@ abstract class PluginBase{ if(file_exists($this->dataFolder . "resources/" . $filename)){ return file_get_contents($this->dataFolder . "resources/" . $filename); } + return false; } } @@ -154,6 +155,7 @@ abstract class PluginBase{ foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->dataFolder . "resources/")) as $resource){ $resources[] = $resource; } + return $resources; } } @@ -162,14 +164,17 @@ abstract class PluginBase{ if(!isset($this->config)){ $this->reloadConfig(); } + return $this->config; } public function saveConfig(){ if($this->getConfig()->save() === false){ - console("[SEVERE] Could not save config to ". $this->configFile); + console("[SEVERE] Could not save config to " . $this->configFile); + return false; } + return true; } @@ -190,8 +195,7 @@ abstract class PluginBase{ return $this->dataFolder; } - public final function getName() - { + public final function getName(){ return $this->description->getName(); } diff --git a/src/PocketMine/plugin/PluginDescription.php b/src/PocketMine/plugin/PluginDescription.php index 74db89440..98f93a1d8 100644 --- a/src/PocketMine/plugin/PluginDescription.php +++ b/src/PocketMine/plugin/PluginDescription.php @@ -54,6 +54,7 @@ class PluginDescription{ $this->name = preg_replace("[^A-Za-z0-9 _.-]", "", $plugin["name"]); if($this->name === ""){ trigger_error("Invalid PluginDescription name", E_USER_WARNING); + return; } $this->name = str_replace(" ", "_", $this->name); @@ -62,6 +63,7 @@ class PluginDescription{ $this->api = !is_array($plugin["api"]) ? array($plugin["api"]) : $plugin["api"]; if(stripos($this->main, "PocketMine\\") === 0){ trigger_error("Invalid PluginDescription main, cannot start within the PocketMine namespace", E_USER_ERROR); + return; } @@ -87,6 +89,7 @@ class PluginDescription{ $order = strtoupper($plugin["load"]); if(!defined("PocketMine\\Plugin\\PluginLoadOrder::" . $order)){ trigger_error("Invalid PluginDescription load", E_USER_ERROR); + return; }else{ $this->order = constant("PocketMine\\Plugin\\PluginLoadOrder::" . $order); @@ -128,80 +131,70 @@ class PluginDescription{ /** * @return array */ - public function getDepend() - { + public function getDepend(){ return $this->depend; } /** * @return string */ - public function getDescription() - { + public function getDescription(){ return $this->description; } /** * @return array */ - public function getLoadBefore() - { + public function getLoadBefore(){ return $this->loadBefore; } /** * @return string */ - public function getMain() - { + public function getMain(){ return $this->main; } /** * @return string */ - public function getName() - { + public function getName(){ return $this->name; } /** * @return int */ - public function getOrder() - { + public function getOrder(){ return $this->order; } /** * @return Permission[] */ - public function getPermisions() - { + public function getPermisions(){ return $this->permissions; } /** * @return array */ - public function getSoftDepend() - { + public function getSoftDepend(){ return $this->softDepend; } /** * @return string */ - public function getVersion() - { + public function getVersion(){ return $this->version; } /** * @return string */ - public function getWebsite() - { + public function getWebsite(){ return $this->website; } } \ No newline at end of file diff --git a/src/PocketMine/plugin/PluginManager.php b/src/PocketMine/plugin/PluginManager.php index 6dcd7d435..211337410 100644 --- a/src/PocketMine/plugin/PluginManager.php +++ b/src/PocketMine/plugin/PluginManager.php @@ -21,9 +21,9 @@ namespace PocketMine\Plugin; -use PocketMine; -use PocketMine\Permission\Permission; use PocketMine\Permission\Permissible; +use PocketMine\Permission\Permission; +use PocketMine; /** * Manages all the plugins, Permissions and Permissibles @@ -51,7 +51,7 @@ abstract class PluginManager{ protected static $defaultPermsOp = array(); /** - * @var Permissible[] + * @var Permissible[] */ protected static $permSubs = array(); @@ -79,6 +79,7 @@ abstract class PluginManager{ if(isset(static::$plugins[$name])){ return static::$plugins[$name]; } + return null; } @@ -99,6 +100,7 @@ abstract class PluginManager{ } static::$fileAssociations[spl_object_hash($loader)] = array($loader, $loader->getPluginFilters()); + return true; } @@ -145,13 +147,13 @@ abstract class PluginManager{ if($description instanceof PluginDescription){ $name = $description->getName(); if(stripos($name, "pocketmine") !== false or stripos($name, "minecraft") !== false or stripos($name, "mojang") !== false){ - console("[ERROR] Could not load plugin '".$name."': restricted name"); + console("[ERROR] Could not load plugin '" . $name . "': restricted name"); continue; }elseif(strpos($name, " ") !== false){ - console("[WARNING] Plugin '".$name."' uses spaces in its name, this is discouraged"); + console("[WARNING] Plugin '" . $name . "' uses spaces in its name, this is discouraged"); } if(isset($plugins[$name])){ - console("[ERROR] Could not load duplicate plugin '".$name."': plugin exists"); + console("[ERROR] Could not load duplicate plugin '" . $name . "': plugin exists"); continue; } @@ -178,7 +180,7 @@ abstract class PluginManager{ } if($compatible === false){ - console("[ERROR] Could not load plugin '".$name."': API version not compatible"); + console("[ERROR] Could not load plugin '" . $name . "': API version not compatible"); continue; } @@ -209,7 +211,7 @@ abstract class PluginManager{ if(isset($loadedPlugins[$dependency])){ unset($dependencies[$name][$key]); }elseif(!isset($plugins[$dependency])){ - console("[SEVERE] Could not load plugin '".$name."': Unknown dependency"); + console("[SEVERE] Could not load plugin '" . $name . "': Unknown dependency"); break; } } @@ -237,7 +239,7 @@ abstract class PluginManager{ if($plugin = static::loadPlugin($file) and $plugin instanceof Plugin){ $loadedPlugins[$name] = $plugin; }else{ - console("[SEVERE] Could not load plugin '".$name."'"); + console("[SEVERE] Could not load plugin '" . $name . "'"); } } } @@ -251,7 +253,7 @@ abstract class PluginManager{ if($plugin = static::loadPlugin($file) and $plugin instanceof Plugin){ $loadedPlugins[$name] = $plugin; }else{ - console("[SEVERE] Could not load plugin '".$name."'"); + console("[SEVERE] Could not load plugin '" . $name . "'"); } } } @@ -259,7 +261,7 @@ abstract class PluginManager{ //No plugins loaded :( if($missingDependency === true){ foreach($plugins as $name => $file){ - console("[SEVERE] Could not load plugin '".$name."': circular dependency detected"); + console("[SEVERE] Could not load plugin '" . $name . "': circular dependency detected"); } $plugins = array(); } @@ -281,6 +283,7 @@ abstract class PluginManager{ if(isset(static::$permissions[$name])){ return static::$permissions[$name]; } + return null; } @@ -293,8 +296,10 @@ abstract class PluginManager{ if(!isset(static::$permissions[$permission->getName()])){ static::$permissions[$permission->getName()] = $permission; static::calculatePermissionDefault($permission); + return true; } + return false; } @@ -388,6 +393,7 @@ abstract class PluginManager{ if(isset(static::$permSubs[$permission])){ return static::$permSubs[$permission]; } + return array(); } diff --git a/src/PocketMine/pmf/LevelFormat.php b/src/PocketMine/pmf/LevelFormat.php index c35b76dab..c94107a61 100644 --- a/src/PocketMine/pmf/LevelFormat.php +++ b/src/PocketMine/pmf/LevelFormat.php @@ -21,12 +21,12 @@ namespace PocketMine\PMF; +use PocketMine; use PocketMine\Level\Level; use PocketMine\NBT\NBT; use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Enum; use PocketMine\Utils\Utils; -use PocketMine; class LevelFormat extends PMF{ const VERSION = 2; @@ -77,15 +77,15 @@ class LevelFormat extends PMF{ $this->levelData = $blank; $this->createBlank(); $this->isLoaded = true; - } else{ + }else{ if($this->load($file) !== false){ $this->parseInfo(); if($this->parseLevel() === false){ $this->isLoaded = false; - } else{ + }else{ $this->isLoaded = true; } - } else{ + }else{ $this->isLoaded = false; } } @@ -135,7 +135,7 @@ class LevelFormat extends PMF{ if($this->levelData["version"] === 0){ $this->read(1); $this->levelData["height"] = ord($this->read(1)); - } else{ + }else{ $this->levelData["height"] = ord($this->read(1)); if($this->levelData["height"] !== 8){ return false; @@ -313,7 +313,7 @@ class LevelFormat extends PMF{ $this->fillMiniChunk($X, $Z, $Y); } $offset += 8192; - } else{ + }else{ $this->chunks[$index][$Y] = false; } } @@ -329,7 +329,7 @@ class LevelFormat extends PMF{ $Z = (int) $Z; if(!$this->isChunkLoaded($X, $Z)){ return false; - } elseif($save !== false){ + }elseif($save !== false){ $this->saveChunk($X, $Z); } $index = self::getIndex($X, $Z); @@ -438,7 +438,7 @@ class LevelFormat extends PMF{ public function setMiniChunk($X, $Z, $Y, $data){ if($this->isGenerating > 0){ $this->initCleanChunk($X, $Z); - } elseif($this->isChunkLoaded($X, $Z) === false){ + }elseif($this->isChunkLoaded($X, $Z) === false){ $this->loadChunk($X, $Z); } if(strlen($data) !== 8192){ @@ -518,7 +518,7 @@ class LevelFormat extends PMF{ $this->chunks[$index][$Y]{(int) ($aY + ($aX << 5) + ($aZ << 9))} = chr($block); if(!isset($this->chunkChange[$index][$Y])){ $this->chunkChange[$index][$Y] = 1; - } else{ + }else{ ++$this->chunkChange[$index][$Y]; } $this->chunkChange[$index][-1] = true; @@ -543,7 +543,7 @@ class LevelFormat extends PMF{ $m = ord($this->chunks[$index][$Y]{(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))}); if(($y & 1) === 0){ $m = $m & 0x0F; - } else{ + }else{ $m = $m >> 4; } @@ -569,7 +569,7 @@ class LevelFormat extends PMF{ $old_m = ord($this->chunks[$index][$Y]{$mindex}); if(($y & 1) === 0){ $m = ($old_m & 0xF0) | $damage; - } else{ + }else{ $m = ($damage << 4) | ($old_m & 0x0F); } @@ -577,7 +577,7 @@ class LevelFormat extends PMF{ $this->chunks[$index][$Y]{$mindex} = chr($m); if(!isset($this->chunkChange[$index][$Y])){ $this->chunkChange[$index][$Y] = 1; - } else{ + }else{ ++$this->chunkChange[$index][$Y]; } $this->chunkChange[$index][-1] = true; @@ -598,7 +598,7 @@ class LevelFormat extends PMF{ $index = self::getIndex($X, $Z); if(!isset($this->chunks[$index]) and $this->loadChunk($X, $Z) === false){ return array(0, 0); - } elseif($this->chunks[$index][$Y] === false){ + }elseif($this->chunks[$index][$Y] === false){ return array(0, 0); } $aX = $x - ($X << 4); @@ -608,7 +608,7 @@ class LevelFormat extends PMF{ $m = ord($this->chunks[$index][$Y]{(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))}); if(($y & 1) === 0){ $m = $m & 0x0F; - } else{ + }else{ $m = $m >> 4; } @@ -627,7 +627,7 @@ class LevelFormat extends PMF{ $index = self::getIndex($X, $Z); if(!isset($this->chunks[$index]) and $this->loadChunk($X, $Z) === false){ return false; - } elseif($this->chunks[$index][$Y] === false){ + }elseif($this->chunks[$index][$Y] === false){ $this->fillMiniChunk($X, $Z, $Y); } $aX = $x - ($X << 4); @@ -639,7 +639,7 @@ class LevelFormat extends PMF{ $old_m = ord($this->chunks[$index][$Y]{$mindex}); if(($y & 1) === 0){ $m = ($old_m & 0xF0) | $meta; - } else{ + }else{ $m = ($meta << 4) | ($old_m & 0x0F); } @@ -648,7 +648,7 @@ class LevelFormat extends PMF{ $this->chunks[$index][$Y]{$mindex} = chr($m); if(!isset($this->chunkChange[$index][$Y])){ $this->chunkChange[$index][$Y] = 1; - } else{ + }else{ ++$this->chunkChange[$index][$Y]; } $this->chunkChange[$index][-1] = true; @@ -697,7 +697,7 @@ class LevelFormat extends PMF{ for($Y = 0; $Y < 8; ++$Y){ if($this->chunks[$index][$Y] !== false and ((isset($this->chunkChange[$index][$Y]) and $this->chunkChange[$index][$Y] === 0) or !$this->isMiniChunkEmpty($X, $Z, $Y))){ $bitmap |= 1 << $Y; - } else{ + }else{ $this->chunks[$index][$Y] = false; } $this->chunkChange[$index][$Y] = 0; diff --git a/src/PocketMine/pmf/PMF.php b/src/PocketMine/pmf/PMF.php index d4e37517f..fed6488d3 100644 --- a/src/PocketMine/pmf/PMF.php +++ b/src/PocketMine/pmf/PMF.php @@ -38,7 +38,7 @@ class PMF{ public function __construct($file, $new = false, $type = 0, $version = PMF::VERSION){ if($new === true){ $this->create($file, $type, $version); - } else{ + }else{ if($this->load($file) !== true){ $this->parseInfo(); } diff --git a/src/PocketMine/pmf/Plugin.php b/src/PocketMine/pmf/Plugin.php index 4ea778372..466c56944 100644 --- a/src/PocketMine/pmf/Plugin.php +++ b/src/PocketMine/pmf/Plugin.php @@ -53,7 +53,7 @@ class Plugin extends PMF{ $this->pluginData["author"] = $this->read(Utils::readShort($this->read(2), false)); if($this->pluginData["fversion"] >= 0x01){ $this->pluginData["apiversion"] = $this->read(Utils::readShort($this->read(2), false)); - } else{ + }else{ $this->pluginData["apiversion"] = Utils::readShort($this->read(2), false); } $this->pluginData["class"] = $this->read(Utils::readShort($this->read(2), false)); @@ -70,7 +70,7 @@ class Plugin extends PMF{ } } - } else{ + }else{ $this->pluginData["extra"] = gzinflate($this->read(Utils::readShort($this->read(2), false))); } $this->pluginData["code"] = ""; diff --git a/src/PocketMine/recipes/Crafting.php b/src/PocketMine/recipes/Crafting.php index 1ea2690d8..fbd83aa26 100644 --- a/src/PocketMine/recipes/Crafting.php +++ b/src/PocketMine/recipes/Crafting.php @@ -24,9 +24,9 @@ */ namespace PocketMine\Recipes; +use PocketMine; use PocketMine\Item\Item; use PocketMine\ServerAPI; -use PocketMine; abstract class Crafting{ private static $small = array( //Probably means craftable on crafting bench and in inventory. Name it better! @@ -315,7 +315,7 @@ abstract class Crafting{ $continue = $recipe; break; } - } else{ + }else{ return true; } diff --git a/src/PocketMine/tile/Chest.php b/src/PocketMine/tile/Chest.php index f0b6ca920..316323a64 100644 --- a/src/PocketMine/tile/Chest.php +++ b/src/PocketMine/tile/Chest.php @@ -23,13 +23,13 @@ namespace PocketMine\Tile; use PocketMine\Level\Level; use PocketMine\Math\Vector3 as Vector3; +use PocketMine; +use PocketMine\NBT\NBT; use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Int; use PocketMine\NBT\Tag\String; use PocketMine\Network\Protocol\EntityDataPacket; -use PocketMine; use PocketMine\Player; -use PocketMine\NBT\NBT; class Chest extends Spawnable{ use Container; @@ -109,7 +109,7 @@ class Chest extends Spawnable{ new Int("pairx", (int) $this->namedtag->pairx), new Int("pairz", (int) $this->namedtag->pairz) ))); - } else{ + }else{ $nbt->setData(new Compound("", array( new String("id", Tile::CHEST), new Int("x", (int) $this->x), diff --git a/src/PocketMine/tile/Container.php b/src/PocketMine/tile/Container.php index 153897fdc..57e37fb1b 100644 --- a/src/PocketMine/tile/Container.php +++ b/src/PocketMine/tile/Container.php @@ -21,6 +21,7 @@ namespace PocketMine\Tile; +use PocketMine; use PocketMine\Event\Event; use PocketMine\Event\EventHandler; use PocketMine\Event\Tile\TileInventoryChangeEvent; @@ -28,9 +29,8 @@ use PocketMine\Item\Item; use PocketMine\NBT\Tag\Byte; use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Short; -use PocketMine\Player; use PocketMine\Network; -use PocketMine; +use PocketMine\Player; trait Container{ public function openInventory(Player $player){ @@ -43,13 +43,13 @@ trait Container{ $pair, $this ); - } else{ + }else{ $player->windows[$id] = array( $this, $pair ); } - } else{ + }else{ $player->windows[$id] = $this; } @@ -77,12 +77,12 @@ trait Container{ $slot = $ob->getSlot($s); if($slot->getID() > Item::AIR and $slot->getCount() > 0){ $slots[] = $slot; - } else{ + }else{ $slots[] = Item::get(Item::AIR, 0, 0); } } } - } else{ + }else{ $pk = new Network\Protocol\TileEventPacket; $pk->x = $this->x; $pk->y = $this->y; @@ -94,7 +94,7 @@ trait Container{ $slot = $this->getSlot($s); if($slot->getID() > Item::AIR and $slot->getCount() > 0){ $slots[] = $slot; - } else{ + }else{ $slots[] = Item::get(Item::AIR, 0, 0); } } @@ -106,7 +106,7 @@ trait Container{ $player->dataPacket($pk); return true; - } elseif($this instanceof Furnace){ + }elseif($this instanceof Furnace){ $player->windowCnt++; $player->windowCnt = $id = max(2, $player->windowCnt % 99); $player->windows[$id] = $this; @@ -125,7 +125,7 @@ trait Container{ $slot = $this->getSlot($s); if($slot->getID() > Item::AIR and $slot->getCount() > 0){ $slots[] = $slot; - } else{ + }else{ $slots[] = Item::get(Item::AIR, 0, 0); } } @@ -152,7 +152,7 @@ trait Container{ $i = $this->getSlotIndex($s); if($i === false or $i < 0){ return Item::get(Item::AIR, 0, 0); - } else{ + }else{ return Item::get($this->namedtag->Items[$i]["id"], $this->namedtag->Items[$i]["Damage"], $this->namedtag->Items[$i]["Count"]); } } @@ -176,9 +176,9 @@ trait Container{ if($i >= 0){ unset($this->namedtag->Items[$i]); } - } elseif($i < 0){ + }elseif($i < 0){ $this->namedtag->Items[] = $d; - } else{ + }else{ $this->namedtag->Items[$i] = $d; } diff --git a/src/PocketMine/tile/Furnace.php b/src/PocketMine/tile/Furnace.php index eb9ba8471..72d32ba52 100644 --- a/src/PocketMine/tile/Furnace.php +++ b/src/PocketMine/tile/Furnace.php @@ -21,11 +21,11 @@ namespace PocketMine\Tile; +use PocketMine; use PocketMine\Block\Block; use PocketMine\Item\Item; use PocketMine\Level\Level; use PocketMine\NBT\Tag\Compound; -use PocketMine; class Furnace extends Tile{ use Container; @@ -92,15 +92,15 @@ class Furnace extends Tile{ $this->setSlot(0, $raw, false); $this->namedtag->CookTime -= 200; } - } elseif($this->namedtag->BurnTime <= 0){ + }elseif($this->namedtag->BurnTime <= 0){ $this->namedtag->BurnTime = 0; $this->namedtag->CookTime = 0; $this->namedtag->BurnTicks = 0; - } else{ + }else{ $this->namedtag->CookTime = 0; } $ret = true; - } else{ + }else{ $current = $this->level->getBlock($this); if($current->getID() === Item::BURNING_FURNACE){ $this->level->setBlock($this, Block::get(Item::FURNACE, $current->getMetadata()), true, false, true); diff --git a/src/PocketMine/tile/Sign.php b/src/PocketMine/tile/Sign.php index ddfa03c05..d697c6515 100644 --- a/src/PocketMine/tile/Sign.php +++ b/src/PocketMine/tile/Sign.php @@ -22,12 +22,12 @@ namespace PocketMine\Tile; use PocketMine\Level\Level; +use PocketMine; use PocketMine\NBT\NBT; use PocketMine\NBT\Tag\Compound; use PocketMine\NBT\Tag\Int; use PocketMine\NBT\Tag\String; use PocketMine\Network\Protocol\EntityDataPacket; -use PocketMine; use PocketMine\Player; class Sign extends Spawnable{ diff --git a/src/PocketMine/tile/Tile.php b/src/PocketMine/tile/Tile.php index e51a5df44..7fce777c1 100644 --- a/src/PocketMine/tile/Tile.php +++ b/src/PocketMine/tile/Tile.php @@ -25,12 +25,12 @@ */ namespace PocketMine\Tile; +use PocketMine; use PocketMine\Level\Level; use PocketMine\Level\Position; use PocketMine\NBT\Tag\Compound; use PocketMine\PMF\LevelFormat; use PocketMine\ServerAPI; -use PocketMine; abstract class Tile extends Position{ const SIGN = "Sign"; diff --git a/src/PocketMine/utils/Config.php b/src/PocketMine/utils/Config.php index 054fc0deb..919faa510 100644 --- a/src/PocketMine/utils/Config.php +++ b/src/PocketMine/utils/Config.php @@ -75,10 +75,10 @@ class Config{ ); /** - * @param string $file Path of the file to be loaded - * @param int $type Config type to load, -1 by default (detect) - * @param array $default Array with the default values, will be set if not existent - * @param null &$correct Sets correct to true if everything has been loaded correctly + * @param string $file Path of the file to be loaded + * @param int $type Config type to load, -1 by default (detect) + * @param array $default Array with the default values, will be set if not existent + * @param null &$correct Sets correct to true if everything has been loaded correctly */ public function __construct($file, $type = Config::DETECT, $default = array(), &$correct = null){ $this->load($file, $type, $default); @@ -121,13 +121,13 @@ class Config{ if(!file_exists($file)){ $this->config = $default; $this->save(); - } else{ + }else{ if($this->type === Config::DETECT){ $extension = explode(".", basename($this->file)); $extension = strtolower(trim(array_pop($extension))); if(isset(Config::$formats[$extension])){ $this->type = Config::$formats[$extension]; - } else{ + }else{ $this->correct = false; } } @@ -162,7 +162,7 @@ class Config{ if($this->fillDefaults($default, $this->config) > 0){ $this->save(); } - } else{ + }else{ return false; } } @@ -204,7 +204,7 @@ class Config{ @file_put_contents($this->file, $content, LOCK_EX); return true; - } else{ + }else{ return false; } } @@ -259,7 +259,7 @@ class Config{ /** * @param string $k key to be set - * @param bool $v value to set key + * @param bool $v value to set key */ public function set($k, $v = true){ $this->config[$k] = $v; @@ -283,7 +283,7 @@ class Config{ $k = strtolower($k); //Convert requested key to lower $array = array_change_key_case($this->config, CASE_LOWER); //Change all keys in array to lower return isset($array[$k]); //Find $k in modified array - } else{ + }else{ return isset($this->config[$k]); } } @@ -318,7 +318,7 @@ class Config{ $data[$k] = array(); } $changed += $this->fillDefaults($v, $data[$k]); - } elseif(!isset($data[$k])){ + }elseif(!isset($data[$k])){ $data[$k] = $v; ++$changed; } @@ -348,7 +348,7 @@ class Config{ foreach($this->config as $k => $v){ if(is_bool($v) === true){ $v = $v === true ? "on" : "off"; - } elseif(is_array($v)){ + }elseif(is_array($v)){ $v = implode(";", $v); } $content .= $k . "=" . $v . "\r\n"; diff --git a/src/PocketMine/utils/Utils.php b/src/PocketMine/utils/Utils.php index 28249eb6c..b405c54c7 100644 --- a/src/PocketMine/utils/Utils.php +++ b/src/PocketMine/utils/Utils.php @@ -51,7 +51,7 @@ class Utils{ public static function getCallableIdentifier(callable $variable){ if(is_array($variable)){ return sha1(strtolower(spl_object_hash($variable[0])) . "::" . strtolower($variable[1])); - } else{ + }else{ return sha1(strtolower($variable)); } } @@ -106,25 +106,25 @@ class Utils{ public static function getIP($force = false){ if(Utils::$online === false){ return false; - } elseif(Utils::$ip !== false and $force !== true){ + }elseif(Utils::$ip !== false and $force !== true){ return Utils::$ip; } $ip = trim(strip_tags(Utils::getURL("http://checkip.dyndns.org/"))); if(preg_match('#Current IP Address\: ([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){ Utils::$ip = $matches[1]; - } else{ + }else{ $ip = Utils::getURL("http://www.checkip.org/"); if(preg_match('#">([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){ Utils::$ip = $matches[1]; - } else{ + }else{ $ip = Utils::getURL("http://checkmyip.org/"); if(preg_match('#Your IP address is ([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){ Utils::$ip = $matches[1]; - } else{ + }else{ $ip = trim(Utils::getURL("http://ifconfig.me/ip")); if($ip != ""){ Utils::$ip = $ip; - } else{ + }else{ return false; } } @@ -152,20 +152,20 @@ class Utils{ if(stripos($uname, "Darwin") !== false){ if(strpos(php_uname("m"), "iP") === 0){ return "ios"; - } else{ + }else{ return "mac"; } - } elseif(stripos($uname, "Win") !== false or $uname === "Msys"){ + }elseif(stripos($uname, "Win") !== false or $uname === "Msys"){ return "win"; - } elseif(stripos($uname, "Linux") !== false){ + }elseif(stripos($uname, "Linux") !== false){ if(@file_exists("/system/build.prop")){ return "android"; - } else{ + }else{ return "linux"; } - } elseif(stripos($uname, "BSD") !== false or $uname === "DragonFly"){ + }elseif(stripos($uname, "BSD") !== false or $uname === "DragonFly"){ return "bsd"; - } else{ + }else{ return "other"; } } @@ -490,11 +490,11 @@ class Utils{ $value .= chr($secureValue); $secureValue = 0; $bitcnt = 0; - } else{ + }else{ ++$bitcnt; } ++$drop; - } else{ + }else{ $drop += 2; } } @@ -780,7 +780,7 @@ class Utils{ if($negative){ $x = ~$x; } - } else{ + }else{ $negative = false; } @@ -800,7 +800,7 @@ class Utils{ if($value{0} === "-"){ $value = substr($value, 1); } - } else{ + }else{ $negative = false; } while(bccomp($value, "0", 0) > 0){ diff --git a/src/PocketMine/utils/VersionString.php b/src/PocketMine/utils/VersionString.php index 406fcad84..3d1e96b69 100644 --- a/src/PocketMine/utils/VersionString.php +++ b/src/PocketMine/utils/VersionString.php @@ -51,7 +51,7 @@ class VersionString{ $this->major = ($version >> 5) & 0x0F; $this->generation = ($version >> 9) & 0x0F; $this->stage = array_search(($version >> 13) & 0x0F, VersionString::$stageOrder, true); - } else{ + }else{ $version = preg_split("/([A-Za-z]*)[ _\-]([0-9]*)\.([0-9]*)\.{0,1}([0-9]*)(dev|)/", $version, -1, PREG_SPLIT_DELIM_CAPTURE); $this->stage = strtolower($version[1]); //0-15 $this->generation = (int) $version[2]; //0-15 @@ -108,9 +108,9 @@ class VersionString{ } if($number > $tNumber){ return -1; //Target is older - } elseif($number < $tNumber){ + }elseif($number < $tNumber){ return 1; //Target is newer - } else{ + }else{ return 0; //Same version } } diff --git a/src/PocketMine/wizard/Installer.php b/src/PocketMine/wizard/Installer.php index 40cb99ecb..25d286444 100644 --- a/src/PocketMine/wizard/Installer.php +++ b/src/PocketMine/wizard/Installer.php @@ -25,9 +25,9 @@ */ namespace PocketMine\Wizard; -use PocketMine; -use PocketMine\Utils\Utils; use PocketMine\Utils\Config; +use PocketMine\Utils\Utils; +use PocketMine; class Installer{ const DEFAULT_NAME = "Minecraft: PE Server"; @@ -51,7 +51,7 @@ class Installer{ echo "[!] Couldn't find the language\n"; $lang = false; } - } while($lang == false); + }while($lang == false); $this->lang = new InstallerLang($lang); echo "[*] " . $this->lang->language_has_been_selected . "\n"; echo "[?] " . $this->lang->skip_installer . " (y/N): "; @@ -101,7 +101,7 @@ LICENSE; if($port <= 0 or $port > 65535){ echo "[!] " . $this->lang->invalid_port . "\n"; } - } while($port <= 0 or $port > 65535); + }while($port <= 0 or $port > 65535); $config->set("server-port", $port); echo "[*] " . $this->lang->ram_warning . "\n"; echo "[?] " . $this->lang->server_ram . " (" . self::DEFAULT_MEMORY . "): "; @@ -110,7 +110,7 @@ LICENSE; do{ echo "[?] " . $this->lang->default_gamemode . ": (" . self::DEFAULT_GAMEMODE . "): "; $gamemode = (int) $this->getInput(self::DEFAULT_GAMEMODE); - } while($gamemode < 0 or $gamemode > 3); + }while($gamemode < 0 or $gamemode > 3); $config->set("gamemode", $gamemode); echo "[?] " . $this->lang->max_players . " (" . self::DEFAULT_PLAYERS . "): "; $config->set("max-players", (int) $this->getInput(self::DEFAULT_PLAYERS)); @@ -118,7 +118,7 @@ LICENSE; echo "[?] " . $this->lang->spawn_protection . " (Y/n): "; if(strtolower($this->getInput("y")) == "n"){ $config->set("spawn-protection", -1); - } else{ + }else{ $config->set("spawn-protection", 16); } $config->save(); @@ -130,7 +130,7 @@ LICENSE; $op = strtolower($this->getInput("")); if($op === ""){ echo "[!] " . $this->lang->op_warning . "\n"; - } else{ + }else{ $ops = new Config(\PocketMine\DATA . "ops.txt", Config::ENUM); $ops->set($op, true); $ops->save(); @@ -141,7 +141,7 @@ LICENSE; if(strtolower($this->getInput("n")) === "y"){ echo "[!] " . $this->lang->whitelist_warning . "\n"; $config->set("white-list", true); - } else{ + }else{ $config->set("white-list", false); } $config->save(); @@ -154,7 +154,7 @@ LICENSE; echo "[?] " . $this->lang->query_disable . " (y/N): "; if(strtolower($this->getInput("n")) === "y"){ $config->set("enable-query", false); - } else{ + }else{ $config->set("enable-query", true); } @@ -165,7 +165,7 @@ LICENSE; $password = substr(base64_encode(Utils::getRandomBytes(20, false)), 3, 10); $config->set("rcon.password", $password); echo "[*] " . $this->lang->rcon_password . ": " . $password . "\n"; - } else{ + }else{ $config->set("enable-rcon", false); } @@ -173,7 +173,7 @@ LICENSE; echo "[?] " . $this->lang->usage_disable . " (y/N): "; if(strtolower($this->getInput("n")) === "y"){ $config->set("send-usage", false); - } else{ + }else{ $config->set("send-usage", true); } $config->save(); diff --git a/src/PocketMine/wizard/InstallerLang.php b/src/PocketMine/wizard/InstallerLang.php index 889bd6dea..e62c0c090 100644 --- a/src/PocketMine/wizard/InstallerLang.php +++ b/src/PocketMine/wizard/InstallerLang.php @@ -51,7 +51,7 @@ class InstallerLang{ if(file_exists(\PocketMine\PATH . "src/lang/Installer/" . $lang . ".ini")){ $this->lang = $lang; $this->langfile = \PocketMine\PATH . "src/lang/Installer/" . $lang . ".ini"; - } else{ + }else{ $l = glob(\PocketMine\PATH . "src/lang/Installer/" . $lang . "_*.ini"); if(count($l) > 0){ $files = array(); @@ -64,7 +64,7 @@ class InstallerLang{ $l = substr($l, strrpos($l, "/") + 1, -4); $this->lang = isset(self::$languages[$l]) ? $l : $lang; $this->langfile = \PocketMine\PATH . "src/lang/Installer/" . $l . ".ini"; - } else{ + }else{ $this->lang = "en"; $this->langfile = \PocketMine\PATH . "src/lang/Installer/en.ini"; } @@ -98,12 +98,12 @@ class InstallerLang{ if(!isset($this->texts[$this->lang][$name])){ if($this->lang !== "en" and isset($this->texts["en"][$name])){ return $this->texts["en"][$name]; - } else{ + }else{ return $name; } - } elseif(count($search) > 0){ + }elseif(count($search) > 0){ return str_replace($search, $replace, $this->texts[$this->lang][$name]); - } else{ + }else{ return $this->texts[$this->lang][$name]; } } diff --git a/src/pthreads.php b/src/pthreads.php index 4dccfd245..7221c8185 100644 --- a/src/pthreads.php +++ b/src/pthreads.php @@ -42,7 +42,7 @@ class StackableArray extends \Threaded{ } } -class AsyncMultipleQueue extends Thread{ +class AsyncMultipleQueue extends \Thread{ public $input; public $output; public $stop; @@ -112,7 +112,7 @@ class AsyncMultipleQueue extends Thread{ } } -class Async extends Thread{ +class Async extends \Thread{ public function __construct($method, $params = array()){ $this->method = $method; $this->params = $params;