diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aceec41d6..e2e58aa44 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,7 +40,6 @@ It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accept * Files MUST NOT have an ending `?>` tag. * Code MUST use namespaces. * Strings SHOULD use the double quote `"` except when the single quote is required. -* Arrays SHOULD be declared using `array()`, not the `[]` shortcut. * Argument lists MAY NOT be split across multiple lines, except long arrays. ```php diff --git a/src/pocketmine/Achievement.php b/src/pocketmine/Achievement.php index af014d57a..43dc4d217 100644 --- a/src/pocketmine/Achievement.php +++ b/src/pocketmine/Achievement.php @@ -33,7 +33,7 @@ abstract class Achievement{ public static $list = array( /*"openInventory" => array( "name" => "Taking Inventory", - "requires" => array(), + "requires" => [], ),*/ "mineWood" => array( "name" => "Getting Wood", @@ -118,7 +118,7 @@ abstract class Achievement{ return false; } - public static function add($achievementId, $achievementName, array $requires = array()){ + public static function add($achievementId, $achievementName, array $requires = []){ if(!isset(Achievement::$list[$achievementId])){ Achievement::$list[$achievementId] = array( "name" => $achievementName, diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index e0000a086..e827b3a95 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -103,15 +103,15 @@ class Player extends Human implements CommandSender, IPlayer{ public $gamemode; public $lastBreak; public $windowCnt = 2; - public $windows = array(); + public $windows = []; public $blocked = true; - public $achievements = array(); - public $chunksLoaded = array(); + public $achievements = []; + public $chunksLoaded = []; public $lastCorrect; - public $craftingItems = array(); - public $toCraft = array(); + public $craftingItems = []; + public $toCraft = []; public $lastCraft = 0; - public $loginData = array(); + public $loginData = []; protected $lastMovement = 0; protected $forceMovement = false; protected $connected = true; @@ -123,13 +123,13 @@ class Player extends Human implements CommandSender, IPlayer{ protected $displayName; protected $startAction = false; protected $sleeping = false; - protected $chunksOrder = array(); + protected $chunksOrder = []; /** @var Player[] */ - protected $hiddenPlayers = array(); - private $recoveryQueue = array(); - private $receiveQueue = array(); - private $resendQueue = array(); - private $ackQueue = array(); + protected $hiddenPlayers = []; + private $recoveryQueue = []; + private $receiveQueue = []; + private $resendQueue = []; + private $ackQueue = []; private $receiveCount = -1; /** @var \pocketmine\network\raknet\Packet */ private $buffer; @@ -141,7 +141,7 @@ class Player extends Human implements CommandSender, IPlayer{ private $lastMeasure = 0; private $bandwidthRaw = 0; private $bandwidthStats = array(0, 0, 0); - private $lag = array(); + private $lag = []; private $lagStat = 0; private $spawnPosition; private $packetLoss = 0; @@ -150,13 +150,13 @@ class Player extends Human implements CommandSender, IPlayer{ private $inAction = false; private $bigCnt; private $packetStats; - private $chunkCount = array(); - private $received = array(); + private $chunkCount = []; + private $received = []; /** * @var \pocketmine\scheduler\TaskHandler[] */ - private $tasks = array(); + private $tasks = []; /** @var PermissibleBase */ private $perm = null; @@ -377,7 +377,7 @@ class Player extends Human implements CommandSender, IPlayer{ $this->hotbar = array(0, -1, -1, -1, -1, -1, -1, -1, -1); $this->packetStats = array(0, 0); $this->buffer = new Packet(Info::DATA_PACKET_0); - $this->buffer->data = array(); + $this->buffer->data = []; $this->tasks[] = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask(array($this, "handlePacketQueues")), 1); $this->tasks[] = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask(array($this, "clearQueue")), 20 * 60); console("[DEBUG] New Session started with " . $ip . ":" . $port . ". MTU " . $this->MTU . ", Client ID " . $this->clientID, true, true, 2); @@ -399,7 +399,7 @@ class Player extends Human implements CommandSender, IPlayer{ */ public function hasAchievement($achievementId){ if(!isset(Achievement::$list[$achievementId]) or !isset($this->achievements)){ - $this->achievements = array(); + $this->achievements = []; return false; } @@ -565,7 +565,7 @@ class Player extends Human implements CommandSender, IPlayer{ if($cnt === false){ return false; } - $this->chunkCount = array(); + $this->chunkCount = []; foreach($cnt as $i => $count){ $this->chunkCount[$count] = true; } @@ -590,7 +590,7 @@ class Player extends Human implements CommandSender, IPlayer{ return false; } - $newOrder = array(); + $newOrder = []; $lastChunk = $this->chunksLoaded; $centerX = $this->x >> 4; $centerZ = $this->z >> 4; @@ -672,7 +672,7 @@ class Player extends Human implements CommandSender, IPlayer{ @$this->buffer->data[] = $packet; $this->bufferLen += 6 + $len; - return array(); + return []; } private function directBigRawPacket(DataPacket $packet){ @@ -686,7 +686,7 @@ class Player extends Human implements CommandSender, IPlayer{ $buffer = str_split($packet->buffer, $size); $bigCnt = $this->bigCnt; $this->bigCnt = ($this->bigCnt + 1) % 0x10000; - $cnts = array(); + $cnts = []; $bufCount = count($buffer); foreach($buffer as $i => $buf){ $cnts[] = $count = $this->counter[0]++; @@ -742,7 +742,7 @@ class Player extends Human implements CommandSender, IPlayer{ } $this->bufferLen = 0; $this->buffer = new Packet(Info::DATA_PACKET_0); - $this->buffer->data = array(); + $this->buffer->data = []; $this->nextBuffer = microtime(true) + 0.1; } } @@ -1064,7 +1064,7 @@ class Player extends Human implements CommandSender, IPlayer{ $this->bandwidthStats[] = $this->bandwidthRaw / max(0.00001, microtime(true) - $this->lastMeasure); $this->bandwidthRaw = 0; $this->lagStat = array_sum($this->lag) / max(1, count($this->lag)); - $this->lag = array(); + $this->lag = []; $this->sendBuffer(); $this->lastMeasure = microtime(true); } @@ -1141,7 +1141,7 @@ class Player extends Human implements CommandSender, IPlayer{ $packetCnt = (int) ($ackCnt / $safeCount + 1); for($p = 0; $p < $packetCnt; ++$p){ $pk = new Packet(Info::ACK); - $pk->packets = array(); + $pk->packets = []; for($c = 0; $c < $safeCount; ++$c){ if(($k = array_pop($this->ackQueue)) === null){ break; @@ -1150,7 +1150,7 @@ class Player extends Human implements CommandSender, IPlayer{ } $this->send($pk); } - $this->ackQueue = array(); + $this->ackQueue = []; } if(($receiveCnt = count($this->receiveQueue)) > 0){ @@ -1350,7 +1350,7 @@ class Player extends Human implements CommandSender, IPlayer{ return; } - $this->achievements = array(); + $this->achievements = []; foreach($nbt->Achievements as $achievement){ $this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false; } @@ -1559,8 +1559,8 @@ class Player extends Human implements CommandSender, IPlayer{ $this->dataPacket($pk); break; } - $this->craftingItems = array(); - $this->toCraft = array(); + $this->craftingItems = []; + $this->toCraft = []; $packet->eid = $this->id; if($packet->face >= 0 and $packet->face <= 5){ //Use Block, place @@ -1618,8 +1618,8 @@ class Player extends Human implements CommandSender, IPlayer{ break; } $packet->eid = $this->id; - $this->craftingItems = array(); - $this->toCraft = array(); + $this->craftingItems = []; + $this->toCraft = []; switch($packet->action){ case 5: //Shot arrow @@ -1693,8 +1693,8 @@ class Player extends Human implements CommandSender, IPlayer{ if($this->spawned === false or $this->blocked === true){ break; } - $this->craftingItems = array(); - $this->toCraft = array(); + $this->craftingItems = []; + $this->toCraft = []; $vector = new Vector3($packet->x, $packet->y, $packet->z); @@ -1725,8 +1725,8 @@ class Player extends Human implements CommandSender, IPlayer{ if($this->spawned === false or $this->blocked === true){ break; } - $this->craftingItems = array(); - $this->toCraft = array(); + $this->craftingItems = []; + $this->toCraft = []; for($i = 0; $i < 4; ++$i){ $s = $packet->slots[$i]; @@ -1774,12 +1774,12 @@ class Player extends Human implements CommandSender, IPlayer{ break; } $packet->eid = $this->id; - $data = array(); + $data = []; $data["target"] = $packet->target; $data["eid"] = $packet->eid; $data["action"] = $packet->action; - $this->craftingItems = array(); - $this->toCraft = array(); + $this->craftingItems = []; + $this->toCraft = []; $target = Entity::get($packet->target); if($target instanceof Entity and $this->gamemode !== VIEW and $this->blocked === false and ($target instanceof Entity) and $this->entity->distance($target) <= 8){ $data["targetentity"] = $target; @@ -1869,8 +1869,8 @@ class Player extends Human implements CommandSender, IPlayer{ if($this->spawned === false or $this->dead === false){ break; } - $this->craftingItems = array(); - $this->toCraft = array(); + $this->craftingItems = []; + $this->toCraft = []; $this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->spawnPosition)); @@ -1889,8 +1889,8 @@ class Player extends Human implements CommandSender, IPlayer{ if($this->spawned === false or $this->blocked === true){ break; } - $this->craftingItems = array(); - $this->toCraft = array(); + $this->craftingItems = []; + $this->toCraft = []; $packet->eid = $this->id; if($this->entity->inAction === true){ $this->entity->inAction = false; @@ -1945,9 +1945,9 @@ class Player extends Human implements CommandSender, IPlayer{ } $packet->eid = $this->id; $packet->item = $this->getSlot($this->getCurrentEquipment()); - $this->craftingItems = array(); - $this->toCraft = array(); - $data = array(); + $this->craftingItems = []; + $this->toCraft = []; + $data = []; $data["eid"] = $packet->eid; $data["unknown"] = $packet->unknown; $data["item"] = $packet->item; @@ -1965,8 +1965,8 @@ class Player extends Human implements CommandSender, IPlayer{ if($this->spawned === false){ break; } - $this->craftingItems = array(); - $this->toCraft = array(); + $this->craftingItems = []; + $this->toCraft = []; $packet->message = TextFormat::clean($packet->message); if(trim($packet->message) != "" and strlen($packet->message) <= 255){ $message = $packet->message; @@ -1988,8 +1988,8 @@ class Player extends Human implements CommandSender, IPlayer{ if($this->spawned === false){ break; } - $this->craftingItems = array(); - $this->toCraft = array(); + $this->craftingItems = []; + $this->toCraft = []; if(isset($this->windows[$packet->windowid])){ if(is_array($this->windows[$packet->windowid])){ foreach($this->windows[$packet->windowid] as $ob){ @@ -2026,9 +2026,9 @@ class Player extends Human implements CommandSender, IPlayer{ if(isset($this->toCraft[-1])){ $this->toCraft = array(-1 => $this->toCraft[-1]); }else{ - $this->toCraft = array(); + $this->toCraft = []; } - $this->craftingItems = array(); + $this->craftingItems = []; } if($packet->windowid === 0){ @@ -2063,15 +2063,15 @@ class Player extends Human implements CommandSender, IPlayer{ if($craft === true and count($this->craftingItems) > 0 and count($this->toCraft) > 0 and ($recipe = $this->craftItems($this->toCraft, $this->craftingItems, $this->toCraft[-1])) !== true){ if($recipe === false){ $this->sendInventory(); - $this->toCraft = array(); + $this->toCraft = []; }else{ $this->toCraft = array(-1 => $this->toCraft[-1]); } - $this->craftingItems = array(); + $this->craftingItems = []; } }else{ - $this->toCraft = array(); - $this->craftingItems = array(); + $this->toCraft = []; + $this->craftingItems = []; } if(!isset($this->windows[$packet->windowid])){ break; @@ -2206,8 +2206,8 @@ class Player extends Human implements CommandSender, IPlayer{ if($this->spawned === false or $this->blocked === true){ break; } - $this->craftingItems = array(); - $this->toCraft = array(); + $this->craftingItems = []; + $this->toCraft = []; $t = $this->getLevel()->getTile(new Vector3($packet->x, $packet->y, $packet->z)); if($t instanceof Sign){ if($t->namedtag->creator !== $this->username){ @@ -2307,11 +2307,11 @@ class Player extends Human implements CommandSender, IPlayer{ foreach($this->tasks as $task){ $task->cancel(); } - $this->tasks = array(); - $this->recoveryQueue = array(); - $this->receiveQueue = array(); - $this->resendQueue = array(); - $this->ackQueue = array(); + $this->tasks = []; + $this->recoveryQueue = []; + $this->receiveQueue = []; + $this->resendQueue = []; + $this->ackQueue = []; if(isset($ev) and $this->username != "" and $this->spawned !== false and $ev->getQuitMessage() != ""){ $this->server->broadcastMessage($ev->getQuitMessage()); @@ -2319,14 +2319,14 @@ class Player extends Human implements CommandSender, IPlayer{ $this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this); $this->spawned = false; console("[INFO] " . TextFormat::AQUA . $this->username . TextFormat::RESET . "[/" . $this->ip . ":" . $this->port . "] logged out due to " . $reason); - $this->windows = array(); - $this->armor = array(); - $this->inventory = array(); - $this->chunksLoaded = array(); - $this->chunksOrder = array(); - $this->chunkCount = array(); - $this->craftingItems = array(); - $this->received = array(); + $this->windows = []; + $this->armor = []; + $this->inventory = []; + $this->chunksLoaded = []; + $this->chunksOrder = []; + $this->chunkCount = []; + $this->craftingItems = []; + $this->received = []; $this->buffer = null; unset($this->buffer); } @@ -2372,7 +2372,7 @@ class Player extends Human implements CommandSender, IPlayer{ $this->server->getPluginManager()->callEvent($ev = new DataPacketSendEvent($this, $packet)); if($ev->isCancelled()){ - return array(); + return []; } $packet->encode(); $pk = new Packet(Info::DATA_PACKET_0); @@ -2432,7 +2432,7 @@ class Player extends Human implements CommandSender, IPlayer{ } - $recipeItems = array(); + $recipeItems = []; foreach($recipe as $item){ if(!isset($recipeItems[$item->getID()])){ $recipeItems[$item->getID()] = array($item->getID(), $item->getDamage(), $item->getCount()); @@ -2558,7 +2558,7 @@ class Player extends Human implements CommandSender, IPlayer{ if(($this->gamemode & 0x01) === 1){ return; } - $hotbar = array(); + $hotbar = []; foreach($this->hotbar as $slot){ $hotbar[] = $slot <= -1 ? -1 : $slot + 9; } @@ -2634,7 +2634,7 @@ class Player extends Human implements CommandSender, IPlayer{ case Info::DATA_PACKET_E: case Info::DATA_PACKET_F: $this->ackQueue[] = $packet->seqNumber; - $this->receiveQueue[$packet->seqNumber] = array(); + $this->receiveQueue[$packet->seqNumber] = []; foreach($packet->data as $pk){ $this->receiveQueue[$packet->seqNumber][] = $pk; } diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index 10cd3b4ef..fa275ece8 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -226,7 +226,7 @@ namespace pocketmine { function getTrace($start = 1){ $e = new \Exception(); $trace = $e->getTrace(); - $messages = array(); + $messages = []; $j = 0; for($i = (int) $start; isset($trace[$i]); ++$i, ++$j){ $params = ""; @@ -277,7 +277,7 @@ namespace pocketmine { if((!defined("pocketmine\\DEBUG") or \pocketmine\DEBUG >= $level) and (!defined("pocketmine\\LOG") or \pocketmine\LOG === true)){ $message .= $EOL === true ? PHP_EOL : ""; if(!isset($fpointers)){ - $fpointers = array(); + $fpointers = []; } if(!isset($fpointers[$name]) or $fpointers[$name] === false){ $fpointers[$name] = @fopen(\pocketmine\DATA . "/" . $name . ".log", "ab"); diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 35ab26498..7bfcb88e2 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -39,6 +39,7 @@ use pocketmine\event\HandlerList; use pocketmine\event\server\PacketReceiveEvent; use pocketmine\event\server\PacketSendEvent; use pocketmine\event\server\ServerCommandEvent; +use pocketmine\inventory\InventoryType; use pocketmine\item\Item; use pocketmine\level\generator\Flat; use pocketmine\level\generator\Generator; @@ -171,10 +172,10 @@ class Server{ private $properties; /** @var Player[] */ - private $players = array(); + private $players = []; /** @var Level[] */ - private $levels = array(); + private $levels = []; /** @var Level */ private $levelDefault = null; @@ -551,8 +552,8 @@ class Server{ new Int("SpawnY", (int) $spawn->y), new Int("SpawnZ", (int) $spawn->z), new Byte("SpawnForced", 1), //TODO - new Enum("Inventory", array()), - new Compound("Achievements", array()), + new Enum("Inventory", []), + new Compound("Achievements", []), new Int("playerGameType", $this->getGamemode()), new Enum("Motion", array( new Double(0, 0.0), @@ -576,7 +577,7 @@ class Server{ $nbt->Rotation->setTagType(NBT::TAG_Float); if(file_exists($path . "$name.yml")){ //Importing old PocketMine-MP files - $data = new Config($path . "$name.yml", Config::YAML, array()); + $data = new Config($path . "$name.yml", Config::YAML, []); $nbt["playerGameType"] = (int) $data->get("gamemode"); $nbt["Level"] = $data->get("position")["level"]; $nbt["Pos"][0] = $data->get("position")["x"]; @@ -696,7 +697,7 @@ class Server{ */ public function matchPlayer($partialName){ $partialName = strtolower($partialName); - $matchedPlayers = array(); + $matchedPlayers = []; foreach($this->getOnlinePlayers() as $player){ if(strtolower($player->getName()) === $partialName){ $matchedPlayers = array($player); @@ -849,11 +850,11 @@ class Server{ } $level->loadChunk($tile["x"] >> 4, $tile["z"] >> 4); - $nbt = new Compound(false, array()); + $nbt = new Compound(false, []); foreach($tile as $index => $data){ switch($index){ case "Items": - $tag = new Enum("Items", array()); + $tag = new Enum("Items", []); $tag->setTagType(NBT::TAG_Compound); foreach($data as $slot => $fields){ $tag[(int) $slot] = new Compound(false, array( @@ -918,7 +919,7 @@ class Server{ * * @return bool */ - public function generateLevel($name, $seed = null, $generator = null, array $options = array()){ + public function generateLevel($name, $seed = null, $generator = null, array $options = []){ if(trim($name) === "" or $this->isLevelGenerated($name)){ return false; } @@ -1273,6 +1274,8 @@ class Server{ //TODO: update checking (async) $this->enablePlugins(PluginLoadOrder::STARTUP); + + InventoryType::init(); Block::init(); Item::init(); Crafting::init(); @@ -1666,7 +1669,7 @@ class Server{ $dump .= "\r\n\r\n"; } - $extensions = array(); + $extensions = []; foreach(get_loaded_extensions() as $ext){ $extensions[$ext] = phpversion($ext); } diff --git a/src/pocketmine/block/Beetroot.php b/src/pocketmine/block/Beetroot.php index 38e0d714b..20c6bfc9c 100644 --- a/src/pocketmine/block/Beetroot.php +++ b/src/pocketmine/block/Beetroot.php @@ -81,7 +81,7 @@ class Beetroot extends Flowable{ } public function getDrops(Item $item){ - $drops = array(); + $drops = []; if($this->meta >= 0x07){ $drops[] = array(Item::BEETROOT, 0, 1); $drops[] = array(Item::BEETROOT_SEEDS, 0, mt_rand(0, 3)); diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 832d30bc2..67b9d6e62 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -405,7 +405,7 @@ abstract class Block extends Position implements Metadatable{ ); /** @var Block[] */ - public static $list = array(); + public static $list = []; protected $id; protected $meta; protected $name; @@ -650,7 +650,7 @@ abstract class Block extends Position implements Metadatable{ */ public function getDrops(Item $item){ if(!isset(self::$list[$this->id])){ //Unknown blocks - return array(); + return []; }else{ return array( array($this->id, $this->meta, 1), diff --git a/src/pocketmine/block/Bricks.php b/src/pocketmine/block/Bricks.php index df648c616..16ec86cb0 100644 --- a/src/pocketmine/block/Bricks.php +++ b/src/pocketmine/block/Bricks.php @@ -52,7 +52,7 @@ class Bricks extends Solid{ array(Item::BRICKS_BLOCK, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/BurningFurnace.php b/src/pocketmine/block/BurningFurnace.php index 544a3666c..90ba81808 100644 --- a/src/pocketmine/block/BurningFurnace.php +++ b/src/pocketmine/block/BurningFurnace.php @@ -48,7 +48,7 @@ class BurningFurnace extends Solid{ $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; $this->getLevel()->setBlock($block, $this, true, false, true); $nbt = new Compound(false, array( - new Enum("Items", array()), + new Enum("Items", []), new String("id", Tile::FURNACE), new Int("x", $this->x), new Int("y", $this->y), @@ -74,7 +74,7 @@ class BurningFurnace extends Solid{ $furnace = $t; }else{ $nbt = new Compound(false, array( - new Enum("Items", array()), + new Enum("Items", []), new String("id", Tile::FURNACE), new Int("x", $this->x), new Int("y", $this->y), @@ -112,7 +112,7 @@ class BurningFurnace extends Solid{ } public function getDrops(Item $item){ - $drops = array(); + $drops = []; if($item->isPickaxe() >= 1){ $drops[] = array(Item::FURNACE, 0, 1); } diff --git a/src/pocketmine/block/Cake.php b/src/pocketmine/block/Cake.php index d8931d941..0c7b03b71 100644 --- a/src/pocketmine/block/Cake.php +++ b/src/pocketmine/block/Cake.php @@ -58,7 +58,7 @@ class Cake extends Transparent{ } public function getDrops(Item $item){ - return array(); + return []; } public function onActivate(Item $item, Player $player = null){ diff --git a/src/pocketmine/block/Carrot.php b/src/pocketmine/block/Carrot.php index 5717a44f6..cedcf5a7a 100644 --- a/src/pocketmine/block/Carrot.php +++ b/src/pocketmine/block/Carrot.php @@ -81,7 +81,7 @@ class Carrot extends Flowable{ } public function getDrops(Item $item){ - $drops = array(); + $drops = []; if($this->meta >= 0x07){ $drops[] = array(Item::CARROT, 0, mt_rand(1, 4)); }else{ diff --git a/src/pocketmine/block/Chest.php b/src/pocketmine/block/Chest.php index 0ea0bbe05..dc77a987a 100644 --- a/src/pocketmine/block/Chest.php +++ b/src/pocketmine/block/Chest.php @@ -69,7 +69,7 @@ class Chest extends Transparent{ $this->getLevel()->setBlock($block, $this, true, false, true); $nbt = new Compound(false, array( - new Enum("Items", array()), + new Enum("Items", []), new String("id", Tile::CHEST), new Int("x", $this->x), new Int("y", $this->y), @@ -109,7 +109,7 @@ class Chest extends Transparent{ $chest = $t; }else{ $nbt = new Compound(false, array( - new Enum("Items", array()), + new Enum("Items", []), new String("id", Tile::CHEST), new Int("x", $this->x), new Int("y", $this->y), diff --git a/src/pocketmine/block/Coal.php b/src/pocketmine/block/Coal.php index 88e2b9dac..ee224883d 100644 --- a/src/pocketmine/block/Coal.php +++ b/src/pocketmine/block/Coal.php @@ -52,7 +52,7 @@ class Coal extends Solid{ array(Item::COAL_BLOCK, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/CoalOre.php b/src/pocketmine/block/CoalOre.php index 4db7b5d35..49b0c630d 100644 --- a/src/pocketmine/block/CoalOre.php +++ b/src/pocketmine/block/CoalOre.php @@ -52,7 +52,7 @@ class CoalOre extends Solid{ array(Item::COAL, 0, 1), ); }else{ - return array(); + return []; } } diff --git a/src/pocketmine/block/Cobblestone.php b/src/pocketmine/block/Cobblestone.php index 14f2cd253..186157d23 100644 --- a/src/pocketmine/block/Cobblestone.php +++ b/src/pocketmine/block/Cobblestone.php @@ -52,7 +52,7 @@ class Cobblestone extends Solid{ array(Item::COBBLESTONE, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/Cobweb.php b/src/pocketmine/block/Cobweb.php index 3268f8cab..5e8a54067 100644 --- a/src/pocketmine/block/Cobweb.php +++ b/src/pocketmine/block/Cobweb.php @@ -32,6 +32,6 @@ class Cobweb extends Flowable{ } public function getDrops(Item $item){ - return array(); + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Diamond.php b/src/pocketmine/block/Diamond.php index 53210dbf9..6c211656a 100644 --- a/src/pocketmine/block/Diamond.php +++ b/src/pocketmine/block/Diamond.php @@ -46,7 +46,7 @@ class Diamond extends Solid{ array(Item::DIAMOND_BLOCK, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/DiamondOre.php b/src/pocketmine/block/DiamondOre.php index f9c09fd23..d6a48baab 100644 --- a/src/pocketmine/block/DiamondOre.php +++ b/src/pocketmine/block/DiamondOre.php @@ -46,7 +46,7 @@ class DiamondOre extends Solid{ array(Item::DIAMOND, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/DoubleSlab.php b/src/pocketmine/block/DoubleSlab.php index 19acd361d..7ab51b6ab 100644 --- a/src/pocketmine/block/DoubleSlab.php +++ b/src/pocketmine/block/DoubleSlab.php @@ -62,7 +62,7 @@ class DoubleSlab extends Solid{ array(Item::SLAB, $this->meta & 0x07, 2), ); }else{ - return array(); + return []; } } diff --git a/src/pocketmine/block/Fire.php b/src/pocketmine/block/Fire.php index 36ca8e481..0774ce7af 100644 --- a/src/pocketmine/block/Fire.php +++ b/src/pocketmine/block/Fire.php @@ -34,7 +34,7 @@ class Fire extends Flowable{ } public function getDrops(Item $item){ - return array(); + return []; } public function onUpdate($type){ diff --git a/src/pocketmine/block/Glass.php b/src/pocketmine/block/Glass.php index 88f2de244..9f58a214b 100644 --- a/src/pocketmine/block/Glass.php +++ b/src/pocketmine/block/Glass.php @@ -30,6 +30,6 @@ class Glass extends Transparent{ } public function getDrops(Item $item){ - return array(); + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/GlowingRedstoneOre.php b/src/pocketmine/block/GlowingRedstoneOre.php index 5cc203eb4..5ede4d643 100644 --- a/src/pocketmine/block/GlowingRedstoneOre.php +++ b/src/pocketmine/block/GlowingRedstoneOre.php @@ -58,7 +58,7 @@ class GlowingRedstoneOre extends Solid{ array(Item::REDSTONE_DUST, 0, mt_rand(4, 5)), ); }else{ - return array(); + return []; } } diff --git a/src/pocketmine/block/Gold.php b/src/pocketmine/block/Gold.php index 4c9dafe52..e5ad32278 100644 --- a/src/pocketmine/block/Gold.php +++ b/src/pocketmine/block/Gold.php @@ -46,7 +46,7 @@ class Gold extends Solid{ array(Item::GOLD_BLOCK, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/GoldOre.php b/src/pocketmine/block/GoldOre.php index 7353dc71b..74f38024b 100644 --- a/src/pocketmine/block/GoldOre.php +++ b/src/pocketmine/block/GoldOre.php @@ -46,7 +46,7 @@ class GoldOre extends Solid{ array(Item::GOLD_ORE, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/Ice.php b/src/pocketmine/block/Ice.php index 4cc4e869b..8cfda5407 100644 --- a/src/pocketmine/block/Ice.php +++ b/src/pocketmine/block/Ice.php @@ -53,6 +53,6 @@ class Ice extends Transparent{ } public function getDrops(Item $item){ - return array(); + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Iron.php b/src/pocketmine/block/Iron.php index b31273244..90f06d2b1 100644 --- a/src/pocketmine/block/Iron.php +++ b/src/pocketmine/block/Iron.php @@ -48,7 +48,7 @@ class Iron extends Solid{ array(Item::IRON_BLOCK, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/IronDoor.php b/src/pocketmine/block/IronDoor.php index f8ff9c12a..f0e570b87 100644 --- a/src/pocketmine/block/IronDoor.php +++ b/src/pocketmine/block/IronDoor.php @@ -53,7 +53,7 @@ class IronDoor extends Door{ array(Item::IRON_DOOR, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/IronOre.php b/src/pocketmine/block/IronOre.php index c3c378616..f3af7c45e 100644 --- a/src/pocketmine/block/IronOre.php +++ b/src/pocketmine/block/IronOre.php @@ -48,7 +48,7 @@ class IronOre extends Solid{ array(Item::IRON_ORE, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/Lapis.php b/src/pocketmine/block/Lapis.php index fc1844b25..5c160f94f 100644 --- a/src/pocketmine/block/Lapis.php +++ b/src/pocketmine/block/Lapis.php @@ -48,7 +48,7 @@ class Lapis extends Solid{ array(Item::LAPIS_BLOCK, 0, 1), ); }else{ - return array(); + return []; } } diff --git a/src/pocketmine/block/LapisOre.php b/src/pocketmine/block/LapisOre.php index c8c079078..ff1a69b38 100644 --- a/src/pocketmine/block/LapisOre.php +++ b/src/pocketmine/block/LapisOre.php @@ -49,7 +49,7 @@ class LapisOre extends Solid{ array(Item::DYE, 4, mt_rand(4, 8)), ); }else{ - return array(); + return []; } } diff --git a/src/pocketmine/block/Leaves.php b/src/pocketmine/block/Leaves.php index 6a082d419..a01dbf12b 100644 --- a/src/pocketmine/block/Leaves.php +++ b/src/pocketmine/block/Leaves.php @@ -117,7 +117,7 @@ class Leaves extends Transparent{ }elseif($type === Level::BLOCK_UPDATE_RANDOM){ if(($this->meta & 0b00001100) === 0x08){ $this->meta &= 0x03; - $visited = array(); + $visited = []; $check = 0; if($this->findLog($this, $visited, 0, $check) === true){ $this->getLevel()->setBlock($this, $this, false, false, true); @@ -146,7 +146,7 @@ class Leaves extends Transparent{ } public function getDrops(Item $item){ - $drops = array(); + $drops = []; if($item->isShears()){ $drops[] = array(Item::LEAVES, $this->meta & 0x03, 1); }else{ diff --git a/src/pocketmine/block/MossStone.php b/src/pocketmine/block/MossStone.php index 36c062109..0217df5bf 100644 --- a/src/pocketmine/block/MossStone.php +++ b/src/pocketmine/block/MossStone.php @@ -53,7 +53,7 @@ class MossStone extends Solid{ array(Item::MOSS_STONE, $this->meta, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/NetherBrick.php b/src/pocketmine/block/NetherBrick.php index 737889219..fe6f73da4 100644 --- a/src/pocketmine/block/NetherBrick.php +++ b/src/pocketmine/block/NetherBrick.php @@ -53,7 +53,7 @@ class NetherBrick extends Solid{ array(Item::NETHER_BRICKS, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/Netherrack.php b/src/pocketmine/block/Netherrack.php index 93d54c4dd..da6687486 100644 --- a/src/pocketmine/block/Netherrack.php +++ b/src/pocketmine/block/Netherrack.php @@ -53,7 +53,7 @@ class Netherrack extends Solid{ array(Item::NETHERRACK, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/Obsidian.php b/src/pocketmine/block/Obsidian.php index 9227b3c7e..396515aab 100644 --- a/src/pocketmine/block/Obsidian.php +++ b/src/pocketmine/block/Obsidian.php @@ -44,7 +44,7 @@ class Obsidian extends Solid{ array(Item::OBSIDIAN, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/Potato.php b/src/pocketmine/block/Potato.php index 39b23ebd9..ba2abd832 100644 --- a/src/pocketmine/block/Potato.php +++ b/src/pocketmine/block/Potato.php @@ -83,7 +83,7 @@ class Potato extends Flowable{ } public function getDrops(Item $item){ - $drops = array(); + $drops = []; if($this->meta >= 0x07){ $drops[] = array(Item::POTATO, 0, mt_rand(1, 4)); }else{ diff --git a/src/pocketmine/block/Quartz.php b/src/pocketmine/block/Quartz.php index db5aa2ac3..39a2019a1 100644 --- a/src/pocketmine/block/Quartz.php +++ b/src/pocketmine/block/Quartz.php @@ -59,7 +59,7 @@ class Quartz extends Solid{ array(Item::QUARTZ_BLOCK, $this->meta & 0x03, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/RedstoneOre.php b/src/pocketmine/block/RedstoneOre.php index ff144e4f5..fd537cee6 100644 --- a/src/pocketmine/block/RedstoneOre.php +++ b/src/pocketmine/block/RedstoneOre.php @@ -46,7 +46,7 @@ class RedstoneOre extends Solid{ array(Item::REDSTONE_DUST, 0, mt_rand(4, 5)), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/Sandstone.php b/src/pocketmine/block/Sandstone.php index f9f83ffc4..b25cb0289 100644 --- a/src/pocketmine/block/Sandstone.php +++ b/src/pocketmine/block/Sandstone.php @@ -59,7 +59,7 @@ class Sandstone extends Solid{ array(Item::SANDSTONE, $this->meta & 0x03, 1), ); }else{ - return array(); + return []; } } diff --git a/src/pocketmine/block/Slab.php b/src/pocketmine/block/Slab.php index cb47b812a..3e6bbb8e0 100644 --- a/src/pocketmine/block/Slab.php +++ b/src/pocketmine/block/Slab.php @@ -119,7 +119,7 @@ class Slab extends Transparent{ array($this->id, $this->meta & 0x07, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/SnowLayer.php b/src/pocketmine/block/SnowLayer.php index 50210e2f0..176710783 100644 --- a/src/pocketmine/block/SnowLayer.php +++ b/src/pocketmine/block/SnowLayer.php @@ -64,6 +64,6 @@ class SnowLayer extends Flowable{ ); } - return array(); + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Stair.php b/src/pocketmine/block/Stair.php index d967c4c19..72a77097c 100644 --- a/src/pocketmine/block/Stair.php +++ b/src/pocketmine/block/Stair.php @@ -58,7 +58,7 @@ class Stair extends Transparent{ array($this->id, 0, 1), ); }else{ - return array(); + return []; } } } \ No newline at end of file diff --git a/src/pocketmine/block/Stone.php b/src/pocketmine/block/Stone.php index 987ee5207..2892e8967 100644 --- a/src/pocketmine/block/Stone.php +++ b/src/pocketmine/block/Stone.php @@ -53,7 +53,7 @@ class Stone extends Solid{ array(Item::COBBLESTONE, 0, 1), ); }else{ - return array(); + return []; } } diff --git a/src/pocketmine/block/StoneBricks.php b/src/pocketmine/block/StoneBricks.php index 97f6a2298..28aa66664 100644 --- a/src/pocketmine/block/StoneBricks.php +++ b/src/pocketmine/block/StoneBricks.php @@ -60,7 +60,7 @@ class StoneBricks extends Solid{ array(Item::STONE_BRICKS, $this->meta & 0x03, 1), ); }else{ - return array(); + return []; } } diff --git a/src/pocketmine/block/TallGrass.php b/src/pocketmine/block/TallGrass.php index 8c814c5e3..2ac85d9cc 100644 --- a/src/pocketmine/block/TallGrass.php +++ b/src/pocketmine/block/TallGrass.php @@ -50,7 +50,7 @@ class TallGrass extends Flowable{ } public function getDrops(Item $item){ - $drops = array(); + $drops = []; $possibleDrops = array( array(Item::WHEAT_SEEDS, 0, 1), array(Item::CARROT, 0, 1), diff --git a/src/pocketmine/block/Wheat.php b/src/pocketmine/block/Wheat.php index ec20134e8..fa4f59c04 100644 --- a/src/pocketmine/block/Wheat.php +++ b/src/pocketmine/block/Wheat.php @@ -79,7 +79,7 @@ class Wheat extends Flowable{ } public function getDrops(Item $item){ - $drops = array(); + $drops = []; if($this->meta >= 0x07){ $drops[] = array(Item::WHEAT, 0, 1); $drops[] = array(Item::WHEAT_SEEDS, 0, mt_rand(0, 3)); diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index d2b0ae821..50f16f4ba 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -40,12 +40,12 @@ abstract class Command{ /** * @var string[] */ - private $aliases = array(); + private $aliases = []; /** * @var string[] */ - private $activeAliases = array(); + private $activeAliases = []; /** @var CommandMap */ private $commandMap = null; @@ -68,7 +68,7 @@ abstract class Command{ * @param string $usageMessage * @param string[] $aliases */ - public function __construct($name, $description = "", $usageMessage = null, array $aliases = array()){ + public function __construct($name, $description = "", $usageMessage = null, array $aliases = []){ $this->name = $name; $this->nextLabel = $name; $this->label = $name; diff --git a/src/pocketmine/command/SimpleCommandMap.php b/src/pocketmine/command/SimpleCommandMap.php index 30267ee77..c5457511c 100644 --- a/src/pocketmine/command/SimpleCommandMap.php +++ b/src/pocketmine/command/SimpleCommandMap.php @@ -61,7 +61,7 @@ class SimpleCommandMap implements CommandMap{ /** * @var Command[] */ - protected $knownCommands = array(); + protected $knownCommands = []; /** @var Server */ private $server; @@ -184,7 +184,7 @@ class SimpleCommandMap implements CommandMap{ foreach($this->knownCommands as $command){ $command->unregister($this); } - $this->knownCommands = array(); + $this->knownCommands = []; $this->setDefaultCommands(); } diff --git a/src/pocketmine/command/defaults/HelpCommand.php b/src/pocketmine/command/defaults/HelpCommand.php index ca0e98daf..51966aa45 100644 --- a/src/pocketmine/command/defaults/HelpCommand.php +++ b/src/pocketmine/command/defaults/HelpCommand.php @@ -65,7 +65,7 @@ class HelpCommand extends VanillaCommand{ } if($command === ""){ - $commands = array(); + $commands = []; foreach(Server::getInstance()->getCommandMap()->getCommands() as $command){ if($command->testPermissionSilent($sender)){ $commands[$command->getName()] = $command; diff --git a/src/pocketmine/command/defaults/VanillaCommand.php b/src/pocketmine/command/defaults/VanillaCommand.php index 605421584..f0510fa21 100644 --- a/src/pocketmine/command/defaults/VanillaCommand.php +++ b/src/pocketmine/command/defaults/VanillaCommand.php @@ -29,7 +29,7 @@ abstract class VanillaCommand extends Command{ const MAX_COORD = 524288; const MIN_COORD = -524288; - public function __construct($name, $description = "", $usageMessage = null, array $aliases = array()){ + public function __construct($name, $description = "", $usageMessage = null, array $aliases = []){ parent::__construct($name, $description, $usageMessage, $aliases); } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 7933773e3..d34a6e3fb 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -53,17 +53,17 @@ abstract class Entity extends Position implements Metadatable{ /** * @var Entity[] */ - public static $list = array(); + public static $list = []; /** * @var Entity[] */ - public static $needUpdate = array(); + public static $needUpdate = []; /** * @var Player[] */ - protected $hasSpawned = array(); + protected $hasSpawned = []; protected $id; @@ -424,7 +424,7 @@ abstract class Entity extends Position implements Metadatable{ $this->setLevel($targetLevel, true); //Hard reference $this->getLevel()->entities[$this->id] = $this; //Oops, TODO!! if($this instanceof Player){ - $this->chunksLoaded = array(); + $this->chunksLoaded = []; $pk = new SetTimePacket(); $pk->time = $this->getLevel()->getTime(); $pk->started = $this->getLevel()->stopTime == false; diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 2447d80d6..365432a13 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -42,10 +42,10 @@ use pocketmine\Server; class Human extends Creature implements ProjectileSource, InventorySource{ protected $nameTag = "TESTIFICATE"; - protected $inventory = array(); + protected $inventory = []; public $slot; - protected $hotbar = array(); - protected $armor = array(); + protected $hotbar = []; + protected $armor = []; protected function initEntity(){ if(isset($this->namedtag->NameTag)){ @@ -76,7 +76,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{ public function saveNBT(){ parent::saveNBT(); - $this->namedtag->Inventory = new Enum("Inventory", array()); + $this->namedtag->Inventory = new Enum("Inventory", []); $this->namedtag->Inventory->setTagType(NBT::TAG_Compound); for($slot = 0; $slot < 9; ++$slot){ if(isset($this->hotbar[$slot]) and $this->hotbar[$slot] !== -1){ @@ -240,7 +240,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{ } public function sendArmor($player = null){ - $slots = array(); + $slots = []; 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; diff --git a/src/pocketmine/event/HandlerList.php b/src/pocketmine/event/HandlerList.php index c7019ce0a..03cd9774b 100644 --- a/src/pocketmine/event/HandlerList.php +++ b/src/pocketmine/event/HandlerList.php @@ -34,12 +34,12 @@ class HandlerList{ /** * @var RegisteredListener[][] */ - private $handlerSlots = array(); + private $handlerSlots = []; /** * @var HandlerList[] */ - private static $allLists = array(); + private static $allLists = []; public static function bakeAll(){ foreach(self::$allLists as $h){ @@ -61,7 +61,7 @@ class HandlerList{ }else{ foreach(self::$allLists as $h){ foreach($h->handlerSlots as $key => $list){ - $h->handlerSlots[$key] = array(); + $h->handlerSlots[$key] = []; } $h->handlers = null; } @@ -70,12 +70,12 @@ class HandlerList{ public function __construct(){ $this->handlerSlots = array( - EventPriority::MONITOR => array(), - EventPriority::HIGHEST => array(), - EventPriority::HIGH => array(), - EventPriority::NORMAL => array(), - EventPriority::LOW => array(), - EventPriority::LOWEST => array() + EventPriority::MONITOR => [], + EventPriority::HIGHEST => [], + EventPriority::HIGH => [], + EventPriority::NORMAL => [], + EventPriority::LOW => [], + EventPriority::LOWEST => [] ); self::$allLists[] = $this; } @@ -133,7 +133,7 @@ class HandlerList{ if($this->handlers !== null){ return; } - $entries = array(); + $entries = []; foreach($this->handlerSlots as $list){ foreach($list as $hash => $listener){ $entries[$hash] = $listener; @@ -149,7 +149,7 @@ class HandlerList{ */ public function getRegisteredListeners($plugin = null){ if($plugin instanceof Plugin){ - $listeners = array(); + $listeners = []; foreach($this->getRegisteredListeners(null) as $hash => $listener){ if($listener->getPlugin() === $plugin){ $listeners[$hash] = $plugin; diff --git a/src/pocketmine/event/player/PlayerChatEvent.php b/src/pocketmine/event/player/PlayerChatEvent.php index 5822adf74..95650070b 100644 --- a/src/pocketmine/event/player/PlayerChatEvent.php +++ b/src/pocketmine/event/player/PlayerChatEvent.php @@ -40,7 +40,7 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{ /** * @var Player[] */ - protected $recipients = array(); + protected $recipients = []; public function __construct(Player $player, $message, $format = "<%s> %s", array $recipients = null){ $this->player = $player; diff --git a/src/pocketmine/inventory/Inventory.php b/src/pocketmine/inventory/Inventory.php new file mode 100644 index 000000000..cb00e586c --- /dev/null +++ b/src/pocketmine/inventory/Inventory.php @@ -0,0 +1,153 @@ + 0){ + return; + } + + static::$default[static::CHEST] = new InventoryType(27, "Chest"); + static::$default[static::PLAYER] = new InventoryType(36, "Player"); //9 HOTBAR slots, 27 CONTAINER, 4 ARMOR + static::$default[static::FURNACE] = new InventoryType(3, "Furnace"); + static::$default[static::CRAFTING] = new InventoryType(5, "Crafting"); //4 CRAFTING slots, 1 RESULT + static::$default[static::WORKBENCH] = new InventoryType(10, "Crafting"); //9 CRAFTING slots, 1 RESULT + } + + /** + * @param int $defaultSize + * @param string $defaultTitle + */ + private function __construct($defaultSize, $defaultTitle){ + $this->size = $defaultSize; + $this->title = $defaultTitle; + } + + /** + * @return int + */ + public function getDefaultSize(){ + return $this->size; + } + + /** + * @return string + */ + public function getDefaultTitle(){ + return $this->title; + } +} \ No newline at end of file diff --git a/src/pocketmine/inventory/SlotType.php b/src/pocketmine/inventory/SlotType.php new file mode 100644 index 000000000..f8439f3cf --- /dev/null +++ b/src/pocketmine/inventory/SlotType.php @@ -0,0 +1,39 @@ +source->floor(); $radius = 2 * $this->size; $yield = (1 / $this->size) * 100; diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 78f856db7..50beb49c5 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -64,19 +64,19 @@ class Level{ const BLOCK_UPDATE_TOUCH = 5; /** @var Player[] */ - public $players = array(); + public $players = []; /** @var Entity[] */ - public $entities = array(); + public $entities = []; /** @var Entity[][] */ - public $chunkEntities = array(); + public $chunkEntities = []; /** @var Tile[] */ - public $tiles = array(); + public $tiles = []; /** @var Tile[][] */ - public $chunkTiles = array(); + public $chunkTiles = []; public $nextSave; @@ -116,9 +116,9 @@ class Level{ $this->nextSave += 90; $this->stopTime = false; $this->name = $name; - $this->usedChunks = array(); - $this->changedBlocks = array(); - $this->changedCount = array(); + $this->usedChunks = []; + $this->changedBlocks = []; + $this->changedCount = []; $gen = Generator::getGenerator($this->level->levelData["generator"]); $this->generator = new $gen((array) $this->level->levelData["generatorSettings"]); $this->generator->init($this, new Random($this->level->levelData["seed"])); @@ -184,7 +184,7 @@ class Level{ public function getUsingChunk($X, $Z){ $index = LevelFormat::getIndex($X, $Z); - return isset($this->usedChunks[$index]) ? $this->usedChunks[$index] : array(); + return isset($this->usedChunks[$index]) ? $this->usedChunks[$index] : []; } /** @@ -292,7 +292,7 @@ class Level{ } } } - $this->changedCount = array(); + $this->changedCount = []; if(count($this->changedBlocks) > 0){ foreach($this->changedBlocks as $index => $mini){ @@ -308,7 +308,7 @@ class Level{ } } } - $this->changedBlocks = array(); + $this->changedBlocks = []; } $X = null; @@ -429,8 +429,8 @@ class Level{ foreach($this->usedChunks as $index => $d){ LevelFormat::getXZ($index, $X, $Z); $nbt = new Compound("", array( - new Enum("Entities", array()), - new Enum("TileEntities", array()), + new Enum("Entities", []), + new Enum("TileEntities", []), )); $nbt->Entities->setTagType(NBT::TAG_Compound); $nbt->TileEntities->setTagType(NBT::TAG_Compound); @@ -531,12 +531,12 @@ class Level{ Cache::remove("world:{$this->name}:{$index}"); } if(!isset($this->changedBlocks[$index])){ - $this->changedBlocks[$index] = array(); + $this->changedBlocks[$index] = []; $this->changedCount[$index] = 0; } $Y = $pos->y >> 4; if(!isset($this->changedBlocks[$index][$Y])){ - $this->changedBlocks[$index][$Y] = array(); + $this->changedBlocks[$index][$Y] = []; $this->changedCount[$index] |= 1 << $Y; } $this->changedBlocks[$index][$Y][] = clone $block; @@ -581,12 +581,12 @@ class Level{ Cache::remove("world:{$this->name}:{$index}"); } if(!isset($this->changedBlocks[$index])){ - $this->changedBlocks[$index] = array(); + $this->changedBlocks[$index] = []; $this->changedCount[$index] = 0; } $Y = $pos->y >> 4; if(!isset($this->changedBlocks[$index][$Y])){ - $this->changedBlocks[$index][$Y] = array(); + $this->changedBlocks[$index][$Y] = []; $this->changedCount[$index] |= 1 << $Y; } $this->changedBlocks[$index][$Y][] = clone $block; @@ -896,7 +896,7 @@ class Level{ return $this->chunkEntities[$index]; } - return array(); + return []; } /** @@ -913,7 +913,7 @@ class Level{ return $this->chunkTiles[$index]; } - return array(); + return []; } /** @@ -929,9 +929,9 @@ class Level{ if(isset($this->usedChunks[$index])){ return true; }elseif($this->level->loadChunk($X, $Z) !== false){ - $this->usedChunks[$index] = array(); - $this->chunkTiles[$index] = array(); - $this->chunkEntities[$index] = array(); + $this->usedChunks[$index] = []; + $this->chunkTiles[$index] = []; + $this->chunkEntities[$index] = []; $tags = $this->level->getChunkNBT($X, $Z); if(isset($tags->Entities)){ foreach($tags->Entities as $nbt){ @@ -1027,7 +1027,7 @@ class Level{ } - $raw = array(); + $raw = []; for($Y = 0; $Y < 8; ++$Y){ if(($Yndex & (1 << $Y)) !== 0){ $raw[$Y] = $this->level->getMiniChunk($X, $Z, $Y); diff --git a/src/pocketmine/level/LevelImport.php b/src/pocketmine/level/LevelImport.php index 470ce0c9d..f0efee7ab 100644 --- a/src/pocketmine/level/LevelImport.php +++ b/src/pocketmine/level/LevelImport.php @@ -53,7 +53,7 @@ class LevelImport{ $nbt->read(substr(file_get_contents($this->path . "entities.dat"), 12)); $entities = $nbt->getData(); if(!isset($entities->TileEntities)){ - $entities->TileEntities = array(); + $entities->TileEntities = []; } $tiles = $entities->TileEntities; $entities = $entities->Entities; diff --git a/src/pocketmine/level/format/PocketChunkParser.php b/src/pocketmine/level/format/PocketChunkParser.php index cffef4b67..4743ef387 100644 --- a/src/pocketmine/level/format/PocketChunkParser.php +++ b/src/pocketmine/level/format/PocketChunkParser.php @@ -35,13 +35,13 @@ class PocketChunkParser{ private $file; public $sectorLength = 4096; //16 * 16 * 16 public $chunkLength = 86016; //21 * $sectorLength - public $map = array(); + public $map = []; public function __construct(){ } private function loadLocationTable(){ - $this->location = array(); + $this->location = []; console("[DEBUG] Loading Chunk Location table...", true, true, 2); for($offset = 0; $offset < 0x1000; $offset += 4){ $data = Binary::readLInt(substr($this->raw, $offset, 4)); @@ -116,10 +116,10 @@ class PocketChunkParser{ $len = Binary::readLInt(substr($this->raw, $offset, 4)); $offset += 4; $chunk = array( - 0 => array(), //Block - 1 => array(), //Data - 2 => array(), //SkyLight - 3 => array(), //BlockLight + 0 => [], //Block + 1 => [], //Data + 2 => [], //SkyLight + 3 => [], //BlockLight ); foreach($chunk as $section => &$data){ $l = $section === 0 ? 128 : 64; @@ -139,7 +139,7 @@ class PocketChunkParser{ $this->loadLocationTable(); console("[DEBUG] Loading chunks...", true, true, 2); for($x = 0; $x < 16; ++$x){ - $this->map[$x] = array(); + $this->map[$x] = []; for($z = 0; $z < 16; ++$z){ $this->map[$x][$z] = $this->parseChunk($x, $z); } diff --git a/src/pocketmine/level/format/anvil/Chunk.php b/src/pocketmine/level/format/anvil/Chunk.php index 114ca1a05..5f638ed87 100644 --- a/src/pocketmine/level/format/anvil/Chunk.php +++ b/src/pocketmine/level/format/anvil/Chunk.php @@ -38,32 +38,32 @@ class Chunk extends BaseChunk{ if($this->nbt->Entities instanceof Enum){ $this->nbt->Entities->setTagType(NBT::TAG_Compound); }else{ - $this->nbt->Entities = new Enum("Entities", array()); + $this->nbt->Entities = new Enum("Entities", []); $this->nbt->Entities->setTagType(NBT::TAG_Compound); } if($this->nbt->TileEntities instanceof Enum){ $this->nbt->TileEntities->setTagType(NBT::TAG_Compound); }else{ - $this->nbt->TileEntities = new Enum("TileEntities", array()); + $this->nbt->TileEntities = new Enum("TileEntities", []); $this->nbt->TileEntities->setTagType(NBT::TAG_Compound); } if($this->nbt->TileTicks instanceof Enum){ $this->nbt->TileTicks->setTagType(NBT::TAG_Compound); }else{ - $this->nbt->TileTicks = new Enum("TileTicks", array()); + $this->nbt->TileTicks = new Enum("TileTicks", []); $this->nbt->TileTicks->setTagType(NBT::TAG_Compound); } if($this->nbt->Sections instanceof Enum){ $this->nbt->Sections->setTagType(NBT::TAG_Compound); }else{ - $this->nbt->Sections = new Enum("Sections", array()); + $this->nbt->Sections = new Enum("Sections", []); $this->nbt->Sections->setTagType(NBT::TAG_Compound); } - $sections = array(); + $sections = []; foreach($this->nbt->Sections as $section){ if($section instanceof Compound){ $sections[(int) $section["Y"]] = new ChunkSection($section); diff --git a/src/pocketmine/level/format/anvil/RegionLoader.php b/src/pocketmine/level/format/anvil/RegionLoader.php index 9ebe0b753..08f7f524e 100644 --- a/src/pocketmine/level/format/anvil/RegionLoader.php +++ b/src/pocketmine/level/format/anvil/RegionLoader.php @@ -43,7 +43,7 @@ class RegionLoader{ protected $filePath; protected $filePointer; protected $lastSector; - protected $locationTable = array(); + protected $locationTable = []; public function __construct($path,/*Level $level, */$regionX, $regionZ){ $this->x = $regionX; @@ -118,7 +118,7 @@ class RegionLoader{ } public function generateChunk($x, $z){ - $nbt = new Compound("Level", array()); + $nbt = new Compound("Level", []); $nbt->xPos = new Int("xPos", ($this->getX() * 32) + $x); $nbt->zPos = new Int("xPos", ($this->getZ() * 32) + $z); $nbt->LastUpdate = new Long("LastUpdate", 0); @@ -128,13 +128,13 @@ class RegionLoader{ $nbt->InhabitedTime = new Long("InhabitedTime", 0); $nbt->Biomes = new ByteArray("Biomes", str_repeat(Binary::writeByte(-1), 256)); $nbt->HeightMap = new IntArray("HeightMap", array_fill(0, 256, 127)); - $nbt->Sections = new Enum("Sections", array()); + $nbt->Sections = new Enum("Sections", []); $nbt->Sections->setTagType(NBT::TAG_Compound); - $nbt->Entities = new Enum("Entities", array()); + $nbt->Entities = new Enum("Entities", []); $nbt->Entities->setTagType(NBT::TAG_Compound); - $nbt->TileEntities = new Enum("TileEntities", array()); + $nbt->TileEntities = new Enum("TileEntities", []); $nbt->TileEntities->setTagType(NBT::TAG_Compound); - $nbt->TileTicks = new Enum("TileTicks", array()); + $nbt->TileTicks = new Enum("TileTicks", []); $nbt->TileTicks->setTagType(NBT::TAG_Compound); $writer = new NBT(NBT::BIG_ENDIAN); $writer->setData(new Compound("", array($nbt))); @@ -187,7 +187,7 @@ class RegionLoader{ } private function cleanGarbage(){ - $sectors = array(); + $sectors = []; foreach($this->locationTable as $index => $data){ //Calculate file usage if($data[0] === 0 or $data[1] === 0){ $this->locationTable[$index] = array(0, 0, 0); diff --git a/src/pocketmine/level/format/generic/BaseChunk.php b/src/pocketmine/level/format/generic/BaseChunk.php index f5cf50788..489e6604b 100644 --- a/src/pocketmine/level/format/generic/BaseChunk.php +++ b/src/pocketmine/level/format/generic/BaseChunk.php @@ -27,7 +27,7 @@ use pocketmine\level\Level; abstract class BaseChunk implements Chunk{ /** @var ChunkSection[] */ - protected $sections = array(); + protected $sections = []; protected $level; protected $x; diff --git a/src/pocketmine/level/format/pmf/LevelFormat.php b/src/pocketmine/level/format/pmf/LevelFormat.php index 1706eaad6..add37e013 100644 --- a/src/pocketmine/level/format/pmf/LevelFormat.php +++ b/src/pocketmine/level/format/pmf/LevelFormat.php @@ -34,11 +34,11 @@ class LevelFormat extends PMF{ const ZLIB_ENCODING = 15; //15 = zlib, -15 = raw deflate, 31 = gzip public $level; - public $levelData = array(); + public $levelData = []; public $isLoaded = true; - private $chunks = array(); - private $chunkChange = array(); - private $chunkInfo = array(); + private $chunks = []; + private $chunkChange = []; + private $chunkInfo = []; public $isGenerating = 0; public function getData($index){ @@ -69,9 +69,9 @@ class LevelFormat extends PMF{ * @param bool|array $blank default false */ public function __construct($file, $blank = false){ - $this->chunks = array(); - $this->chunkChange = array(); - $this->chunkInfo = array(); + $this->chunks = []; + $this->chunkChange = []; + $this->chunkInfo = []; if(is_array($blank)){ $this->create($file, 0); $this->levelData = $blank; @@ -189,8 +189,8 @@ class LevelFormat extends PMF{ private function upgrade_From1_To2(){ console("[NOTICE] Old PMF Level format version #1 detected, upgrading to version #2"); $nbt = new Compound("", array( - new Enum("Entities", array()), - new Enum("TileEntities", array()) + new Enum("Entities", []), + new Enum("TileEntities", []) )); $nbt->Entities->setTagType(NBT::TAG_Compound); $nbt->TileEntities->setTagType(NBT::TAG_Compound); @@ -301,7 +301,7 @@ class LevelFormat extends PMF{ $nbt->read(substr($chunk, $offset, $len)); $this->chunkInfo[$index][2] = $nbt->getData(); $offset += $len; - $this->chunks[$index] = array(); + $this->chunks[$index] = []; $this->chunkChange[$index] = array(-1 => false); $this->chunkInfo[$index][3] = substr($chunk, $offset, 256); //Biome data $offset += 256; @@ -421,8 +421,8 @@ class LevelFormat extends PMF{ 7 => 8192, ); $nbt = new Compound("", array( - new Enum("Entities", array()), - new Enum("TileEntities", array()) + new Enum("Entities", []), + new Enum("TileEntities", []) )); $nbt->Entities->setTagType(NBT::TAG_Compound); $nbt->TileEntities->setTagType(NBT::TAG_Compound); diff --git a/src/pocketmine/level/generator/Flat.php b/src/pocketmine/level/generator/Flat.php index 4c36e4250..b9734b6b0 100644 --- a/src/pocketmine/level/generator/Flat.php +++ b/src/pocketmine/level/generator/Flat.php @@ -37,7 +37,7 @@ use pocketmine\math\Vector3 as Vector3; use pocketmine\utils\Random; class Flat extends Generator{ - private $level, $random, $structure, $chunks, $options, $floorLevel, $preset, $populators = array(); + private $level, $random, $structure, $chunks, $options, $floorLevel, $preset, $populators = []; public function getSettings(){ return $this->options; @@ -47,7 +47,7 @@ class Flat extends Generator{ return "flat"; } - public function __construct(array $options = array()){ + public function __construct(array $options = []){ $this->preset = "2;7,59x1,3x3,2;1;spawn(radius=10 block=89),decoration(treecount=80 grasscount=45)"; $this->options = $options; if(isset($options["preset"])){ @@ -84,8 +84,8 @@ class Flat extends Generator{ $options = isset($preset[3]) ? $preset[3] : ""; preg_match_all('#(([0-9]{0,})x?([0-9]{1,3}:?[0-9]{0,2})),?#', $blocks, $matches); $y = 0; - $this->structure = array(); - $this->chunks = array(); + $this->structure = []; + $this->chunks = []; foreach($matches[3] as $i => $b){ $b = Item::fromString($b); $cnt = $matches[2][$i] === "" ? 1 : intval($matches[2][$i]); @@ -122,7 +122,7 @@ class Flat extends Generator{ foreach($matches[2] as $i => $option){ $params = true; if($matches[3][$i] !== ""){ - $params = array(); + $params = []; $p = explode(" ", $matches[3][$i]); foreach($p as $k){ $k = explode("=", $k); diff --git a/src/pocketmine/level/generator/Generator.php b/src/pocketmine/level/generator/Generator.php index 6ee1c3644..e4fb59b10 100644 --- a/src/pocketmine/level/generator/Generator.php +++ b/src/pocketmine/level/generator/Generator.php @@ -28,7 +28,7 @@ use pocketmine\level\Level; use pocketmine\utils\Random; abstract class Generator{ - private static $list = array(); + private static $list = []; public static function addGenerator($object, $name){ if(is_subclass_of($object, "pocketmine\\level\\generator\\Generator") and !isset(Generator::$list[$name])){ @@ -48,7 +48,7 @@ abstract class Generator{ return "pocketmine\\level\\generator\\Normal"; } - public abstract function __construct(array $settings = array()); + public abstract function __construct(array $settings = []); public abstract function init(Level $level, Random $random); diff --git a/src/pocketmine/level/generator/Normal.php b/src/pocketmine/level/generator/Normal.php index f9d462fc6..c77943760 100644 --- a/src/pocketmine/level/generator/Normal.php +++ b/src/pocketmine/level/generator/Normal.php @@ -40,7 +40,7 @@ use pocketmine\utils\Random; class Normal extends Generator{ - private $populators = array(); + private $populators = []; private $level; private $random; private $worldHeight = 65; @@ -50,7 +50,7 @@ class Normal extends Generator{ private $noisePatchesSmall; private $noiseBase; - public function __construct(array $options = array()){ + public function __construct(array $options = []){ } @@ -59,7 +59,7 @@ class Normal extends Generator{ } public function getSettings(){ - return array(); + return []; } public function init(Level $level, Random $random){ @@ -98,10 +98,10 @@ class Normal extends Generator{ public function generateChunk($chunkX, $chunkZ){ $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed()); - $hills = array(); - $patches = array(); - $patchesSmall = array(); - $base = array(); + $hills = []; + $patches = []; + $patchesSmall = []; + $base = []; for($z = 0; $z < 16; ++$z){ for($x = 0; $x < 16; ++$x){ $i = ($z << 4) + $x; diff --git a/src/pocketmine/level/generator/noise/Generator.php b/src/pocketmine/level/generator/noise/Generator.php index 60bf08523..53cb37eb5 100644 --- a/src/pocketmine/level/generator/noise/Generator.php +++ b/src/pocketmine/level/generator/noise/Generator.php @@ -29,7 +29,7 @@ namespace pocketmine\level\generator\noise; abstract class Generator{ - protected $perm = array(); + protected $perm = []; protected $offsetX = 0; protected $offsetY = 0; protected $offsetZ = 0; diff --git a/src/pocketmine/level/generator/populator/Ore.php b/src/pocketmine/level/generator/populator/Ore.php index 991d0ba88..5959f2f0c 100644 --- a/src/pocketmine/level/generator/populator/Ore.php +++ b/src/pocketmine/level/generator/populator/Ore.php @@ -27,7 +27,7 @@ use pocketmine\math\Vector3 as Vector3; use pocketmine\utils\Random; class Ore extends Populator{ - private $oreTypes = array(); + private $oreTypes = []; public function populate(Level $level, $chunkX, $chunkZ, Random $random){ foreach($this->oreTypes as $type){ diff --git a/src/pocketmine/math/Matrix.php b/src/pocketmine/math/Matrix.php index 76505b3bb..955d7ed36 100644 --- a/src/pocketmine/math/Matrix.php +++ b/src/pocketmine/math/Matrix.php @@ -23,7 +23,7 @@ namespace pocketmine\math; class Matrix implements \ArrayAccess{ - private $matrix = array(); + private $matrix = []; private $rows = 0; private $columns = 0; @@ -43,7 +43,7 @@ class Matrix implements \ArrayAccess{ unset($this->matrix[(int) $offset]); } - public function __construct($rows, $columns, array $set = array()){ + public function __construct($rows, $columns, array $set = []){ $this->rows = max(1, (int) $rows); $this->columns = max(1, (int) $columns); $this->set($set); @@ -51,7 +51,7 @@ class Matrix implements \ArrayAccess{ public function set(array $m){ for($r = 0; $r < $this->rows; ++$r){ - $this->matrix[$r] = array(); + $this->matrix[$r] = []; for($c = 0; $c < $this->columns; ++$c){ $this->matrix[$r][$c] = isset($m[$r][$c]) ? $m[$r][$c] : 0; } diff --git a/src/pocketmine/nbt/tag/Compound.php b/src/pocketmine/nbt/tag/Compound.php index 1163bf67b..e68751b1f 100644 --- a/src/pocketmine/nbt/tag/Compound.php +++ b/src/pocketmine/nbt/tag/Compound.php @@ -25,7 +25,7 @@ use pocketmine\nbt\NBT; class Compound extends NamedTag implements \ArrayAccess{ - public function __construct($name = "", $value = array()){ + public function __construct($name = "", $value = []){ $this->name = $name; foreach($value as $tag){ $this->{$tag->getName()} = $tag; @@ -65,7 +65,7 @@ class Compound extends NamedTag implements \ArrayAccess{ } public function read(NBT $nbt){ - $this->value = array(); + $this->value = []; do{ $tag = $nbt->readTag(); if($tag instanceof NamedTag and $tag->getName() !== ""){ diff --git a/src/pocketmine/nbt/tag/Enum.php b/src/pocketmine/nbt/tag/Enum.php index f53e9d2f9..0098941b2 100644 --- a/src/pocketmine/nbt/tag/Enum.php +++ b/src/pocketmine/nbt/tag/Enum.php @@ -28,7 +28,7 @@ class Enum extends NamedTag implements \ArrayAccess{ private $tagType; - public function __construct($name = "", $value = array()){ + public function __construct($name = "", $value = []){ $this->name = $name; foreach($value as $k => $v){ $this->{$k} = $v; @@ -76,7 +76,7 @@ class Enum extends NamedTag implements \ArrayAccess{ } public function read(NBT $nbt){ - $this->value = array(); + $this->value = []; $this->tagType = $nbt->getByte(); $size = $nbt->getInt(); for($i = 0; $i < $size and !$nbt->feof(); ++$i){ @@ -156,7 +156,7 @@ class Enum extends NamedTag implements \ArrayAccess{ $nbt->putByte($this->tagType); - $tags = array(); + $tags = []; foreach($this as $tag){ if($tag instanceof Tag){ $tags[] = $tag; diff --git a/src/pocketmine/nbt/tag/IntArray.php b/src/pocketmine/nbt/tag/IntArray.php index b47ba7a88..11c11ba3a 100644 --- a/src/pocketmine/nbt/tag/IntArray.php +++ b/src/pocketmine/nbt/tag/IntArray.php @@ -30,7 +30,7 @@ class IntArray extends NamedTag{ } public function read(NBT $nbt){ - $this->value = array(); + $this->value = []; $size = $nbt->getInt(); for($i = 0; $i < $size and !$nbt->feof(); ++$i){ $this->value[] = $nbt->getInt(); diff --git a/src/pocketmine/network/protocol/ContainerSetContentPacket.php b/src/pocketmine/network/protocol/ContainerSetContentPacket.php index 5163e0697..460cb4222 100644 --- a/src/pocketmine/network/protocol/ContainerSetContentPacket.php +++ b/src/pocketmine/network/protocol/ContainerSetContentPacket.php @@ -24,8 +24,8 @@ namespace pocketmine\network\protocol; class ContainerSetContentPacket extends DataPacket{ public $windowid; - public $slots = array(); - public $hotbar = array(); + public $slots = []; + public $hotbar = []; public function pid(){ return Info::CONTAINER_SET_CONTENT_PACKET; diff --git a/src/pocketmine/network/protocol/DataPacket.php b/src/pocketmine/network/protocol/DataPacket.php index b41b57eef..8ed37f9f1 100644 --- a/src/pocketmine/network/protocol/DataPacket.php +++ b/src/pocketmine/network/protocol/DataPacket.php @@ -137,7 +137,7 @@ abstract class DataPacket extends \stdClass{ } protected function getDataArray($len = 10){ - $data = array(); + $data = []; for($i = 1; $i <= $len and !$this->feof(); ++$i){ $data[] = $this->get($this->getTriad()); } @@ -145,7 +145,7 @@ abstract class DataPacket extends \stdClass{ return $data; } - protected function putDataArray(array $data = array()){ + protected function putDataArray(array $data = []){ foreach($data as $v){ $this->putTriad(strlen($v)); $this->put($v); diff --git a/src/pocketmine/network/protocol/PlayerArmorEquipmentPacket.php b/src/pocketmine/network/protocol/PlayerArmorEquipmentPacket.php index d31eeb9c4..8fa462ac7 100644 --- a/src/pocketmine/network/protocol/PlayerArmorEquipmentPacket.php +++ b/src/pocketmine/network/protocol/PlayerArmorEquipmentPacket.php @@ -24,7 +24,7 @@ namespace pocketmine\network\protocol; class PlayerArmorEquipmentPacket extends DataPacket{ public $eid; - public $slots = array(); + public $slots = []; public function pid(){ return Info::PLAYER_ARMOR_EQUIPMENT_PACKET; diff --git a/src/pocketmine/network/protocol/SendInventoryPacket.php b/src/pocketmine/network/protocol/SendInventoryPacket.php index f3348e07e..c8322a91d 100644 --- a/src/pocketmine/network/protocol/SendInventoryPacket.php +++ b/src/pocketmine/network/protocol/SendInventoryPacket.php @@ -25,8 +25,8 @@ namespace pocketmine\network\protocol; class SendInventoryPacket extends DataPacket{ public $eid; public $windowid; - public $slots = array(); - public $armor = array(); + public $slots = []; + public $armor = []; public function pid(){ return Info::SEND_INVENTORY_PACKET; diff --git a/src/pocketmine/network/raknet/Packet.php b/src/pocketmine/network/raknet/Packet.php index 9d17342d5..ef9798bfe 100644 --- a/src/pocketmine/network/raknet/Packet.php +++ b/src/pocketmine/network/raknet/Packet.php @@ -84,7 +84,7 @@ use pocketmine\utils\Utils; class Packet extends NetworkPacket{ private $packetID; private $offset = 1; - public $data = array(); + public $data = []; public function __construct($packetID){ $this->packetID = (int) $packetID; @@ -172,7 +172,7 @@ class Packet extends NetworkPacket{ case Info::DATA_PACKET_E: case Info::DATA_PACKET_F: $this->seqNumber = $this->getLTriad(); - $this->data = array(); + $this->data = []; while(!$this->feof() and $this->parseDataPacket() !== false){ } @@ -180,7 +180,7 @@ class Packet extends NetworkPacket{ case Info::NACK: case Info::ACK: $count = $this->getShort(); - $this->packets = array(); + $this->packets = []; for($i = 0; $i < $count and !$this->feof(); ++$i){ if($this->getByte() === 0){ $start = $this->getLTriad(); diff --git a/src/pocketmine/network/rcon/RCON.php b/src/pocketmine/network/rcon/RCON.php index 307825da5..4b6494d22 100644 --- a/src/pocketmine/network/rcon/RCON.php +++ b/src/pocketmine/network/rcon/RCON.php @@ -41,7 +41,7 @@ class RCON{ private $rconSender; public function __construct($password, $port = 19132, $interface = "0.0.0.0", $threads = 1, $clientsPerThread = 50){ - $this->workers = array(); + $this->workers = []; $this->password = (string) $password; console("[INFO] Starting remote control listener"); if($this->password === ""){ diff --git a/src/pocketmine/permission/BanList.php b/src/pocketmine/permission/BanList.php index 63c8508dd..ca4eaa73a 100644 --- a/src/pocketmine/permission/BanList.php +++ b/src/pocketmine/permission/BanList.php @@ -26,7 +26,7 @@ use pocketmine\Server; class BanList{ /** @var BanEntry[] */ - private $list = array(); + private $list = []; /** @var string */ private $file; @@ -128,7 +128,7 @@ class BanList{ } public function load(){ - $this->list = array(); + $this->list = []; $fp = @fopen($this->file, "r"); if(is_resource($fp)){ while(($line = fgets($fp)) !== false){ diff --git a/src/pocketmine/permission/PermissibleBase.php b/src/pocketmine/permission/PermissibleBase.php index 0ee752042..094b8fe88 100644 --- a/src/pocketmine/permission/PermissibleBase.php +++ b/src/pocketmine/permission/PermissibleBase.php @@ -34,12 +34,12 @@ class PermissibleBase implements Permissible{ /** * @var PermissionAttachment[] */ - private $attachments = array(); + private $attachments = []; /** * @var PermissionAttachmentInfo[] */ - private $permissions = array(); + private $permissions = []; /** * @param ServerOperator $opable @@ -190,7 +190,7 @@ class PermissibleBase implements Permissible{ Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(false, $this->parent); Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(true, $this->parent); - $this->permissions = array(); + $this->permissions = []; } /** diff --git a/src/pocketmine/permission/Permission.php b/src/pocketmine/permission/Permission.php index 35da701c8..6a1c2a91c 100644 --- a/src/pocketmine/permission/Permission.php +++ b/src/pocketmine/permission/Permission.php @@ -84,7 +84,7 @@ class Permission{ /** * @var string[] */ - private $children = array(); + private $children = []; /** @var string */ private $defaultValue; @@ -97,7 +97,7 @@ class Permission{ * @param string $defaultValue * @param Permission[] $children */ - public function __construct($name, $description = null, $defaultValue = null, array $children = array()){ + public function __construct($name, $description = null, $defaultValue = null, array $children = []){ $this->name = $name; $this->description = $description !== null ? $description : ""; $this->defaultValue = $defaultValue !== null ? $defaultValue : self::$DEFAULT_PERMISSION; @@ -199,7 +199,7 @@ class Permission{ * @return Permission[] */ public static function loadPermissions(array $data, $default = self::DEFAULT_OP){ - $result = array(); + $result = []; foreach($data as $key => $entry){ $result[] = self::loadPermission($key, $entry, $default, $result); } @@ -215,9 +215,9 @@ class Permission{ * * @return Permission */ - public static function loadPermission($name, array $data, $default = self::DEFAULT_OP, &$output = array()){ + public static function loadPermission($name, array $data, $default = self::DEFAULT_OP, &$output = []){ $desc = null; - $children = array(); + $children = []; if(isset($data["default"])){ $value = Permission::getByName($data["default"]); if($value !== null){ diff --git a/src/pocketmine/permission/PermissionAttachment.php b/src/pocketmine/permission/PermissionAttachment.php index f70010d5e..af0e836b9 100644 --- a/src/pocketmine/permission/PermissionAttachment.php +++ b/src/pocketmine/permission/PermissionAttachment.php @@ -30,7 +30,7 @@ class PermissionAttachment{ /** * @var bool[] */ - private $permissions = array(); + private $permissions = []; /** @var Permissible */ private $permissible; diff --git a/src/pocketmine/plugin/PluginBase.php b/src/pocketmine/plugin/PluginBase.php index d2804ff29..6aec80525 100644 --- a/src/pocketmine/plugin/PluginBase.php +++ b/src/pocketmine/plugin/PluginBase.php @@ -218,7 +218,7 @@ abstract class PluginBase implements Plugin{ * @return string[] */ public function getResources(){ - $resources = array(); + $resources = []; if(is_dir($this->file . "resources/")){ foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->file . "resources/")) as $resource){ $resources[] = $resource; diff --git a/src/pocketmine/plugin/PluginDescription.php b/src/pocketmine/plugin/PluginDescription.php index 85e98bd30..efdd5ac10 100644 --- a/src/pocketmine/plugin/PluginDescription.php +++ b/src/pocketmine/plugin/PluginDescription.php @@ -27,13 +27,13 @@ class PluginDescription{ private $name; private $main; private $api; - private $depend = array(); - private $softDepend = array(); - private $loadBefore = array(); + private $depend = []; + private $softDepend = []; + private $loadBefore = []; private $version; - private $commands = array(); + private $commands = []; private $description = null; - private $authors = array(); + private $authors = []; private $website = null; private $prefix = null; private $order = PluginLoadOrder::POSTWORLD; @@ -41,7 +41,7 @@ class PluginDescription{ /** * @var Permission[] */ - private $permissions = array(); + private $permissions = []; /** * @param string $yamlString @@ -100,7 +100,7 @@ class PluginDescription{ $this->order = constant("pocketmine\\plugin\\PluginLoadOrder::" . $order); } } - $this->authors = array(); + $this->authors = []; if(isset($plugin["author"])){ $this->authors[] = $plugin["author"]; } diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index a41cea68a..b81f44979 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -45,12 +45,12 @@ class PluginManager{ /** * @var Plugin[] */ - protected $plugins = array(); + protected $plugins = []; /** * @var Permission[] */ - protected $permissions = array(); + protected $permissions = []; /** * @var Permission[] @@ -65,7 +65,7 @@ class PluginManager{ /** * @var Permissible[] */ - protected $permSubs = array(); + protected $permSubs = []; /** * @var Permissible[] @@ -80,7 +80,7 @@ class PluginManager{ /** * @var PluginLoader[] */ - protected $fileAssociations = array(); + protected $fileAssociations = []; /** * @param Server $server @@ -166,12 +166,12 @@ class PluginManager{ public function loadPlugins($directory, $newLoaders = null){ if(is_dir($directory)){ - $plugins = array(); - $loadedPlugins = array(); - $dependencies = array(); - $softDependencies = array(); + $plugins = []; + $loadedPlugins = []; + $dependencies = []; + $softDependencies = []; if(is_array($newLoaders)){ - $loaders = array(); + $loaders = []; foreach($newLoaders as $key){ if(isset($this->fileAssociations[$key])){ $loaders[$key] = $this->fileAssociations[$key]; @@ -302,14 +302,14 @@ class PluginManager{ foreach($plugins as $name => $file){ console("[SEVERE] Could not load plugin '" . $name . "': circular dependency detected"); } - $plugins = array(); + $plugins = []; } } } return $loadedPlugins; }else{ - return array(); + return []; } } @@ -432,7 +432,7 @@ class PluginManager{ return $this->permSubs[$permission]; } - return array(); + return []; } /** @@ -512,7 +512,7 @@ class PluginManager{ * @return PluginCommand[] */ protected function parseYamlCommands(Plugin $plugin){ - $pluginCmds = array(); + $pluginCmds = []; foreach($plugin->getDescription()->getCommands() as $key => $data){ if(strpos($key, ":") !== false){ @@ -530,7 +530,7 @@ class PluginManager{ } if(isset($data["aliases"]) and is_array($data["aliases"])){ - $aliasList = array(); + $aliasList = []; foreach($data["aliases"] as $alias){ if(strpos($alias, ":") !== false){ console("[SEVERE] Could not load alias " . $alias . " for plugin " . $plugin->getDescription()->getName()); @@ -579,11 +579,11 @@ class PluginManager{ public function clearPlugins(){ $this->disablePlugins(); - $this->plugins = array(); - $this->fileAssociations = array(); - $this->permissions = array(); - $this->defaultPerms = array(); - $this->defaultPermsOp = array(); + $this->plugins = []; + $this->fileAssociations = []; + $this->permissions = []; + $this->defaultPerms = []; + $this->defaultPermsOp = []; } /** diff --git a/src/pocketmine/recipes/Crafting.php b/src/pocketmine/recipes/Crafting.php index bd6843854..438ddc589 100644 --- a/src/pocketmine/recipes/Crafting.php +++ b/src/pocketmine/recipes/Crafting.php @@ -28,7 +28,7 @@ use pocketmine\item\Item; abstract class Crafting{ - private static $lookupTable = array(); + private static $lookupTable = []; private static $small = array( //Probably means craftable on crafting bench and in inventory. Name it better! //Building @@ -221,11 +221,11 @@ abstract class Crafting{ "COBBLESTONE:?x6=>COBBLESTONE_STAIRS:0x4", ); - private static $recipes = array(); + private static $recipes = []; private static function parseRecipe($recipe){ $recipe = explode("=>", $recipe); - $recipeItems = array(); + $recipeItems = []; foreach(explode(",", $recipe[0]) as $item){ $item = explode("x", $item); $id = explode(":", $item[0]); @@ -257,34 +257,34 @@ abstract class Crafting{ public static function init(){ $id = 1; - self::$lookupTable[0] = array(); + self::$lookupTable[0] = []; foreach(self::$small as $recipe){ $recipe = self::parseRecipe($recipe); self::$recipes[$id] = $recipe; if(!isset(self::$lookupTable[0][$recipe[2]])){ - self::$lookupTable[0][$recipe[2]] = array(); + self::$lookupTable[0][$recipe[2]] = []; } self::$lookupTable[0][$recipe[2]][] = $id; ++$id; } - self::$lookupTable[1] = array(); + self::$lookupTable[1] = []; foreach(self::$big as $recipe){ $recipe = self::parseRecipe($recipe); self::$recipes[$id] = $recipe; if(!isset(self::$lookupTable[1][$recipe[2]])){ - self::$lookupTable[1][$recipe[2]] = array(); + self::$lookupTable[1][$recipe[2]] = []; } self::$lookupTable[1][$recipe[2]][] = $id; ++$id; } - self::$lookupTable[2] = array(); + self::$lookupTable[2] = []; foreach(self::$stone as $recipe){ $recipe = self::parseRecipe($recipe); self::$recipes[$id] = $recipe; if(!isset(self::$lookupTable[2][$recipe[2]])){ - self::$lookupTable[2][$recipe[2]] = array(); + self::$lookupTable[2][$recipe[2]] = []; } self::$lookupTable[2][$recipe[2]][] = $id; ++$id; diff --git a/src/pocketmine/scheduler/CallbackTask.php b/src/pocketmine/scheduler/CallbackTask.php index d8e2771a6..cc3a7668e 100644 --- a/src/pocketmine/scheduler/CallbackTask.php +++ b/src/pocketmine/scheduler/CallbackTask.php @@ -39,7 +39,7 @@ class CallbackTask extends Task{ * @param callable $callable * @param array $args */ - public function __construct(callable $callable, array $args = array()){ + public function __construct(callable $callable, array $args = []){ $this->callable = $callable; $this->args = $args; $this->args[] = $this; diff --git a/src/pocketmine/scheduler/ServerScheduler.php b/src/pocketmine/scheduler/ServerScheduler.php index 97a1b3665..a76b2c5de 100644 --- a/src/pocketmine/scheduler/ServerScheduler.php +++ b/src/pocketmine/scheduler/ServerScheduler.php @@ -37,7 +37,7 @@ class ServerScheduler{ /** * @var TaskHandler[] */ - protected $tasks = array(); + protected $tasks = []; /** @var \Pool */ protected $asyncPool; @@ -134,7 +134,7 @@ class ServerScheduler{ foreach($this->tasks as $task){ $task->cancel(); } - $this->tasks = array(); + $this->tasks = []; $this->asyncPool->shutdown(); $this->asyncTasks = 0; } diff --git a/src/pocketmine/tile/Container.php b/src/pocketmine/tile/Container.php index 589fbe5b5..13bf81c7b 100644 --- a/src/pocketmine/tile/Container.php +++ b/src/pocketmine/tile/Container.php @@ -62,7 +62,7 @@ trait Container{ $pk->y = $this->y; $pk->z = $this->z; $player->dataPacket($pk); - $slots = array(); + $slots = []; if(is_array($player->windows[$id])){ $all = $this->getLevel()->getPlayers(); @@ -121,7 +121,7 @@ trait Container{ $pk->z = $this->z; $player->dataPacket($pk); - $slots = array(); + $slots = []; for($s = 0; $s < Furnace::SLOTS; ++$s){ $slot = $this->getSlot($s); if($slot->getID() > Item::AIR and $slot->getCount() > 0){ diff --git a/src/pocketmine/tile/Tile.php b/src/pocketmine/tile/Tile.php index 15b4648d6..4a1918e06 100644 --- a/src/pocketmine/tile/Tile.php +++ b/src/pocketmine/tile/Tile.php @@ -41,12 +41,12 @@ abstract class Tile extends Position{ /** * @var Tile[] */ - public static $list = array(); + public static $list = []; /** * @var Tile[] */ - public static $needUpdate = array(); + public static $needUpdate = []; public $chunkIndex; public $name; diff --git a/src/pocketmine/utils/Binary.php b/src/pocketmine/utils/Binary.php index 0a9bd6f7f..901ad2dfd 100644 --- a/src/pocketmine/utils/Binary.php +++ b/src/pocketmine/utils/Binary.php @@ -113,7 +113,7 @@ class Binary{ */ public static function readMetadata($value, $types = false){ $offset = 0; - $m = array(); + $m = []; $b = ord($value{$offset}); ++$offset; while($b !== 127 and isset($value{$offset})){ @@ -143,7 +143,7 @@ class Binary{ $offset += $len; break; case 5: - $r = array(); + $r = []; $r[] = self::readLShort(substr($value, $offset, 2)); $offset += 2; $r[] = ord($value{$offset}); @@ -152,7 +152,7 @@ class Binary{ $offset += 2; break; case 6: - $r = array(); + $r = []; for($i = 0; $i < 3; ++$i){ $r[] = self::readLInt(substr($value, $offset, 4)); $offset += 4; diff --git a/src/pocketmine/utils/Cache.php b/src/pocketmine/utils/Cache.php index 8733a31c2..ee5e6a6ad 100644 --- a/src/pocketmine/utils/Cache.php +++ b/src/pocketmine/utils/Cache.php @@ -23,7 +23,7 @@ namespace pocketmine\utils; class Cache{ - public static $cached = array(); + public static $cached = []; /** * Adds something to the cache diff --git a/src/pocketmine/utils/Config.php b/src/pocketmine/utils/Config.php index 894a0736d..dbb53bfd8 100644 --- a/src/pocketmine/utils/Config.php +++ b/src/pocketmine/utils/Config.php @@ -71,7 +71,7 @@ class Config{ * @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){ + public function __construct($file, $type = Config::DETECT, $default = [], &$correct = null){ $this->load($file, $type, $default); $correct = $this->correct; } @@ -102,12 +102,12 @@ class Config{ * * @return bool */ - public function load($file, $type = Config::DETECT, $default = array()){ + public function load($file, $type = Config::DETECT, $default = []){ $this->correct = true; $this->type = (int) $type; $this->file = $file; if(!is_array($default)){ - $default = array(); + $default = []; } if(!file_exists($file)){ $this->config = $default; @@ -275,7 +275,7 @@ class Config{ $final = array_pop($components); foreach($components as $component){ if(!isset($currPath[$component])){ - $currPath[$component] = array(); + $currPath[$component] = []; } $currPath =& $currPath[$component]; } @@ -347,7 +347,7 @@ class Config{ foreach($default as $k => $v){ if(is_array($v)){ if(!isset($data[$k]) or !is_array($data[$k])){ - $data[$k] = array(); + $data[$k] = []; } $changed += $this->fillDefaults($v, $data[$k]); }elseif(!isset($data[$k])){ diff --git a/src/pocketmine/wizard/InstallerLang.php b/src/pocketmine/wizard/InstallerLang.php index fc8c3bee9..08567f611 100644 --- a/src/pocketmine/wizard/InstallerLang.php +++ b/src/pocketmine/wizard/InstallerLang.php @@ -42,7 +42,7 @@ class InstallerLang{ "tr" => "Türkçe", //"et" => "Eesti", ); - private $texts = array(); + private $texts = []; private $lang; private $langfile; @@ -53,7 +53,7 @@ class InstallerLang{ }else{ $l = glob(\pocketmine\PATH . "src/lang/Installer/" . $lang . "_*.ini"); if(count($l) > 0){ - $files = array(); + $files = []; foreach($l as $file){ $files[$file] = filesize($file); } @@ -81,7 +81,7 @@ class InstallerLang{ } public function loadLang($langfile, $lang = "en"){ - $this->texts[$lang] = array(); + $this->texts[$lang] = []; $texts = explode("\n", str_replace(array("\r", "\/\/"), array("", "//"), file_get_contents($langfile))); foreach($texts as $line){ $line = trim($line); @@ -93,7 +93,7 @@ class InstallerLang{ } } - public function get($name, $search = array(), $replace = array()){ + public function get($name, $search = [], $replace = []){ if(!isset($this->texts[$this->lang][$name])){ if($this->lang !== "en" and isset($this->texts["en"][$name])){ return $this->texts["en"][$name]; diff --git a/src/spl/SplClassLoader.php b/src/spl/SplClassLoader.php index 85b7cddfc..2f2dfa2fd 100644 --- a/src/spl/SplClassLoader.php +++ b/src/spl/SplClassLoader.php @@ -50,7 +50,7 @@ class SplClassLoader implements SplAutoloader{ private $includePathLookup = false; /** @var array */ - private $resources = array(); + private $resources = []; /** @var integer */ private $mode = self::MODE_NORMAL; diff --git a/src/stubs/pthreads.php b/src/stubs/pthreads.php index 63c1589d2..715241bb9 100644 --- a/src/stubs/pthreads.php +++ b/src/stubs/pthreads.php @@ -629,7 +629,7 @@ class Pool{ * * @link http://www.php.net/manual/en/pool.__construct.php */ - public function __construct($size, $class, array $ctor = array()){ + public function __construct($size, $class, array $ctor = []){ } /** diff --git a/src/stubs/uopz.php b/src/stubs/uopz.php index a059dc480..feaa5f10a 100644 --- a/src/stubs/uopz.php +++ b/src/stubs/uopz.php @@ -153,7 +153,7 @@ function uopz_backup($name, $classMethod = null){} * @param array $properties An associative array of properties, keys are names, values are modifiers * @param int $flags Entry type, by default ZEND_ACC_CLASS */ -function uopz_compose($name, array $classes, array $methods = array(), array $properties = array(), $flags = ZEND_USER_ACC_CLASS){} +function uopz_compose($name, array $classes, array $methods = [], array $properties = [], $flags = ZEND_USER_ACC_CLASS){} /** * Copy a function by name diff --git a/src/stubs/yaml.php b/src/stubs/yaml.php index f2f2e6a06..a272109f1 100644 --- a/src/stubs/yaml.php +++ b/src/stubs/yaml.php @@ -46,7 +46,7 @@ define("YAML_CRLN_BREAK", 3); * @link http://www.php.net/manual/en/function.yaml-emit-file.php * @return bool */ -function yaml_emit_file($filename, $data, $encoding = YAML_ANY_ENCODING, $linebreak = YAML_ANY_BREAK, array $callbacks = array()){ +function yaml_emit_file($filename, $data, $encoding = YAML_ANY_ENCODING, $linebreak = YAML_ANY_BREAK, array $callbacks = []){ } /** @@ -60,7 +60,7 @@ function yaml_emit_file($filename, $data, $encoding = YAML_ANY_ENCODING, $linebr * @link http://www.php.net/manual/en/function.yaml-emit.php * @return string */ -function yaml_emit($data, $encoding = YAML_ANY_ENCODING, $linebreak = YAML_ANY_BREAK, array $callbacks = array()){ +function yaml_emit($data, $encoding = YAML_ANY_ENCODING, $linebreak = YAML_ANY_BREAK, array $callbacks = []){ } /** @@ -74,7 +74,7 @@ function yaml_emit($data, $encoding = YAML_ANY_ENCODING, $linebreak = YAML_ANY_B * @link http://www.php.net/manual/en/function.yaml-parse-file.php * @return mixed */ -function yaml_parse_file($filename, $pos = 0, &$ndocs = null, array $callbacks = array()){ +function yaml_parse_file($filename, $pos = 0, &$ndocs = null, array $callbacks = []){ } /** @@ -88,7 +88,7 @@ function yaml_parse_file($filename, $pos = 0, &$ndocs = null, array $callbacks = * @link http://www.php.net/manual/en/function.yaml-parse-url.php * @return mixed */ -function yaml_parse_url($url, $pos = 0, &$ndocs = null, array $callbacks = array()){ +function yaml_parse_url($url, $pos = 0, &$ndocs = null, array $callbacks = []){ } /** @@ -102,5 +102,5 @@ function yaml_parse_url($url, $pos = 0, &$ndocs = null, array $callbacks = array * @link http://www.php.net/manual/en/function.yaml-parse.php * @return mixed */ -function yaml_parse($input, $pos = 0, &$ndocs = null, array $callbacks = array()){ +function yaml_parse($input, $pos = 0, &$ndocs = null, array $callbacks = []){ } \ No newline at end of file