Added Inventory interfaces and types, updated long array() to []

This commit is contained in:
Shoghi Cervantes 2014-05-22 18:59:16 +02:00
parent 0be679c9d5
commit 6cbd39de9b
102 changed files with 637 additions and 334 deletions

View File

@ -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. * Files MUST NOT have an ending `?>` tag.
* Code MUST use namespaces. * Code MUST use namespaces.
* Strings SHOULD use the double quote `"` except when the single quote is required. * 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. * Argument lists MAY NOT be split across multiple lines, except long arrays.
```php ```php

View File

@ -33,7 +33,7 @@ abstract class Achievement{
public static $list = array( public static $list = array(
/*"openInventory" => array( /*"openInventory" => array(
"name" => "Taking Inventory", "name" => "Taking Inventory",
"requires" => array(), "requires" => [],
),*/ ),*/
"mineWood" => array( "mineWood" => array(
"name" => "Getting Wood", "name" => "Getting Wood",
@ -118,7 +118,7 @@ abstract class Achievement{
return false; return false;
} }
public static function add($achievementId, $achievementName, array $requires = array()){ public static function add($achievementId, $achievementName, array $requires = []){
if(!isset(Achievement::$list[$achievementId])){ if(!isset(Achievement::$list[$achievementId])){
Achievement::$list[$achievementId] = array( Achievement::$list[$achievementId] = array(
"name" => $achievementName, "name" => $achievementName,

View File

@ -103,15 +103,15 @@ class Player extends Human implements CommandSender, IPlayer{
public $gamemode; public $gamemode;
public $lastBreak; public $lastBreak;
public $windowCnt = 2; public $windowCnt = 2;
public $windows = array(); public $windows = [];
public $blocked = true; public $blocked = true;
public $achievements = array(); public $achievements = [];
public $chunksLoaded = array(); public $chunksLoaded = [];
public $lastCorrect; public $lastCorrect;
public $craftingItems = array(); public $craftingItems = [];
public $toCraft = array(); public $toCraft = [];
public $lastCraft = 0; public $lastCraft = 0;
public $loginData = array(); public $loginData = [];
protected $lastMovement = 0; protected $lastMovement = 0;
protected $forceMovement = false; protected $forceMovement = false;
protected $connected = true; protected $connected = true;
@ -123,13 +123,13 @@ class Player extends Human implements CommandSender, IPlayer{
protected $displayName; protected $displayName;
protected $startAction = false; protected $startAction = false;
protected $sleeping = false; protected $sleeping = false;
protected $chunksOrder = array(); protected $chunksOrder = [];
/** @var Player[] */ /** @var Player[] */
protected $hiddenPlayers = array(); protected $hiddenPlayers = [];
private $recoveryQueue = array(); private $recoveryQueue = [];
private $receiveQueue = array(); private $receiveQueue = [];
private $resendQueue = array(); private $resendQueue = [];
private $ackQueue = array(); private $ackQueue = [];
private $receiveCount = -1; private $receiveCount = -1;
/** @var \pocketmine\network\raknet\Packet */ /** @var \pocketmine\network\raknet\Packet */
private $buffer; private $buffer;
@ -141,7 +141,7 @@ class Player extends Human implements CommandSender, IPlayer{
private $lastMeasure = 0; private $lastMeasure = 0;
private $bandwidthRaw = 0; private $bandwidthRaw = 0;
private $bandwidthStats = array(0, 0, 0); private $bandwidthStats = array(0, 0, 0);
private $lag = array(); private $lag = [];
private $lagStat = 0; private $lagStat = 0;
private $spawnPosition; private $spawnPosition;
private $packetLoss = 0; private $packetLoss = 0;
@ -150,13 +150,13 @@ class Player extends Human implements CommandSender, IPlayer{
private $inAction = false; private $inAction = false;
private $bigCnt; private $bigCnt;
private $packetStats; private $packetStats;
private $chunkCount = array(); private $chunkCount = [];
private $received = array(); private $received = [];
/** /**
* @var \pocketmine\scheduler\TaskHandler[] * @var \pocketmine\scheduler\TaskHandler[]
*/ */
private $tasks = array(); private $tasks = [];
/** @var PermissibleBase */ /** @var PermissibleBase */
private $perm = null; 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->hotbar = array(0, -1, -1, -1, -1, -1, -1, -1, -1);
$this->packetStats = array(0, 0); $this->packetStats = array(0, 0);
$this->buffer = new Packet(Info::DATA_PACKET_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, "handlePacketQueues")), 1);
$this->tasks[] = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask(array($this, "clearQueue")), 20 * 60); $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); 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){ public function hasAchievement($achievementId){
if(!isset(Achievement::$list[$achievementId]) or !isset($this->achievements)){ if(!isset(Achievement::$list[$achievementId]) or !isset($this->achievements)){
$this->achievements = array(); $this->achievements = [];
return false; return false;
} }
@ -565,7 +565,7 @@ class Player extends Human implements CommandSender, IPlayer{
if($cnt === false){ if($cnt === false){
return false; return false;
} }
$this->chunkCount = array(); $this->chunkCount = [];
foreach($cnt as $i => $count){ foreach($cnt as $i => $count){
$this->chunkCount[$count] = true; $this->chunkCount[$count] = true;
} }
@ -590,7 +590,7 @@ class Player extends Human implements CommandSender, IPlayer{
return false; return false;
} }
$newOrder = array(); $newOrder = [];
$lastChunk = $this->chunksLoaded; $lastChunk = $this->chunksLoaded;
$centerX = $this->x >> 4; $centerX = $this->x >> 4;
$centerZ = $this->z >> 4; $centerZ = $this->z >> 4;
@ -672,7 +672,7 @@ class Player extends Human implements CommandSender, IPlayer{
@$this->buffer->data[] = $packet; @$this->buffer->data[] = $packet;
$this->bufferLen += 6 + $len; $this->bufferLen += 6 + $len;
return array(); return [];
} }
private function directBigRawPacket(DataPacket $packet){ private function directBigRawPacket(DataPacket $packet){
@ -686,7 +686,7 @@ class Player extends Human implements CommandSender, IPlayer{
$buffer = str_split($packet->buffer, $size); $buffer = str_split($packet->buffer, $size);
$bigCnt = $this->bigCnt; $bigCnt = $this->bigCnt;
$this->bigCnt = ($this->bigCnt + 1) % 0x10000; $this->bigCnt = ($this->bigCnt + 1) % 0x10000;
$cnts = array(); $cnts = [];
$bufCount = count($buffer); $bufCount = count($buffer);
foreach($buffer as $i => $buf){ foreach($buffer as $i => $buf){
$cnts[] = $count = $this->counter[0]++; $cnts[] = $count = $this->counter[0]++;
@ -742,7 +742,7 @@ class Player extends Human implements CommandSender, IPlayer{
} }
$this->bufferLen = 0; $this->bufferLen = 0;
$this->buffer = new Packet(Info::DATA_PACKET_0); $this->buffer = new Packet(Info::DATA_PACKET_0);
$this->buffer->data = array(); $this->buffer->data = [];
$this->nextBuffer = microtime(true) + 0.1; $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->bandwidthStats[] = $this->bandwidthRaw / max(0.00001, microtime(true) - $this->lastMeasure);
$this->bandwidthRaw = 0; $this->bandwidthRaw = 0;
$this->lagStat = array_sum($this->lag) / max(1, count($this->lag)); $this->lagStat = array_sum($this->lag) / max(1, count($this->lag));
$this->lag = array(); $this->lag = [];
$this->sendBuffer(); $this->sendBuffer();
$this->lastMeasure = microtime(true); $this->lastMeasure = microtime(true);
} }
@ -1141,7 +1141,7 @@ class Player extends Human implements CommandSender, IPlayer{
$packetCnt = (int) ($ackCnt / $safeCount + 1); $packetCnt = (int) ($ackCnt / $safeCount + 1);
for($p = 0; $p < $packetCnt; ++$p){ for($p = 0; $p < $packetCnt; ++$p){
$pk = new Packet(Info::ACK); $pk = new Packet(Info::ACK);
$pk->packets = array(); $pk->packets = [];
for($c = 0; $c < $safeCount; ++$c){ for($c = 0; $c < $safeCount; ++$c){
if(($k = array_pop($this->ackQueue)) === null){ if(($k = array_pop($this->ackQueue)) === null){
break; break;
@ -1150,7 +1150,7 @@ class Player extends Human implements CommandSender, IPlayer{
} }
$this->send($pk); $this->send($pk);
} }
$this->ackQueue = array(); $this->ackQueue = [];
} }
if(($receiveCnt = count($this->receiveQueue)) > 0){ if(($receiveCnt = count($this->receiveQueue)) > 0){
@ -1350,7 +1350,7 @@ class Player extends Human implements CommandSender, IPlayer{
return; return;
} }
$this->achievements = array(); $this->achievements = [];
foreach($nbt->Achievements as $achievement){ foreach($nbt->Achievements as $achievement){
$this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false; $this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false;
} }
@ -1559,8 +1559,8 @@ class Player extends Human implements CommandSender, IPlayer{
$this->dataPacket($pk); $this->dataPacket($pk);
break; break;
} }
$this->craftingItems = array(); $this->craftingItems = [];
$this->toCraft = array(); $this->toCraft = [];
$packet->eid = $this->id; $packet->eid = $this->id;
if($packet->face >= 0 and $packet->face <= 5){ //Use Block, place if($packet->face >= 0 and $packet->face <= 5){ //Use Block, place
@ -1618,8 +1618,8 @@ class Player extends Human implements CommandSender, IPlayer{
break; break;
} }
$packet->eid = $this->id; $packet->eid = $this->id;
$this->craftingItems = array(); $this->craftingItems = [];
$this->toCraft = array(); $this->toCraft = [];
switch($packet->action){ switch($packet->action){
case 5: //Shot arrow case 5: //Shot arrow
@ -1693,8 +1693,8 @@ class Player extends Human implements CommandSender, IPlayer{
if($this->spawned === false or $this->blocked === true){ if($this->spawned === false or $this->blocked === true){
break; break;
} }
$this->craftingItems = array(); $this->craftingItems = [];
$this->toCraft = array(); $this->toCraft = [];
$vector = new Vector3($packet->x, $packet->y, $packet->z); $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){ if($this->spawned === false or $this->blocked === true){
break; break;
} }
$this->craftingItems = array(); $this->craftingItems = [];
$this->toCraft = array(); $this->toCraft = [];
for($i = 0; $i < 4; ++$i){ for($i = 0; $i < 4; ++$i){
$s = $packet->slots[$i]; $s = $packet->slots[$i];
@ -1774,12 +1774,12 @@ class Player extends Human implements CommandSender, IPlayer{
break; break;
} }
$packet->eid = $this->id; $packet->eid = $this->id;
$data = array(); $data = [];
$data["target"] = $packet->target; $data["target"] = $packet->target;
$data["eid"] = $packet->eid; $data["eid"] = $packet->eid;
$data["action"] = $packet->action; $data["action"] = $packet->action;
$this->craftingItems = array(); $this->craftingItems = [];
$this->toCraft = array(); $this->toCraft = [];
$target = Entity::get($packet->target); $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){ 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; $data["targetentity"] = $target;
@ -1869,8 +1869,8 @@ class Player extends Human implements CommandSender, IPlayer{
if($this->spawned === false or $this->dead === false){ if($this->spawned === false or $this->dead === false){
break; break;
} }
$this->craftingItems = array(); $this->craftingItems = [];
$this->toCraft = array(); $this->toCraft = [];
$this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->spawnPosition)); $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){ if($this->spawned === false or $this->blocked === true){
break; break;
} }
$this->craftingItems = array(); $this->craftingItems = [];
$this->toCraft = array(); $this->toCraft = [];
$packet->eid = $this->id; $packet->eid = $this->id;
if($this->entity->inAction === true){ if($this->entity->inAction === true){
$this->entity->inAction = false; $this->entity->inAction = false;
@ -1945,9 +1945,9 @@ class Player extends Human implements CommandSender, IPlayer{
} }
$packet->eid = $this->id; $packet->eid = $this->id;
$packet->item = $this->getSlot($this->getCurrentEquipment()); $packet->item = $this->getSlot($this->getCurrentEquipment());
$this->craftingItems = array(); $this->craftingItems = [];
$this->toCraft = array(); $this->toCraft = [];
$data = array(); $data = [];
$data["eid"] = $packet->eid; $data["eid"] = $packet->eid;
$data["unknown"] = $packet->unknown; $data["unknown"] = $packet->unknown;
$data["item"] = $packet->item; $data["item"] = $packet->item;
@ -1965,8 +1965,8 @@ class Player extends Human implements CommandSender, IPlayer{
if($this->spawned === false){ if($this->spawned === false){
break; break;
} }
$this->craftingItems = array(); $this->craftingItems = [];
$this->toCraft = array(); $this->toCraft = [];
$packet->message = TextFormat::clean($packet->message); $packet->message = TextFormat::clean($packet->message);
if(trim($packet->message) != "" and strlen($packet->message) <= 255){ if(trim($packet->message) != "" and strlen($packet->message) <= 255){
$message = $packet->message; $message = $packet->message;
@ -1988,8 +1988,8 @@ class Player extends Human implements CommandSender, IPlayer{
if($this->spawned === false){ if($this->spawned === false){
break; break;
} }
$this->craftingItems = array(); $this->craftingItems = [];
$this->toCraft = array(); $this->toCraft = [];
if(isset($this->windows[$packet->windowid])){ if(isset($this->windows[$packet->windowid])){
if(is_array($this->windows[$packet->windowid])){ if(is_array($this->windows[$packet->windowid])){
foreach($this->windows[$packet->windowid] as $ob){ foreach($this->windows[$packet->windowid] as $ob){
@ -2026,9 +2026,9 @@ class Player extends Human implements CommandSender, IPlayer{
if(isset($this->toCraft[-1])){ if(isset($this->toCraft[-1])){
$this->toCraft = array(-1 => $this->toCraft[-1]); $this->toCraft = array(-1 => $this->toCraft[-1]);
}else{ }else{
$this->toCraft = array(); $this->toCraft = [];
} }
$this->craftingItems = array(); $this->craftingItems = [];
} }
if($packet->windowid === 0){ 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($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){ if($recipe === false){
$this->sendInventory(); $this->sendInventory();
$this->toCraft = array(); $this->toCraft = [];
}else{ }else{
$this->toCraft = array(-1 => $this->toCraft[-1]); $this->toCraft = array(-1 => $this->toCraft[-1]);
} }
$this->craftingItems = array(); $this->craftingItems = [];
} }
}else{ }else{
$this->toCraft = array(); $this->toCraft = [];
$this->craftingItems = array(); $this->craftingItems = [];
} }
if(!isset($this->windows[$packet->windowid])){ if(!isset($this->windows[$packet->windowid])){
break; break;
@ -2206,8 +2206,8 @@ class Player extends Human implements CommandSender, IPlayer{
if($this->spawned === false or $this->blocked === true){ if($this->spawned === false or $this->blocked === true){
break; break;
} }
$this->craftingItems = array(); $this->craftingItems = [];
$this->toCraft = array(); $this->toCraft = [];
$t = $this->getLevel()->getTile(new Vector3($packet->x, $packet->y, $packet->z)); $t = $this->getLevel()->getTile(new Vector3($packet->x, $packet->y, $packet->z));
if($t instanceof Sign){ if($t instanceof Sign){
if($t->namedtag->creator !== $this->username){ if($t->namedtag->creator !== $this->username){
@ -2307,11 +2307,11 @@ class Player extends Human implements CommandSender, IPlayer{
foreach($this->tasks as $task){ foreach($this->tasks as $task){
$task->cancel(); $task->cancel();
} }
$this->tasks = array(); $this->tasks = [];
$this->recoveryQueue = array(); $this->recoveryQueue = [];
$this->receiveQueue = array(); $this->receiveQueue = [];
$this->resendQueue = array(); $this->resendQueue = [];
$this->ackQueue = array(); $this->ackQueue = [];
if(isset($ev) and $this->username != "" and $this->spawned !== false and $ev->getQuitMessage() != ""){ if(isset($ev) and $this->username != "" and $this->spawned !== false and $ev->getQuitMessage() != ""){
$this->server->broadcastMessage($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->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
$this->spawned = false; $this->spawned = false;
console("[INFO] " . TextFormat::AQUA . $this->username . TextFormat::RESET . "[/" . $this->ip . ":" . $this->port . "] logged out due to " . $reason); console("[INFO] " . TextFormat::AQUA . $this->username . TextFormat::RESET . "[/" . $this->ip . ":" . $this->port . "] logged out due to " . $reason);
$this->windows = array(); $this->windows = [];
$this->armor = array(); $this->armor = [];
$this->inventory = array(); $this->inventory = [];
$this->chunksLoaded = array(); $this->chunksLoaded = [];
$this->chunksOrder = array(); $this->chunksOrder = [];
$this->chunkCount = array(); $this->chunkCount = [];
$this->craftingItems = array(); $this->craftingItems = [];
$this->received = array(); $this->received = [];
$this->buffer = null; $this->buffer = null;
unset($this->buffer); unset($this->buffer);
} }
@ -2372,7 +2372,7 @@ class Player extends Human implements CommandSender, IPlayer{
$this->server->getPluginManager()->callEvent($ev = new DataPacketSendEvent($this, $packet)); $this->server->getPluginManager()->callEvent($ev = new DataPacketSendEvent($this, $packet));
if($ev->isCancelled()){ if($ev->isCancelled()){
return array(); return [];
} }
$packet->encode(); $packet->encode();
$pk = new Packet(Info::DATA_PACKET_0); $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){ foreach($recipe as $item){
if(!isset($recipeItems[$item->getID()])){ if(!isset($recipeItems[$item->getID()])){
$recipeItems[$item->getID()] = array($item->getID(), $item->getDamage(), $item->getCount()); $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){ if(($this->gamemode & 0x01) === 1){
return; return;
} }
$hotbar = array(); $hotbar = [];
foreach($this->hotbar as $slot){ foreach($this->hotbar as $slot){
$hotbar[] = $slot <= -1 ? -1 : $slot + 9; $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_E:
case Info::DATA_PACKET_F: case Info::DATA_PACKET_F:
$this->ackQueue[] = $packet->seqNumber; $this->ackQueue[] = $packet->seqNumber;
$this->receiveQueue[$packet->seqNumber] = array(); $this->receiveQueue[$packet->seqNumber] = [];
foreach($packet->data as $pk){ foreach($packet->data as $pk){
$this->receiveQueue[$packet->seqNumber][] = $pk; $this->receiveQueue[$packet->seqNumber][] = $pk;
} }

View File

@ -226,7 +226,7 @@ namespace pocketmine {
function getTrace($start = 1){ function getTrace($start = 1){
$e = new \Exception(); $e = new \Exception();
$trace = $e->getTrace(); $trace = $e->getTrace();
$messages = array(); $messages = [];
$j = 0; $j = 0;
for($i = (int) $start; isset($trace[$i]); ++$i, ++$j){ for($i = (int) $start; isset($trace[$i]); ++$i, ++$j){
$params = ""; $params = "";
@ -277,7 +277,7 @@ namespace pocketmine {
if((!defined("pocketmine\\DEBUG") or \pocketmine\DEBUG >= $level) and (!defined("pocketmine\\LOG") or \pocketmine\LOG === true)){ if((!defined("pocketmine\\DEBUG") or \pocketmine\DEBUG >= $level) and (!defined("pocketmine\\LOG") or \pocketmine\LOG === true)){
$message .= $EOL === true ? PHP_EOL : ""; $message .= $EOL === true ? PHP_EOL : "";
if(!isset($fpointers)){ if(!isset($fpointers)){
$fpointers = array(); $fpointers = [];
} }
if(!isset($fpointers[$name]) or $fpointers[$name] === false){ if(!isset($fpointers[$name]) or $fpointers[$name] === false){
$fpointers[$name] = @fopen(\pocketmine\DATA . "/" . $name . ".log", "ab"); $fpointers[$name] = @fopen(\pocketmine\DATA . "/" . $name . ".log", "ab");

View File

@ -39,6 +39,7 @@ use pocketmine\event\HandlerList;
use pocketmine\event\server\PacketReceiveEvent; use pocketmine\event\server\PacketReceiveEvent;
use pocketmine\event\server\PacketSendEvent; use pocketmine\event\server\PacketSendEvent;
use pocketmine\event\server\ServerCommandEvent; use pocketmine\event\server\ServerCommandEvent;
use pocketmine\inventory\InventoryType;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\level\generator\Flat; use pocketmine\level\generator\Flat;
use pocketmine\level\generator\Generator; use pocketmine\level\generator\Generator;
@ -171,10 +172,10 @@ class Server{
private $properties; private $properties;
/** @var Player[] */ /** @var Player[] */
private $players = array(); private $players = [];
/** @var Level[] */ /** @var Level[] */
private $levels = array(); private $levels = [];
/** @var Level */ /** @var Level */
private $levelDefault = null; private $levelDefault = null;
@ -551,8 +552,8 @@ class Server{
new Int("SpawnY", (int) $spawn->y), new Int("SpawnY", (int) $spawn->y),
new Int("SpawnZ", (int) $spawn->z), new Int("SpawnZ", (int) $spawn->z),
new Byte("SpawnForced", 1), //TODO new Byte("SpawnForced", 1), //TODO
new Enum("Inventory", array()), new Enum("Inventory", []),
new Compound("Achievements", array()), new Compound("Achievements", []),
new Int("playerGameType", $this->getGamemode()), new Int("playerGameType", $this->getGamemode()),
new Enum("Motion", array( new Enum("Motion", array(
new Double(0, 0.0), new Double(0, 0.0),
@ -576,7 +577,7 @@ class Server{
$nbt->Rotation->setTagType(NBT::TAG_Float); $nbt->Rotation->setTagType(NBT::TAG_Float);
if(file_exists($path . "$name.yml")){ //Importing old PocketMine-MP files 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["playerGameType"] = (int) $data->get("gamemode");
$nbt["Level"] = $data->get("position")["level"]; $nbt["Level"] = $data->get("position")["level"];
$nbt["Pos"][0] = $data->get("position")["x"]; $nbt["Pos"][0] = $data->get("position")["x"];
@ -696,7 +697,7 @@ class Server{
*/ */
public function matchPlayer($partialName){ public function matchPlayer($partialName){
$partialName = strtolower($partialName); $partialName = strtolower($partialName);
$matchedPlayers = array(); $matchedPlayers = [];
foreach($this->getOnlinePlayers() as $player){ foreach($this->getOnlinePlayers() as $player){
if(strtolower($player->getName()) === $partialName){ if(strtolower($player->getName()) === $partialName){
$matchedPlayers = array($player); $matchedPlayers = array($player);
@ -849,11 +850,11 @@ class Server{
} }
$level->loadChunk($tile["x"] >> 4, $tile["z"] >> 4); $level->loadChunk($tile["x"] >> 4, $tile["z"] >> 4);
$nbt = new Compound(false, array()); $nbt = new Compound(false, []);
foreach($tile as $index => $data){ foreach($tile as $index => $data){
switch($index){ switch($index){
case "Items": case "Items":
$tag = new Enum("Items", array()); $tag = new Enum("Items", []);
$tag->setTagType(NBT::TAG_Compound); $tag->setTagType(NBT::TAG_Compound);
foreach($data as $slot => $fields){ foreach($data as $slot => $fields){
$tag[(int) $slot] = new Compound(false, array( $tag[(int) $slot] = new Compound(false, array(
@ -918,7 +919,7 @@ class Server{
* *
* @return bool * @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)){ if(trim($name) === "" or $this->isLevelGenerated($name)){
return false; return false;
} }
@ -1273,6 +1274,8 @@ class Server{
//TODO: update checking (async) //TODO: update checking (async)
$this->enablePlugins(PluginLoadOrder::STARTUP); $this->enablePlugins(PluginLoadOrder::STARTUP);
InventoryType::init();
Block::init(); Block::init();
Item::init(); Item::init();
Crafting::init(); Crafting::init();
@ -1666,7 +1669,7 @@ class Server{
$dump .= "\r\n\r\n"; $dump .= "\r\n\r\n";
} }
$extensions = array(); $extensions = [];
foreach(get_loaded_extensions() as $ext){ foreach(get_loaded_extensions() as $ext){
$extensions[$ext] = phpversion($ext); $extensions[$ext] = phpversion($ext);
} }

View File

@ -81,7 +81,7 @@ class Beetroot extends Flowable{
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
$drops = array(); $drops = [];
if($this->meta >= 0x07){ if($this->meta >= 0x07){
$drops[] = array(Item::BEETROOT, 0, 1); $drops[] = array(Item::BEETROOT, 0, 1);
$drops[] = array(Item::BEETROOT_SEEDS, 0, mt_rand(0, 3)); $drops[] = array(Item::BEETROOT_SEEDS, 0, mt_rand(0, 3));

View File

@ -405,7 +405,7 @@ abstract class Block extends Position implements Metadatable{
); );
/** @var Block[] */ /** @var Block[] */
public static $list = array(); public static $list = [];
protected $id; protected $id;
protected $meta; protected $meta;
protected $name; protected $name;
@ -650,7 +650,7 @@ abstract class Block extends Position implements Metadatable{
*/ */
public function getDrops(Item $item){ public function getDrops(Item $item){
if(!isset(self::$list[$this->id])){ //Unknown blocks if(!isset(self::$list[$this->id])){ //Unknown blocks
return array(); return [];
}else{ }else{
return array( return array(
array($this->id, $this->meta, 1), array($this->id, $this->meta, 1),

View File

@ -52,7 +52,7 @@ class Bricks extends Solid{
array(Item::BRICKS_BLOCK, 0, 1), array(Item::BRICKS_BLOCK, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -48,7 +48,7 @@ class BurningFurnace extends Solid{
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
$this->getLevel()->setBlock($block, $this, true, false, true); $this->getLevel()->setBlock($block, $this, true, false, true);
$nbt = new Compound(false, array( $nbt = new Compound(false, array(
new Enum("Items", array()), new Enum("Items", []),
new String("id", Tile::FURNACE), new String("id", Tile::FURNACE),
new Int("x", $this->x), new Int("x", $this->x),
new Int("y", $this->y), new Int("y", $this->y),
@ -74,7 +74,7 @@ class BurningFurnace extends Solid{
$furnace = $t; $furnace = $t;
}else{ }else{
$nbt = new Compound(false, array( $nbt = new Compound(false, array(
new Enum("Items", array()), new Enum("Items", []),
new String("id", Tile::FURNACE), new String("id", Tile::FURNACE),
new Int("x", $this->x), new Int("x", $this->x),
new Int("y", $this->y), new Int("y", $this->y),
@ -112,7 +112,7 @@ class BurningFurnace extends Solid{
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
$drops = array(); $drops = [];
if($item->isPickaxe() >= 1){ if($item->isPickaxe() >= 1){
$drops[] = array(Item::FURNACE, 0, 1); $drops[] = array(Item::FURNACE, 0, 1);
} }

View File

@ -58,7 +58,7 @@ class Cake extends Transparent{
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
return array(); return [];
} }
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){

View File

@ -81,7 +81,7 @@ class Carrot extends Flowable{
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
$drops = array(); $drops = [];
if($this->meta >= 0x07){ if($this->meta >= 0x07){
$drops[] = array(Item::CARROT, 0, mt_rand(1, 4)); $drops[] = array(Item::CARROT, 0, mt_rand(1, 4));
}else{ }else{

View File

@ -69,7 +69,7 @@ class Chest extends Transparent{
$this->getLevel()->setBlock($block, $this, true, false, true); $this->getLevel()->setBlock($block, $this, true, false, true);
$nbt = new Compound(false, array( $nbt = new Compound(false, array(
new Enum("Items", array()), new Enum("Items", []),
new String("id", Tile::CHEST), new String("id", Tile::CHEST),
new Int("x", $this->x), new Int("x", $this->x),
new Int("y", $this->y), new Int("y", $this->y),
@ -109,7 +109,7 @@ class Chest extends Transparent{
$chest = $t; $chest = $t;
}else{ }else{
$nbt = new Compound(false, array( $nbt = new Compound(false, array(
new Enum("Items", array()), new Enum("Items", []),
new String("id", Tile::CHEST), new String("id", Tile::CHEST),
new Int("x", $this->x), new Int("x", $this->x),
new Int("y", $this->y), new Int("y", $this->y),

View File

@ -52,7 +52,7 @@ class Coal extends Solid{
array(Item::COAL_BLOCK, 0, 1), array(Item::COAL_BLOCK, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -52,7 +52,7 @@ class CoalOre extends Solid{
array(Item::COAL, 0, 1), array(Item::COAL, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }

View File

@ -52,7 +52,7 @@ class Cobblestone extends Solid{
array(Item::COBBLESTONE, 0, 1), array(Item::COBBLESTONE, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -32,6 +32,6 @@ class Cobweb extends Flowable{
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
return array(); return [];
} }
} }

View File

@ -46,7 +46,7 @@ class Diamond extends Solid{
array(Item::DIAMOND_BLOCK, 0, 1), array(Item::DIAMOND_BLOCK, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -46,7 +46,7 @@ class DiamondOre extends Solid{
array(Item::DIAMOND, 0, 1), array(Item::DIAMOND, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -62,7 +62,7 @@ class DoubleSlab extends Solid{
array(Item::SLAB, $this->meta & 0x07, 2), array(Item::SLAB, $this->meta & 0x07, 2),
); );
}else{ }else{
return array(); return [];
} }
} }

View File

@ -34,7 +34,7 @@ class Fire extends Flowable{
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
return array(); return [];
} }
public function onUpdate($type){ public function onUpdate($type){

View File

@ -30,6 +30,6 @@ class Glass extends Transparent{
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
return array(); return [];
} }
} }

View File

@ -58,7 +58,7 @@ class GlowingRedstoneOre extends Solid{
array(Item::REDSTONE_DUST, 0, mt_rand(4, 5)), array(Item::REDSTONE_DUST, 0, mt_rand(4, 5)),
); );
}else{ }else{
return array(); return [];
} }
} }

View File

@ -46,7 +46,7 @@ class Gold extends Solid{
array(Item::GOLD_BLOCK, 0, 1), array(Item::GOLD_BLOCK, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -46,7 +46,7 @@ class GoldOre extends Solid{
array(Item::GOLD_ORE, 0, 1), array(Item::GOLD_ORE, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -53,6 +53,6 @@ class Ice extends Transparent{
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
return array(); return [];
} }
} }

View File

@ -48,7 +48,7 @@ class Iron extends Solid{
array(Item::IRON_BLOCK, 0, 1), array(Item::IRON_BLOCK, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -53,7 +53,7 @@ class IronDoor extends Door{
array(Item::IRON_DOOR, 0, 1), array(Item::IRON_DOOR, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -48,7 +48,7 @@ class IronOre extends Solid{
array(Item::IRON_ORE, 0, 1), array(Item::IRON_ORE, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -48,7 +48,7 @@ class Lapis extends Solid{
array(Item::LAPIS_BLOCK, 0, 1), array(Item::LAPIS_BLOCK, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }

View File

@ -49,7 +49,7 @@ class LapisOre extends Solid{
array(Item::DYE, 4, mt_rand(4, 8)), array(Item::DYE, 4, mt_rand(4, 8)),
); );
}else{ }else{
return array(); return [];
} }
} }

View File

@ -117,7 +117,7 @@ class Leaves extends Transparent{
}elseif($type === Level::BLOCK_UPDATE_RANDOM){ }elseif($type === Level::BLOCK_UPDATE_RANDOM){
if(($this->meta & 0b00001100) === 0x08){ if(($this->meta & 0b00001100) === 0x08){
$this->meta &= 0x03; $this->meta &= 0x03;
$visited = array(); $visited = [];
$check = 0; $check = 0;
if($this->findLog($this, $visited, 0, $check) === true){ if($this->findLog($this, $visited, 0, $check) === true){
$this->getLevel()->setBlock($this, $this, false, false, true); $this->getLevel()->setBlock($this, $this, false, false, true);
@ -146,7 +146,7 @@ class Leaves extends Transparent{
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
$drops = array(); $drops = [];
if($item->isShears()){ if($item->isShears()){
$drops[] = array(Item::LEAVES, $this->meta & 0x03, 1); $drops[] = array(Item::LEAVES, $this->meta & 0x03, 1);
}else{ }else{

View File

@ -53,7 +53,7 @@ class MossStone extends Solid{
array(Item::MOSS_STONE, $this->meta, 1), array(Item::MOSS_STONE, $this->meta, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -53,7 +53,7 @@ class NetherBrick extends Solid{
array(Item::NETHER_BRICKS, 0, 1), array(Item::NETHER_BRICKS, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -53,7 +53,7 @@ class Netherrack extends Solid{
array(Item::NETHERRACK, 0, 1), array(Item::NETHERRACK, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -44,7 +44,7 @@ class Obsidian extends Solid{
array(Item::OBSIDIAN, 0, 1), array(Item::OBSIDIAN, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -83,7 +83,7 @@ class Potato extends Flowable{
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
$drops = array(); $drops = [];
if($this->meta >= 0x07){ if($this->meta >= 0x07){
$drops[] = array(Item::POTATO, 0, mt_rand(1, 4)); $drops[] = array(Item::POTATO, 0, mt_rand(1, 4));
}else{ }else{

View File

@ -59,7 +59,7 @@ class Quartz extends Solid{
array(Item::QUARTZ_BLOCK, $this->meta & 0x03, 1), array(Item::QUARTZ_BLOCK, $this->meta & 0x03, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -46,7 +46,7 @@ class RedstoneOre extends Solid{
array(Item::REDSTONE_DUST, 0, mt_rand(4, 5)), array(Item::REDSTONE_DUST, 0, mt_rand(4, 5)),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -59,7 +59,7 @@ class Sandstone extends Solid{
array(Item::SANDSTONE, $this->meta & 0x03, 1), array(Item::SANDSTONE, $this->meta & 0x03, 1),
); );
}else{ }else{
return array(); return [];
} }
} }

View File

@ -119,7 +119,7 @@ class Slab extends Transparent{
array($this->id, $this->meta & 0x07, 1), array($this->id, $this->meta & 0x07, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -64,6 +64,6 @@ class SnowLayer extends Flowable{
); );
} }
return array(); return [];
} }
} }

View File

@ -58,7 +58,7 @@ class Stair extends Transparent{
array($this->id, 0, 1), array($this->id, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }
} }

View File

@ -53,7 +53,7 @@ class Stone extends Solid{
array(Item::COBBLESTONE, 0, 1), array(Item::COBBLESTONE, 0, 1),
); );
}else{ }else{
return array(); return [];
} }
} }

View File

@ -60,7 +60,7 @@ class StoneBricks extends Solid{
array(Item::STONE_BRICKS, $this->meta & 0x03, 1), array(Item::STONE_BRICKS, $this->meta & 0x03, 1),
); );
}else{ }else{
return array(); return [];
} }
} }

View File

@ -50,7 +50,7 @@ class TallGrass extends Flowable{
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
$drops = array(); $drops = [];
$possibleDrops = array( $possibleDrops = array(
array(Item::WHEAT_SEEDS, 0, 1), array(Item::WHEAT_SEEDS, 0, 1),
array(Item::CARROT, 0, 1), array(Item::CARROT, 0, 1),

View File

@ -79,7 +79,7 @@ class Wheat extends Flowable{
} }
public function getDrops(Item $item){ public function getDrops(Item $item){
$drops = array(); $drops = [];
if($this->meta >= 0x07){ if($this->meta >= 0x07){
$drops[] = array(Item::WHEAT, 0, 1); $drops[] = array(Item::WHEAT, 0, 1);
$drops[] = array(Item::WHEAT_SEEDS, 0, mt_rand(0, 3)); $drops[] = array(Item::WHEAT_SEEDS, 0, mt_rand(0, 3));

View File

@ -40,12 +40,12 @@ abstract class Command{
/** /**
* @var string[] * @var string[]
*/ */
private $aliases = array(); private $aliases = [];
/** /**
* @var string[] * @var string[]
*/ */
private $activeAliases = array(); private $activeAliases = [];
/** @var CommandMap */ /** @var CommandMap */
private $commandMap = null; private $commandMap = null;
@ -68,7 +68,7 @@ abstract class Command{
* @param string $usageMessage * @param string $usageMessage
* @param string[] $aliases * @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->name = $name;
$this->nextLabel = $name; $this->nextLabel = $name;
$this->label = $name; $this->label = $name;

View File

@ -61,7 +61,7 @@ class SimpleCommandMap implements CommandMap{
/** /**
* @var Command[] * @var Command[]
*/ */
protected $knownCommands = array(); protected $knownCommands = [];
/** @var Server */ /** @var Server */
private $server; private $server;
@ -184,7 +184,7 @@ class SimpleCommandMap implements CommandMap{
foreach($this->knownCommands as $command){ foreach($this->knownCommands as $command){
$command->unregister($this); $command->unregister($this);
} }
$this->knownCommands = array(); $this->knownCommands = [];
$this->setDefaultCommands(); $this->setDefaultCommands();
} }

View File

@ -65,7 +65,7 @@ class HelpCommand extends VanillaCommand{
} }
if($command === ""){ if($command === ""){
$commands = array(); $commands = [];
foreach(Server::getInstance()->getCommandMap()->getCommands() as $command){ foreach(Server::getInstance()->getCommandMap()->getCommands() as $command){
if($command->testPermissionSilent($sender)){ if($command->testPermissionSilent($sender)){
$commands[$command->getName()] = $command; $commands[$command->getName()] = $command;

View File

@ -29,7 +29,7 @@ abstract class VanillaCommand extends Command{
const MAX_COORD = 524288; const MAX_COORD = 524288;
const MIN_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); parent::__construct($name, $description, $usageMessage, $aliases);
} }

View File

@ -53,17 +53,17 @@ abstract class Entity extends Position implements Metadatable{
/** /**
* @var Entity[] * @var Entity[]
*/ */
public static $list = array(); public static $list = [];
/** /**
* @var Entity[] * @var Entity[]
*/ */
public static $needUpdate = array(); public static $needUpdate = [];
/** /**
* @var Player[] * @var Player[]
*/ */
protected $hasSpawned = array(); protected $hasSpawned = [];
protected $id; protected $id;
@ -424,7 +424,7 @@ abstract class Entity extends Position implements Metadatable{
$this->setLevel($targetLevel, true); //Hard reference $this->setLevel($targetLevel, true); //Hard reference
$this->getLevel()->entities[$this->id] = $this; //Oops, TODO!! $this->getLevel()->entities[$this->id] = $this; //Oops, TODO!!
if($this instanceof Player){ if($this instanceof Player){
$this->chunksLoaded = array(); $this->chunksLoaded = [];
$pk = new SetTimePacket(); $pk = new SetTimePacket();
$pk->time = $this->getLevel()->getTime(); $pk->time = $this->getLevel()->getTime();
$pk->started = $this->getLevel()->stopTime == false; $pk->started = $this->getLevel()->stopTime == false;

View File

@ -42,10 +42,10 @@ use pocketmine\Server;
class Human extends Creature implements ProjectileSource, InventorySource{ class Human extends Creature implements ProjectileSource, InventorySource{
protected $nameTag = "TESTIFICATE"; protected $nameTag = "TESTIFICATE";
protected $inventory = array(); protected $inventory = [];
public $slot; public $slot;
protected $hotbar = array(); protected $hotbar = [];
protected $armor = array(); protected $armor = [];
protected function initEntity(){ protected function initEntity(){
if(isset($this->namedtag->NameTag)){ if(isset($this->namedtag->NameTag)){
@ -76,7 +76,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
public function saveNBT(){ public function saveNBT(){
parent::saveNBT(); parent::saveNBT();
$this->namedtag->Inventory = new Enum("Inventory", array()); $this->namedtag->Inventory = new Enum("Inventory", []);
$this->namedtag->Inventory->setTagType(NBT::TAG_Compound); $this->namedtag->Inventory->setTagType(NBT::TAG_Compound);
for($slot = 0; $slot < 9; ++$slot){ for($slot = 0; $slot < 9; ++$slot){
if(isset($this->hotbar[$slot]) and $this->hotbar[$slot] !== -1){ 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){ public function sendArmor($player = null){
$slots = array(); $slots = [];
for($i = 0; $i < 4; ++$i){ for($i = 0; $i < 4; ++$i){
if(isset($this->armor[$i]) and ($this->armor[$i] instanceof Item) and $this->armor[$i]->getID() > Item::AIR){ if(isset($this->armor[$i]) and ($this->armor[$i] instanceof Item) and $this->armor[$i]->getID() > Item::AIR){
$slots[$i] = $this->armor[$i]->getID() !== Item::AIR ? $this->armor[$i]->getID() - 256 : 0; $slots[$i] = $this->armor[$i]->getID() !== Item::AIR ? $this->armor[$i]->getID() - 256 : 0;

View File

@ -34,12 +34,12 @@ class HandlerList{
/** /**
* @var RegisteredListener[][] * @var RegisteredListener[][]
*/ */
private $handlerSlots = array(); private $handlerSlots = [];
/** /**
* @var HandlerList[] * @var HandlerList[]
*/ */
private static $allLists = array(); private static $allLists = [];
public static function bakeAll(){ public static function bakeAll(){
foreach(self::$allLists as $h){ foreach(self::$allLists as $h){
@ -61,7 +61,7 @@ class HandlerList{
}else{ }else{
foreach(self::$allLists as $h){ foreach(self::$allLists as $h){
foreach($h->handlerSlots as $key => $list){ foreach($h->handlerSlots as $key => $list){
$h->handlerSlots[$key] = array(); $h->handlerSlots[$key] = [];
} }
$h->handlers = null; $h->handlers = null;
} }
@ -70,12 +70,12 @@ class HandlerList{
public function __construct(){ public function __construct(){
$this->handlerSlots = array( $this->handlerSlots = array(
EventPriority::MONITOR => array(), EventPriority::MONITOR => [],
EventPriority::HIGHEST => array(), EventPriority::HIGHEST => [],
EventPriority::HIGH => array(), EventPriority::HIGH => [],
EventPriority::NORMAL => array(), EventPriority::NORMAL => [],
EventPriority::LOW => array(), EventPriority::LOW => [],
EventPriority::LOWEST => array() EventPriority::LOWEST => []
); );
self::$allLists[] = $this; self::$allLists[] = $this;
} }
@ -133,7 +133,7 @@ class HandlerList{
if($this->handlers !== null){ if($this->handlers !== null){
return; return;
} }
$entries = array(); $entries = [];
foreach($this->handlerSlots as $list){ foreach($this->handlerSlots as $list){
foreach($list as $hash => $listener){ foreach($list as $hash => $listener){
$entries[$hash] = $listener; $entries[$hash] = $listener;
@ -149,7 +149,7 @@ class HandlerList{
*/ */
public function getRegisteredListeners($plugin = null){ public function getRegisteredListeners($plugin = null){
if($plugin instanceof Plugin){ if($plugin instanceof Plugin){
$listeners = array(); $listeners = [];
foreach($this->getRegisteredListeners(null) as $hash => $listener){ foreach($this->getRegisteredListeners(null) as $hash => $listener){
if($listener->getPlugin() === $plugin){ if($listener->getPlugin() === $plugin){
$listeners[$hash] = $plugin; $listeners[$hash] = $plugin;

View File

@ -40,7 +40,7 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{
/** /**
* @var Player[] * @var Player[]
*/ */
protected $recipients = array(); protected $recipients = [];
public function __construct(Player $player, $message, $format = "<%s> %s", array $recipients = null){ public function __construct(Player $player, $message, $format = "<%s> %s", array $recipients = null){
$this->player = $player; $this->player = $player;

View File

@ -0,0 +1,153 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
/**
* Handles the creation of virtual inventories or mapped to an InventoryHolder
*/
namespace pocketmine\inventory;
use pocketmine\item\Item;
use pocketmine\Player;
interface Inventory{
public function getSize();
public function getMaxStackSize();
/**
* @param int $size
*/
public function setMaxStackSize($size);
public function getName();
public function getTitle();
/**
* @param int $index
*
* @return Item
*/
public function getItem($index);
public function setItem($index, Item $item);
/**
* Stores the given Item in the inventory. This will try to fill
* existing stacks and empty slots as well as it can.
*
* Returns the Items that did not fit
*
* @param Item|Item[] $items
*
* @return Item[]
*/
public function addItem($items);
/**
* Removes the given Item from the inventory.
* It will return the Items that couldn't be removed.
*
* @param Item|Item[] $items
*
* @return Item[]
*/
public function removeItem($items);
/**
* @return Item[]
*/
public function getContents();
/**
* Checks if the inventory contains any Item with the same material data.
* It will check id, amount, and metadata (if not null)
*
* @param Item $item
*
* @return bool
*/
public function contains(Item $item);
/**
* Will return all the Items that has the same id and metadata (if not null)
*
* @param Item $item
*
* @return Item[]
*/
public function all(Item $item);
/**
* Will return the first slot has the same id and metadata (if not null) as the Item.
* -1 if not found
*
* @param Item $item
*
* @return int
*/
public function first(Item $item);
/**
* Returns the first empty slot, or -1 if not found
*
* @return int
*/
public function firstEmpty();
/**
* Will remove all the Items that has the same id and metadata (if not null)
*
* @param Item $item
*/
public function remove(Item $item);
/**
* Will clear a specific slot
*
* @param int $index
*/
public function clear($index);
/**
* Clears all the slots
*/
public function clearAll();
/**
* Gets all the Players viewing the inventory
* Players will be viewing their inventory at all times, even when not open.
*
* @return Player[]
*/
public function getViewers();
/**
* @return InventoryType
*/
public function getType();
/**
* @return InventoryHolder
*/
public function getHolder();
}

View File

@ -0,0 +1,32 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\inventory;
interface InventoryHolder{
/**
* Get the object related inventory
*
* @return Inventory
*/
public function getInventory();
}

View File

@ -0,0 +1,77 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\inventory;
/**
* Saves all the information regarding default inventory sizes and types
*/
class InventoryType{
const CHEST = 0;
const PLAYER = 1;
const FURNACE = 2;
const CRAFTING = 3;
const WORKBENCH = 4;
private static $default = [];
private $size;
private $title;
public static function get($index){
return isset(static::$default[$index]) ? static::$default[$index] : null;
}
public static function init(){
if(count(static::$default) > 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;
}
}

View File

@ -0,0 +1,39 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\inventory;
/**
* Saves all the information regarding default inventory sizes and types
*/
abstract class SlotType{
const RESULT = 0;
const CRAFTING = 1; //Not used in Minecraft: PE yet
const ARMOR = 2;
const CONTAINER = 3;
const HOTBAR = 4;
const FUEL = 5;
}

View File

@ -359,7 +359,7 @@ class Item{
/** @var Item[] */ /** @var Item[] */
public static $list = array(); public static $list = [];
protected $block; protected $block;
protected $id; protected $id;
protected $meta; protected $meta;
@ -447,7 +447,7 @@ class Item{
public static function fromString($str, $multiple = false){ public static function fromString($str, $multiple = false){
if($multiple === true){ if($multiple === true){
$blocks = array(); $blocks = [];
foreach(explode(",", $str) as $b){ foreach(explode(",", $str) as $b){
$blocks[] = self::fromString($b, false); $blocks[] = self::fromString($b, false);
} }

View File

@ -46,7 +46,7 @@ class Explosion{
/** /**
* @var Block[] * @var Block[]
*/ */
public $affectedBlocks = array(); public $affectedBlocks = [];
public $stepLen = 0.3; public $stepLen = 0.3;
private $what; private $what;
@ -95,7 +95,7 @@ class Explosion{
} }
} }
$send = array(); $send = [];
$source = $this->source->floor(); $source = $this->source->floor();
$radius = 2 * $this->size; $radius = 2 * $this->size;
$yield = (1 / $this->size) * 100; $yield = (1 / $this->size) * 100;

View File

@ -64,19 +64,19 @@ class Level{
const BLOCK_UPDATE_TOUCH = 5; const BLOCK_UPDATE_TOUCH = 5;
/** @var Player[] */ /** @var Player[] */
public $players = array(); public $players = [];
/** @var Entity[] */ /** @var Entity[] */
public $entities = array(); public $entities = [];
/** @var Entity[][] */ /** @var Entity[][] */
public $chunkEntities = array(); public $chunkEntities = [];
/** @var Tile[] */ /** @var Tile[] */
public $tiles = array(); public $tiles = [];
/** @var Tile[][] */ /** @var Tile[][] */
public $chunkTiles = array(); public $chunkTiles = [];
public $nextSave; public $nextSave;
@ -116,9 +116,9 @@ class Level{
$this->nextSave += 90; $this->nextSave += 90;
$this->stopTime = false; $this->stopTime = false;
$this->name = $name; $this->name = $name;
$this->usedChunks = array(); $this->usedChunks = [];
$this->changedBlocks = array(); $this->changedBlocks = [];
$this->changedCount = array(); $this->changedCount = [];
$gen = Generator::getGenerator($this->level->levelData["generator"]); $gen = Generator::getGenerator($this->level->levelData["generator"]);
$this->generator = new $gen((array) $this->level->levelData["generatorSettings"]); $this->generator = new $gen((array) $this->level->levelData["generatorSettings"]);
$this->generator->init($this, new Random($this->level->levelData["seed"])); $this->generator->init($this, new Random($this->level->levelData["seed"]));
@ -184,7 +184,7 @@ class Level{
public function getUsingChunk($X, $Z){ public function getUsingChunk($X, $Z){
$index = LevelFormat::getIndex($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){ if(count($this->changedBlocks) > 0){
foreach($this->changedBlocks as $index => $mini){ foreach($this->changedBlocks as $index => $mini){
@ -308,7 +308,7 @@ class Level{
} }
} }
} }
$this->changedBlocks = array(); $this->changedBlocks = [];
} }
$X = null; $X = null;
@ -429,8 +429,8 @@ class Level{
foreach($this->usedChunks as $index => $d){ foreach($this->usedChunks as $index => $d){
LevelFormat::getXZ($index, $X, $Z); LevelFormat::getXZ($index, $X, $Z);
$nbt = new Compound("", array( $nbt = new Compound("", array(
new Enum("Entities", array()), new Enum("Entities", []),
new Enum("TileEntities", array()), new Enum("TileEntities", []),
)); ));
$nbt->Entities->setTagType(NBT::TAG_Compound); $nbt->Entities->setTagType(NBT::TAG_Compound);
$nbt->TileEntities->setTagType(NBT::TAG_Compound); $nbt->TileEntities->setTagType(NBT::TAG_Compound);
@ -531,12 +531,12 @@ class Level{
Cache::remove("world:{$this->name}:{$index}"); Cache::remove("world:{$this->name}:{$index}");
} }
if(!isset($this->changedBlocks[$index])){ if(!isset($this->changedBlocks[$index])){
$this->changedBlocks[$index] = array(); $this->changedBlocks[$index] = [];
$this->changedCount[$index] = 0; $this->changedCount[$index] = 0;
} }
$Y = $pos->y >> 4; $Y = $pos->y >> 4;
if(!isset($this->changedBlocks[$index][$Y])){ if(!isset($this->changedBlocks[$index][$Y])){
$this->changedBlocks[$index][$Y] = array(); $this->changedBlocks[$index][$Y] = [];
$this->changedCount[$index] |= 1 << $Y; $this->changedCount[$index] |= 1 << $Y;
} }
$this->changedBlocks[$index][$Y][] = clone $block; $this->changedBlocks[$index][$Y][] = clone $block;
@ -581,12 +581,12 @@ class Level{
Cache::remove("world:{$this->name}:{$index}"); Cache::remove("world:{$this->name}:{$index}");
} }
if(!isset($this->changedBlocks[$index])){ if(!isset($this->changedBlocks[$index])){
$this->changedBlocks[$index] = array(); $this->changedBlocks[$index] = [];
$this->changedCount[$index] = 0; $this->changedCount[$index] = 0;
} }
$Y = $pos->y >> 4; $Y = $pos->y >> 4;
if(!isset($this->changedBlocks[$index][$Y])){ if(!isset($this->changedBlocks[$index][$Y])){
$this->changedBlocks[$index][$Y] = array(); $this->changedBlocks[$index][$Y] = [];
$this->changedCount[$index] |= 1 << $Y; $this->changedCount[$index] |= 1 << $Y;
} }
$this->changedBlocks[$index][$Y][] = clone $block; $this->changedBlocks[$index][$Y][] = clone $block;
@ -896,7 +896,7 @@ class Level{
return $this->chunkEntities[$index]; return $this->chunkEntities[$index];
} }
return array(); return [];
} }
/** /**
@ -913,7 +913,7 @@ class Level{
return $this->chunkTiles[$index]; return $this->chunkTiles[$index];
} }
return array(); return [];
} }
/** /**
@ -929,9 +929,9 @@ class Level{
if(isset($this->usedChunks[$index])){ if(isset($this->usedChunks[$index])){
return true; return true;
}elseif($this->level->loadChunk($X, $Z) !== false){ }elseif($this->level->loadChunk($X, $Z) !== false){
$this->usedChunks[$index] = array(); $this->usedChunks[$index] = [];
$this->chunkTiles[$index] = array(); $this->chunkTiles[$index] = [];
$this->chunkEntities[$index] = array(); $this->chunkEntities[$index] = [];
$tags = $this->level->getChunkNBT($X, $Z); $tags = $this->level->getChunkNBT($X, $Z);
if(isset($tags->Entities)){ if(isset($tags->Entities)){
foreach($tags->Entities as $nbt){ foreach($tags->Entities as $nbt){
@ -1027,7 +1027,7 @@ class Level{
} }
$raw = array(); $raw = [];
for($Y = 0; $Y < 8; ++$Y){ for($Y = 0; $Y < 8; ++$Y){
if(($Yndex & (1 << $Y)) !== 0){ if(($Yndex & (1 << $Y)) !== 0){
$raw[$Y] = $this->level->getMiniChunk($X, $Z, $Y); $raw[$Y] = $this->level->getMiniChunk($X, $Z, $Y);

View File

@ -53,7 +53,7 @@ class LevelImport{
$nbt->read(substr(file_get_contents($this->path . "entities.dat"), 12)); $nbt->read(substr(file_get_contents($this->path . "entities.dat"), 12));
$entities = $nbt->getData(); $entities = $nbt->getData();
if(!isset($entities->TileEntities)){ if(!isset($entities->TileEntities)){
$entities->TileEntities = array(); $entities->TileEntities = [];
} }
$tiles = $entities->TileEntities; $tiles = $entities->TileEntities;
$entities = $entities->Entities; $entities = $entities->Entities;

View File

@ -35,13 +35,13 @@ class PocketChunkParser{
private $file; private $file;
public $sectorLength = 4096; //16 * 16 * 16 public $sectorLength = 4096; //16 * 16 * 16
public $chunkLength = 86016; //21 * $sectorLength public $chunkLength = 86016; //21 * $sectorLength
public $map = array(); public $map = [];
public function __construct(){ public function __construct(){
} }
private function loadLocationTable(){ private function loadLocationTable(){
$this->location = array(); $this->location = [];
console("[DEBUG] Loading Chunk Location table...", true, true, 2); console("[DEBUG] Loading Chunk Location table...", true, true, 2);
for($offset = 0; $offset < 0x1000; $offset += 4){ for($offset = 0; $offset < 0x1000; $offset += 4){
$data = Binary::readLInt(substr($this->raw, $offset, 4)); $data = Binary::readLInt(substr($this->raw, $offset, 4));
@ -116,10 +116,10 @@ class PocketChunkParser{
$len = Binary::readLInt(substr($this->raw, $offset, 4)); $len = Binary::readLInt(substr($this->raw, $offset, 4));
$offset += 4; $offset += 4;
$chunk = array( $chunk = array(
0 => array(), //Block 0 => [], //Block
1 => array(), //Data 1 => [], //Data
2 => array(), //SkyLight 2 => [], //SkyLight
3 => array(), //BlockLight 3 => [], //BlockLight
); );
foreach($chunk as $section => &$data){ foreach($chunk as $section => &$data){
$l = $section === 0 ? 128 : 64; $l = $section === 0 ? 128 : 64;
@ -139,7 +139,7 @@ class PocketChunkParser{
$this->loadLocationTable(); $this->loadLocationTable();
console("[DEBUG] Loading chunks...", true, true, 2); console("[DEBUG] Loading chunks...", true, true, 2);
for($x = 0; $x < 16; ++$x){ for($x = 0; $x < 16; ++$x){
$this->map[$x] = array(); $this->map[$x] = [];
for($z = 0; $z < 16; ++$z){ for($z = 0; $z < 16; ++$z){
$this->map[$x][$z] = $this->parseChunk($x, $z); $this->map[$x][$z] = $this->parseChunk($x, $z);
} }

View File

@ -38,32 +38,32 @@ class Chunk extends BaseChunk{
if($this->nbt->Entities instanceof Enum){ if($this->nbt->Entities instanceof Enum){
$this->nbt->Entities->setTagType(NBT::TAG_Compound); $this->nbt->Entities->setTagType(NBT::TAG_Compound);
}else{ }else{
$this->nbt->Entities = new Enum("Entities", array()); $this->nbt->Entities = new Enum("Entities", []);
$this->nbt->Entities->setTagType(NBT::TAG_Compound); $this->nbt->Entities->setTagType(NBT::TAG_Compound);
} }
if($this->nbt->TileEntities instanceof Enum){ if($this->nbt->TileEntities instanceof Enum){
$this->nbt->TileEntities->setTagType(NBT::TAG_Compound); $this->nbt->TileEntities->setTagType(NBT::TAG_Compound);
}else{ }else{
$this->nbt->TileEntities = new Enum("TileEntities", array()); $this->nbt->TileEntities = new Enum("TileEntities", []);
$this->nbt->TileEntities->setTagType(NBT::TAG_Compound); $this->nbt->TileEntities->setTagType(NBT::TAG_Compound);
} }
if($this->nbt->TileTicks instanceof Enum){ if($this->nbt->TileTicks instanceof Enum){
$this->nbt->TileTicks->setTagType(NBT::TAG_Compound); $this->nbt->TileTicks->setTagType(NBT::TAG_Compound);
}else{ }else{
$this->nbt->TileTicks = new Enum("TileTicks", array()); $this->nbt->TileTicks = new Enum("TileTicks", []);
$this->nbt->TileTicks->setTagType(NBT::TAG_Compound); $this->nbt->TileTicks->setTagType(NBT::TAG_Compound);
} }
if($this->nbt->Sections instanceof Enum){ if($this->nbt->Sections instanceof Enum){
$this->nbt->Sections->setTagType(NBT::TAG_Compound); $this->nbt->Sections->setTagType(NBT::TAG_Compound);
}else{ }else{
$this->nbt->Sections = new Enum("Sections", array()); $this->nbt->Sections = new Enum("Sections", []);
$this->nbt->Sections->setTagType(NBT::TAG_Compound); $this->nbt->Sections->setTagType(NBT::TAG_Compound);
} }
$sections = array(); $sections = [];
foreach($this->nbt->Sections as $section){ foreach($this->nbt->Sections as $section){
if($section instanceof Compound){ if($section instanceof Compound){
$sections[(int) $section["Y"]] = new ChunkSection($section); $sections[(int) $section["Y"]] = new ChunkSection($section);

View File

@ -43,7 +43,7 @@ class RegionLoader{
protected $filePath; protected $filePath;
protected $filePointer; protected $filePointer;
protected $lastSector; protected $lastSector;
protected $locationTable = array(); protected $locationTable = [];
public function __construct($path,/*Level $level, */$regionX, $regionZ){ public function __construct($path,/*Level $level, */$regionX, $regionZ){
$this->x = $regionX; $this->x = $regionX;
@ -118,7 +118,7 @@ class RegionLoader{
} }
public function generateChunk($x, $z){ public function generateChunk($x, $z){
$nbt = new Compound("Level", array()); $nbt = new Compound("Level", []);
$nbt->xPos = new Int("xPos", ($this->getX() * 32) + $x); $nbt->xPos = new Int("xPos", ($this->getX() * 32) + $x);
$nbt->zPos = new Int("xPos", ($this->getZ() * 32) + $z); $nbt->zPos = new Int("xPos", ($this->getZ() * 32) + $z);
$nbt->LastUpdate = new Long("LastUpdate", 0); $nbt->LastUpdate = new Long("LastUpdate", 0);
@ -128,13 +128,13 @@ class RegionLoader{
$nbt->InhabitedTime = new Long("InhabitedTime", 0); $nbt->InhabitedTime = new Long("InhabitedTime", 0);
$nbt->Biomes = new ByteArray("Biomes", str_repeat(Binary::writeByte(-1), 256)); $nbt->Biomes = new ByteArray("Biomes", str_repeat(Binary::writeByte(-1), 256));
$nbt->HeightMap = new IntArray("HeightMap", array_fill(0, 256, 127)); $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->Sections->setTagType(NBT::TAG_Compound);
$nbt->Entities = new Enum("Entities", array()); $nbt->Entities = new Enum("Entities", []);
$nbt->Entities->setTagType(NBT::TAG_Compound); $nbt->Entities->setTagType(NBT::TAG_Compound);
$nbt->TileEntities = new Enum("TileEntities", array()); $nbt->TileEntities = new Enum("TileEntities", []);
$nbt->TileEntities->setTagType(NBT::TAG_Compound); $nbt->TileEntities->setTagType(NBT::TAG_Compound);
$nbt->TileTicks = new Enum("TileTicks", array()); $nbt->TileTicks = new Enum("TileTicks", []);
$nbt->TileTicks->setTagType(NBT::TAG_Compound); $nbt->TileTicks->setTagType(NBT::TAG_Compound);
$writer = new NBT(NBT::BIG_ENDIAN); $writer = new NBT(NBT::BIG_ENDIAN);
$writer->setData(new Compound("", array($nbt))); $writer->setData(new Compound("", array($nbt)));
@ -187,7 +187,7 @@ class RegionLoader{
} }
private function cleanGarbage(){ private function cleanGarbage(){
$sectors = array(); $sectors = [];
foreach($this->locationTable as $index => $data){ //Calculate file usage foreach($this->locationTable as $index => $data){ //Calculate file usage
if($data[0] === 0 or $data[1] === 0){ if($data[0] === 0 or $data[1] === 0){
$this->locationTable[$index] = array(0, 0, 0); $this->locationTable[$index] = array(0, 0, 0);

View File

@ -27,7 +27,7 @@ use pocketmine\level\Level;
abstract class BaseChunk implements Chunk{ abstract class BaseChunk implements Chunk{
/** @var ChunkSection[] */ /** @var ChunkSection[] */
protected $sections = array(); protected $sections = [];
protected $level; protected $level;
protected $x; protected $x;

View File

@ -34,11 +34,11 @@ class LevelFormat extends PMF{
const ZLIB_ENCODING = 15; //15 = zlib, -15 = raw deflate, 31 = gzip const ZLIB_ENCODING = 15; //15 = zlib, -15 = raw deflate, 31 = gzip
public $level; public $level;
public $levelData = array(); public $levelData = [];
public $isLoaded = true; public $isLoaded = true;
private $chunks = array(); private $chunks = [];
private $chunkChange = array(); private $chunkChange = [];
private $chunkInfo = array(); private $chunkInfo = [];
public $isGenerating = 0; public $isGenerating = 0;
public function getData($index){ public function getData($index){
@ -69,9 +69,9 @@ class LevelFormat extends PMF{
* @param bool|array $blank default false * @param bool|array $blank default false
*/ */
public function __construct($file, $blank = false){ public function __construct($file, $blank = false){
$this->chunks = array(); $this->chunks = [];
$this->chunkChange = array(); $this->chunkChange = [];
$this->chunkInfo = array(); $this->chunkInfo = [];
if(is_array($blank)){ if(is_array($blank)){
$this->create($file, 0); $this->create($file, 0);
$this->levelData = $blank; $this->levelData = $blank;
@ -189,8 +189,8 @@ class LevelFormat extends PMF{
private function upgrade_From1_To2(){ private function upgrade_From1_To2(){
console("[NOTICE] Old PMF Level format version #1 detected, upgrading to version #2"); console("[NOTICE] Old PMF Level format version #1 detected, upgrading to version #2");
$nbt = new Compound("", array( $nbt = new Compound("", array(
new Enum("Entities", array()), new Enum("Entities", []),
new Enum("TileEntities", array()) new Enum("TileEntities", [])
)); ));
$nbt->Entities->setTagType(NBT::TAG_Compound); $nbt->Entities->setTagType(NBT::TAG_Compound);
$nbt->TileEntities->setTagType(NBT::TAG_Compound); $nbt->TileEntities->setTagType(NBT::TAG_Compound);
@ -301,7 +301,7 @@ class LevelFormat extends PMF{
$nbt->read(substr($chunk, $offset, $len)); $nbt->read(substr($chunk, $offset, $len));
$this->chunkInfo[$index][2] = $nbt->getData(); $this->chunkInfo[$index][2] = $nbt->getData();
$offset += $len; $offset += $len;
$this->chunks[$index] = array(); $this->chunks[$index] = [];
$this->chunkChange[$index] = array(-1 => false); $this->chunkChange[$index] = array(-1 => false);
$this->chunkInfo[$index][3] = substr($chunk, $offset, 256); //Biome data $this->chunkInfo[$index][3] = substr($chunk, $offset, 256); //Biome data
$offset += 256; $offset += 256;
@ -421,8 +421,8 @@ class LevelFormat extends PMF{
7 => 8192, 7 => 8192,
); );
$nbt = new Compound("", array( $nbt = new Compound("", array(
new Enum("Entities", array()), new Enum("Entities", []),
new Enum("TileEntities", array()) new Enum("TileEntities", [])
)); ));
$nbt->Entities->setTagType(NBT::TAG_Compound); $nbt->Entities->setTagType(NBT::TAG_Compound);
$nbt->TileEntities->setTagType(NBT::TAG_Compound); $nbt->TileEntities->setTagType(NBT::TAG_Compound);

View File

@ -37,7 +37,7 @@ use pocketmine\math\Vector3 as Vector3;
use pocketmine\utils\Random; use pocketmine\utils\Random;
class Flat extends Generator{ class Flat extends Generator{
private $level, $random, $structure, $chunks, $options, $floorLevel, $preset, $populators = array(); private $level, $random, $structure, $chunks, $options, $floorLevel, $preset, $populators = [];
public function getSettings(){ public function getSettings(){
return $this->options; return $this->options;
@ -47,7 +47,7 @@ class Flat extends Generator{
return "flat"; 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->preset = "2;7,59x1,3x3,2;1;spawn(radius=10 block=89),decoration(treecount=80 grasscount=45)";
$this->options = $options; $this->options = $options;
if(isset($options["preset"])){ if(isset($options["preset"])){
@ -84,8 +84,8 @@ class Flat extends Generator{
$options = isset($preset[3]) ? $preset[3] : ""; $options = isset($preset[3]) ? $preset[3] : "";
preg_match_all('#(([0-9]{0,})x?([0-9]{1,3}:?[0-9]{0,2})),?#', $blocks, $matches); preg_match_all('#(([0-9]{0,})x?([0-9]{1,3}:?[0-9]{0,2})),?#', $blocks, $matches);
$y = 0; $y = 0;
$this->structure = array(); $this->structure = [];
$this->chunks = array(); $this->chunks = [];
foreach($matches[3] as $i => $b){ foreach($matches[3] as $i => $b){
$b = Item::fromString($b); $b = Item::fromString($b);
$cnt = $matches[2][$i] === "" ? 1 : intval($matches[2][$i]); $cnt = $matches[2][$i] === "" ? 1 : intval($matches[2][$i]);
@ -122,7 +122,7 @@ class Flat extends Generator{
foreach($matches[2] as $i => $option){ foreach($matches[2] as $i => $option){
$params = true; $params = true;
if($matches[3][$i] !== ""){ if($matches[3][$i] !== ""){
$params = array(); $params = [];
$p = explode(" ", $matches[3][$i]); $p = explode(" ", $matches[3][$i]);
foreach($p as $k){ foreach($p as $k){
$k = explode("=", $k); $k = explode("=", $k);

View File

@ -28,7 +28,7 @@ use pocketmine\level\Level;
use pocketmine\utils\Random; use pocketmine\utils\Random;
abstract class Generator{ abstract class Generator{
private static $list = array(); private static $list = [];
public static function addGenerator($object, $name){ public static function addGenerator($object, $name){
if(is_subclass_of($object, "pocketmine\\level\\generator\\Generator") and !isset(Generator::$list[$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"; 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); public abstract function init(Level $level, Random $random);

View File

@ -40,7 +40,7 @@ use pocketmine\utils\Random;
class Normal extends Generator{ class Normal extends Generator{
private $populators = array(); private $populators = [];
private $level; private $level;
private $random; private $random;
private $worldHeight = 65; private $worldHeight = 65;
@ -50,7 +50,7 @@ class Normal extends Generator{
private $noisePatchesSmall; private $noisePatchesSmall;
private $noiseBase; private $noiseBase;
public function __construct(array $options = array()){ public function __construct(array $options = []){
} }
@ -59,7 +59,7 @@ class Normal extends Generator{
} }
public function getSettings(){ public function getSettings(){
return array(); return [];
} }
public function init(Level $level, Random $random){ public function init(Level $level, Random $random){
@ -98,10 +98,10 @@ class Normal extends Generator{
public function generateChunk($chunkX, $chunkZ){ public function generateChunk($chunkX, $chunkZ){
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed()); $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
$hills = array(); $hills = [];
$patches = array(); $patches = [];
$patchesSmall = array(); $patchesSmall = [];
$base = array(); $base = [];
for($z = 0; $z < 16; ++$z){ for($z = 0; $z < 16; ++$z){
for($x = 0; $x < 16; ++$x){ for($x = 0; $x < 16; ++$x){
$i = ($z << 4) + $x; $i = ($z << 4) + $x;

View File

@ -29,7 +29,7 @@ namespace pocketmine\level\generator\noise;
abstract class Generator{ abstract class Generator{
protected $perm = array(); protected $perm = [];
protected $offsetX = 0; protected $offsetX = 0;
protected $offsetY = 0; protected $offsetY = 0;
protected $offsetZ = 0; protected $offsetZ = 0;

View File

@ -27,7 +27,7 @@ use pocketmine\math\Vector3 as Vector3;
use pocketmine\utils\Random; use pocketmine\utils\Random;
class Ore extends Populator{ class Ore extends Populator{
private $oreTypes = array(); private $oreTypes = [];
public function populate(Level $level, $chunkX, $chunkZ, Random $random){ public function populate(Level $level, $chunkX, $chunkZ, Random $random){
foreach($this->oreTypes as $type){ foreach($this->oreTypes as $type){

View File

@ -23,7 +23,7 @@ namespace pocketmine\math;
class Matrix implements \ArrayAccess{ class Matrix implements \ArrayAccess{
private $matrix = array(); private $matrix = [];
private $rows = 0; private $rows = 0;
private $columns = 0; private $columns = 0;
@ -43,7 +43,7 @@ class Matrix implements \ArrayAccess{
unset($this->matrix[(int) $offset]); 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->rows = max(1, (int) $rows);
$this->columns = max(1, (int) $columns); $this->columns = max(1, (int) $columns);
$this->set($set); $this->set($set);
@ -51,7 +51,7 @@ class Matrix implements \ArrayAccess{
public function set(array $m){ public function set(array $m){
for($r = 0; $r < $this->rows; ++$r){ for($r = 0; $r < $this->rows; ++$r){
$this->matrix[$r] = array(); $this->matrix[$r] = [];
for($c = 0; $c < $this->columns; ++$c){ for($c = 0; $c < $this->columns; ++$c){
$this->matrix[$r][$c] = isset($m[$r][$c]) ? $m[$r][$c] : 0; $this->matrix[$r][$c] = isset($m[$r][$c]) ? $m[$r][$c] : 0;
} }

View File

@ -25,7 +25,7 @@ use pocketmine\nbt\NBT;
class Compound extends NamedTag implements \ArrayAccess{ class Compound extends NamedTag implements \ArrayAccess{
public function __construct($name = "", $value = array()){ public function __construct($name = "", $value = []){
$this->name = $name; $this->name = $name;
foreach($value as $tag){ foreach($value as $tag){
$this->{$tag->getName()} = $tag; $this->{$tag->getName()} = $tag;
@ -65,7 +65,7 @@ class Compound extends NamedTag implements \ArrayAccess{
} }
public function read(NBT $nbt){ public function read(NBT $nbt){
$this->value = array(); $this->value = [];
do{ do{
$tag = $nbt->readTag(); $tag = $nbt->readTag();
if($tag instanceof NamedTag and $tag->getName() !== ""){ if($tag instanceof NamedTag and $tag->getName() !== ""){

View File

@ -28,7 +28,7 @@ class Enum extends NamedTag implements \ArrayAccess{
private $tagType; private $tagType;
public function __construct($name = "", $value = array()){ public function __construct($name = "", $value = []){
$this->name = $name; $this->name = $name;
foreach($value as $k => $v){ foreach($value as $k => $v){
$this->{$k} = $v; $this->{$k} = $v;
@ -76,7 +76,7 @@ class Enum extends NamedTag implements \ArrayAccess{
} }
public function read(NBT $nbt){ public function read(NBT $nbt){
$this->value = array(); $this->value = [];
$this->tagType = $nbt->getByte(); $this->tagType = $nbt->getByte();
$size = $nbt->getInt(); $size = $nbt->getInt();
for($i = 0; $i < $size and !$nbt->feof(); ++$i){ for($i = 0; $i < $size and !$nbt->feof(); ++$i){
@ -156,7 +156,7 @@ class Enum extends NamedTag implements \ArrayAccess{
$nbt->putByte($this->tagType); $nbt->putByte($this->tagType);
$tags = array(); $tags = [];
foreach($this as $tag){ foreach($this as $tag){
if($tag instanceof Tag){ if($tag instanceof Tag){
$tags[] = $tag; $tags[] = $tag;

View File

@ -30,7 +30,7 @@ class IntArray extends NamedTag{
} }
public function read(NBT $nbt){ public function read(NBT $nbt){
$this->value = array(); $this->value = [];
$size = $nbt->getInt(); $size = $nbt->getInt();
for($i = 0; $i < $size and !$nbt->feof(); ++$i){ for($i = 0; $i < $size and !$nbt->feof(); ++$i){
$this->value[] = $nbt->getInt(); $this->value[] = $nbt->getInt();

View File

@ -24,8 +24,8 @@ namespace pocketmine\network\protocol;
class ContainerSetContentPacket extends DataPacket{ class ContainerSetContentPacket extends DataPacket{
public $windowid; public $windowid;
public $slots = array(); public $slots = [];
public $hotbar = array(); public $hotbar = [];
public function pid(){ public function pid(){
return Info::CONTAINER_SET_CONTENT_PACKET; return Info::CONTAINER_SET_CONTENT_PACKET;

View File

@ -137,7 +137,7 @@ abstract class DataPacket extends \stdClass{
} }
protected function getDataArray($len = 10){ protected function getDataArray($len = 10){
$data = array(); $data = [];
for($i = 1; $i <= $len and !$this->feof(); ++$i){ for($i = 1; $i <= $len and !$this->feof(); ++$i){
$data[] = $this->get($this->getTriad()); $data[] = $this->get($this->getTriad());
} }
@ -145,7 +145,7 @@ abstract class DataPacket extends \stdClass{
return $data; return $data;
} }
protected function putDataArray(array $data = array()){ protected function putDataArray(array $data = []){
foreach($data as $v){ foreach($data as $v){
$this->putTriad(strlen($v)); $this->putTriad(strlen($v));
$this->put($v); $this->put($v);

View File

@ -24,7 +24,7 @@ namespace pocketmine\network\protocol;
class PlayerArmorEquipmentPacket extends DataPacket{ class PlayerArmorEquipmentPacket extends DataPacket{
public $eid; public $eid;
public $slots = array(); public $slots = [];
public function pid(){ public function pid(){
return Info::PLAYER_ARMOR_EQUIPMENT_PACKET; return Info::PLAYER_ARMOR_EQUIPMENT_PACKET;

View File

@ -25,8 +25,8 @@ namespace pocketmine\network\protocol;
class SendInventoryPacket extends DataPacket{ class SendInventoryPacket extends DataPacket{
public $eid; public $eid;
public $windowid; public $windowid;
public $slots = array(); public $slots = [];
public $armor = array(); public $armor = [];
public function pid(){ public function pid(){
return Info::SEND_INVENTORY_PACKET; return Info::SEND_INVENTORY_PACKET;

View File

@ -84,7 +84,7 @@ use pocketmine\utils\Utils;
class Packet extends NetworkPacket{ class Packet extends NetworkPacket{
private $packetID; private $packetID;
private $offset = 1; private $offset = 1;
public $data = array(); public $data = [];
public function __construct($packetID){ public function __construct($packetID){
$this->packetID = (int) $packetID; $this->packetID = (int) $packetID;
@ -172,7 +172,7 @@ class Packet extends NetworkPacket{
case Info::DATA_PACKET_E: case Info::DATA_PACKET_E:
case Info::DATA_PACKET_F: case Info::DATA_PACKET_F:
$this->seqNumber = $this->getLTriad(); $this->seqNumber = $this->getLTriad();
$this->data = array(); $this->data = [];
while(!$this->feof() and $this->parseDataPacket() !== false){ while(!$this->feof() and $this->parseDataPacket() !== false){
} }
@ -180,7 +180,7 @@ class Packet extends NetworkPacket{
case Info::NACK: case Info::NACK:
case Info::ACK: case Info::ACK:
$count = $this->getShort(); $count = $this->getShort();
$this->packets = array(); $this->packets = [];
for($i = 0; $i < $count and !$this->feof(); ++$i){ for($i = 0; $i < $count and !$this->feof(); ++$i){
if($this->getByte() === 0){ if($this->getByte() === 0){
$start = $this->getLTriad(); $start = $this->getLTriad();

View File

@ -41,7 +41,7 @@ class RCON{
private $rconSender; private $rconSender;
public function __construct($password, $port = 19132, $interface = "0.0.0.0", $threads = 1, $clientsPerThread = 50){ public function __construct($password, $port = 19132, $interface = "0.0.0.0", $threads = 1, $clientsPerThread = 50){
$this->workers = array(); $this->workers = [];
$this->password = (string) $password; $this->password = (string) $password;
console("[INFO] Starting remote control listener"); console("[INFO] Starting remote control listener");
if($this->password === ""){ if($this->password === ""){

View File

@ -26,7 +26,7 @@ use pocketmine\Server;
class BanList{ class BanList{
/** @var BanEntry[] */ /** @var BanEntry[] */
private $list = array(); private $list = [];
/** @var string */ /** @var string */
private $file; private $file;
@ -128,7 +128,7 @@ class BanList{
} }
public function load(){ public function load(){
$this->list = array(); $this->list = [];
$fp = @fopen($this->file, "r"); $fp = @fopen($this->file, "r");
if(is_resource($fp)){ if(is_resource($fp)){
while(($line = fgets($fp)) !== false){ while(($line = fgets($fp)) !== false){

View File

@ -34,12 +34,12 @@ class PermissibleBase implements Permissible{
/** /**
* @var PermissionAttachment[] * @var PermissionAttachment[]
*/ */
private $attachments = array(); private $attachments = [];
/** /**
* @var PermissionAttachmentInfo[] * @var PermissionAttachmentInfo[]
*/ */
private $permissions = array(); private $permissions = [];
/** /**
* @param ServerOperator $opable * @param ServerOperator $opable
@ -190,7 +190,7 @@ class PermissibleBase implements Permissible{
Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(false, $this->parent); Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(false, $this->parent);
Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(true, $this->parent); Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(true, $this->parent);
$this->permissions = array(); $this->permissions = [];
} }
/** /**

View File

@ -84,7 +84,7 @@ class Permission{
/** /**
* @var string[] * @var string[]
*/ */
private $children = array(); private $children = [];
/** @var string */ /** @var string */
private $defaultValue; private $defaultValue;
@ -97,7 +97,7 @@ class Permission{
* @param string $defaultValue * @param string $defaultValue
* @param Permission[] $children * @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->name = $name;
$this->description = $description !== null ? $description : ""; $this->description = $description !== null ? $description : "";
$this->defaultValue = $defaultValue !== null ? $defaultValue : self::$DEFAULT_PERMISSION; $this->defaultValue = $defaultValue !== null ? $defaultValue : self::$DEFAULT_PERMISSION;
@ -199,7 +199,7 @@ class Permission{
* @return Permission[] * @return Permission[]
*/ */
public static function loadPermissions(array $data, $default = self::DEFAULT_OP){ public static function loadPermissions(array $data, $default = self::DEFAULT_OP){
$result = array(); $result = [];
foreach($data as $key => $entry){ foreach($data as $key => $entry){
$result[] = self::loadPermission($key, $entry, $default, $result); $result[] = self::loadPermission($key, $entry, $default, $result);
} }
@ -215,9 +215,9 @@ class Permission{
* *
* @return 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; $desc = null;
$children = array(); $children = [];
if(isset($data["default"])){ if(isset($data["default"])){
$value = Permission::getByName($data["default"]); $value = Permission::getByName($data["default"]);
if($value !== null){ if($value !== null){

View File

@ -30,7 +30,7 @@ class PermissionAttachment{
/** /**
* @var bool[] * @var bool[]
*/ */
private $permissions = array(); private $permissions = [];
/** @var Permissible */ /** @var Permissible */
private $permissible; private $permissible;

View File

@ -218,7 +218,7 @@ abstract class PluginBase implements Plugin{
* @return string[] * @return string[]
*/ */
public function getResources(){ public function getResources(){
$resources = array(); $resources = [];
if(is_dir($this->file . "resources/")){ if(is_dir($this->file . "resources/")){
foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->file . "resources/")) as $resource){ foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->file . "resources/")) as $resource){
$resources[] = $resource; $resources[] = $resource;

View File

@ -27,13 +27,13 @@ class PluginDescription{
private $name; private $name;
private $main; private $main;
private $api; private $api;
private $depend = array(); private $depend = [];
private $softDepend = array(); private $softDepend = [];
private $loadBefore = array(); private $loadBefore = [];
private $version; private $version;
private $commands = array(); private $commands = [];
private $description = null; private $description = null;
private $authors = array(); private $authors = [];
private $website = null; private $website = null;
private $prefix = null; private $prefix = null;
private $order = PluginLoadOrder::POSTWORLD; private $order = PluginLoadOrder::POSTWORLD;
@ -41,7 +41,7 @@ class PluginDescription{
/** /**
* @var Permission[] * @var Permission[]
*/ */
private $permissions = array(); private $permissions = [];
/** /**
* @param string $yamlString * @param string $yamlString
@ -100,7 +100,7 @@ class PluginDescription{
$this->order = constant("pocketmine\\plugin\\PluginLoadOrder::" . $order); $this->order = constant("pocketmine\\plugin\\PluginLoadOrder::" . $order);
} }
} }
$this->authors = array(); $this->authors = [];
if(isset($plugin["author"])){ if(isset($plugin["author"])){
$this->authors[] = $plugin["author"]; $this->authors[] = $plugin["author"];
} }

View File

@ -45,12 +45,12 @@ class PluginManager{
/** /**
* @var Plugin[] * @var Plugin[]
*/ */
protected $plugins = array(); protected $plugins = [];
/** /**
* @var Permission[] * @var Permission[]
*/ */
protected $permissions = array(); protected $permissions = [];
/** /**
* @var Permission[] * @var Permission[]
@ -65,7 +65,7 @@ class PluginManager{
/** /**
* @var Permissible[] * @var Permissible[]
*/ */
protected $permSubs = array(); protected $permSubs = [];
/** /**
* @var Permissible[] * @var Permissible[]
@ -80,7 +80,7 @@ class PluginManager{
/** /**
* @var PluginLoader[] * @var PluginLoader[]
*/ */
protected $fileAssociations = array(); protected $fileAssociations = [];
/** /**
* @param Server $server * @param Server $server
@ -166,12 +166,12 @@ class PluginManager{
public function loadPlugins($directory, $newLoaders = null){ public function loadPlugins($directory, $newLoaders = null){
if(is_dir($directory)){ if(is_dir($directory)){
$plugins = array(); $plugins = [];
$loadedPlugins = array(); $loadedPlugins = [];
$dependencies = array(); $dependencies = [];
$softDependencies = array(); $softDependencies = [];
if(is_array($newLoaders)){ if(is_array($newLoaders)){
$loaders = array(); $loaders = [];
foreach($newLoaders as $key){ foreach($newLoaders as $key){
if(isset($this->fileAssociations[$key])){ if(isset($this->fileAssociations[$key])){
$loaders[$key] = $this->fileAssociations[$key]; $loaders[$key] = $this->fileAssociations[$key];
@ -302,14 +302,14 @@ class PluginManager{
foreach($plugins as $name => $file){ 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(); $plugins = [];
} }
} }
} }
return $loadedPlugins; return $loadedPlugins;
}else{ }else{
return array(); return [];
} }
} }
@ -432,7 +432,7 @@ class PluginManager{
return $this->permSubs[$permission]; return $this->permSubs[$permission];
} }
return array(); return [];
} }
/** /**
@ -512,7 +512,7 @@ class PluginManager{
* @return PluginCommand[] * @return PluginCommand[]
*/ */
protected function parseYamlCommands(Plugin $plugin){ protected function parseYamlCommands(Plugin $plugin){
$pluginCmds = array(); $pluginCmds = [];
foreach($plugin->getDescription()->getCommands() as $key => $data){ foreach($plugin->getDescription()->getCommands() as $key => $data){
if(strpos($key, ":") !== false){ if(strpos($key, ":") !== false){
@ -530,7 +530,7 @@ class PluginManager{
} }
if(isset($data["aliases"]) and is_array($data["aliases"])){ if(isset($data["aliases"]) and is_array($data["aliases"])){
$aliasList = array(); $aliasList = [];
foreach($data["aliases"] as $alias){ foreach($data["aliases"] as $alias){
if(strpos($alias, ":") !== false){ if(strpos($alias, ":") !== false){
console("[SEVERE] Could not load alias " . $alias . " for plugin " . $plugin->getDescription()->getName()); console("[SEVERE] Could not load alias " . $alias . " for plugin " . $plugin->getDescription()->getName());
@ -579,11 +579,11 @@ class PluginManager{
public function clearPlugins(){ public function clearPlugins(){
$this->disablePlugins(); $this->disablePlugins();
$this->plugins = array(); $this->plugins = [];
$this->fileAssociations = array(); $this->fileAssociations = [];
$this->permissions = array(); $this->permissions = [];
$this->defaultPerms = array(); $this->defaultPerms = [];
$this->defaultPermsOp = array(); $this->defaultPermsOp = [];
} }
/** /**

View File

@ -28,7 +28,7 @@ use pocketmine\item\Item;
abstract class Crafting{ 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! private static $small = array( //Probably means craftable on crafting bench and in inventory. Name it better!
//Building //Building
@ -221,11 +221,11 @@ abstract class Crafting{
"COBBLESTONE:?x6=>COBBLESTONE_STAIRS:0x4", "COBBLESTONE:?x6=>COBBLESTONE_STAIRS:0x4",
); );
private static $recipes = array(); private static $recipes = [];
private static function parseRecipe($recipe){ private static function parseRecipe($recipe){
$recipe = explode("=>", $recipe); $recipe = explode("=>", $recipe);
$recipeItems = array(); $recipeItems = [];
foreach(explode(",", $recipe[0]) as $item){ foreach(explode(",", $recipe[0]) as $item){
$item = explode("x", $item); $item = explode("x", $item);
$id = explode(":", $item[0]); $id = explode(":", $item[0]);
@ -257,34 +257,34 @@ abstract class Crafting{
public static function init(){ public static function init(){
$id = 1; $id = 1;
self::$lookupTable[0] = array(); self::$lookupTable[0] = [];
foreach(self::$small as $recipe){ foreach(self::$small as $recipe){
$recipe = self::parseRecipe($recipe); $recipe = self::parseRecipe($recipe);
self::$recipes[$id] = $recipe; self::$recipes[$id] = $recipe;
if(!isset(self::$lookupTable[0][$recipe[2]])){ if(!isset(self::$lookupTable[0][$recipe[2]])){
self::$lookupTable[0][$recipe[2]] = array(); self::$lookupTable[0][$recipe[2]] = [];
} }
self::$lookupTable[0][$recipe[2]][] = $id; self::$lookupTable[0][$recipe[2]][] = $id;
++$id; ++$id;
} }
self::$lookupTable[1] = array(); self::$lookupTable[1] = [];
foreach(self::$big as $recipe){ foreach(self::$big as $recipe){
$recipe = self::parseRecipe($recipe); $recipe = self::parseRecipe($recipe);
self::$recipes[$id] = $recipe; self::$recipes[$id] = $recipe;
if(!isset(self::$lookupTable[1][$recipe[2]])){ if(!isset(self::$lookupTable[1][$recipe[2]])){
self::$lookupTable[1][$recipe[2]] = array(); self::$lookupTable[1][$recipe[2]] = [];
} }
self::$lookupTable[1][$recipe[2]][] = $id; self::$lookupTable[1][$recipe[2]][] = $id;
++$id; ++$id;
} }
self::$lookupTable[2] = array(); self::$lookupTable[2] = [];
foreach(self::$stone as $recipe){ foreach(self::$stone as $recipe){
$recipe = self::parseRecipe($recipe); $recipe = self::parseRecipe($recipe);
self::$recipes[$id] = $recipe; self::$recipes[$id] = $recipe;
if(!isset(self::$lookupTable[2][$recipe[2]])){ if(!isset(self::$lookupTable[2][$recipe[2]])){
self::$lookupTable[2][$recipe[2]] = array(); self::$lookupTable[2][$recipe[2]] = [];
} }
self::$lookupTable[2][$recipe[2]][] = $id; self::$lookupTable[2][$recipe[2]][] = $id;
++$id; ++$id;

View File

@ -39,7 +39,7 @@ class CallbackTask extends Task{
* @param callable $callable * @param callable $callable
* @param array $args * @param array $args
*/ */
public function __construct(callable $callable, array $args = array()){ public function __construct(callable $callable, array $args = []){
$this->callable = $callable; $this->callable = $callable;
$this->args = $args; $this->args = $args;
$this->args[] = $this; $this->args[] = $this;

View File

@ -37,7 +37,7 @@ class ServerScheduler{
/** /**
* @var TaskHandler[] * @var TaskHandler[]
*/ */
protected $tasks = array(); protected $tasks = [];
/** @var \Pool */ /** @var \Pool */
protected $asyncPool; protected $asyncPool;
@ -134,7 +134,7 @@ class ServerScheduler{
foreach($this->tasks as $task){ foreach($this->tasks as $task){
$task->cancel(); $task->cancel();
} }
$this->tasks = array(); $this->tasks = [];
$this->asyncPool->shutdown(); $this->asyncPool->shutdown();
$this->asyncTasks = 0; $this->asyncTasks = 0;
} }

View File

@ -62,7 +62,7 @@ trait Container{
$pk->y = $this->y; $pk->y = $this->y;
$pk->z = $this->z; $pk->z = $this->z;
$player->dataPacket($pk); $player->dataPacket($pk);
$slots = array(); $slots = [];
if(is_array($player->windows[$id])){ if(is_array($player->windows[$id])){
$all = $this->getLevel()->getPlayers(); $all = $this->getLevel()->getPlayers();
@ -121,7 +121,7 @@ trait Container{
$pk->z = $this->z; $pk->z = $this->z;
$player->dataPacket($pk); $player->dataPacket($pk);
$slots = array(); $slots = [];
for($s = 0; $s < Furnace::SLOTS; ++$s){ for($s = 0; $s < Furnace::SLOTS; ++$s){
$slot = $this->getSlot($s); $slot = $this->getSlot($s);
if($slot->getID() > Item::AIR and $slot->getCount() > 0){ if($slot->getID() > Item::AIR and $slot->getCount() > 0){

View File

@ -41,12 +41,12 @@ abstract class Tile extends Position{
/** /**
* @var Tile[] * @var Tile[]
*/ */
public static $list = array(); public static $list = [];
/** /**
* @var Tile[] * @var Tile[]
*/ */
public static $needUpdate = array(); public static $needUpdate = [];
public $chunkIndex; public $chunkIndex;
public $name; public $name;

View File

@ -113,7 +113,7 @@ class Binary{
*/ */
public static function readMetadata($value, $types = false){ public static function readMetadata($value, $types = false){
$offset = 0; $offset = 0;
$m = array(); $m = [];
$b = ord($value{$offset}); $b = ord($value{$offset});
++$offset; ++$offset;
while($b !== 127 and isset($value{$offset})){ while($b !== 127 and isset($value{$offset})){
@ -143,7 +143,7 @@ class Binary{
$offset += $len; $offset += $len;
break; break;
case 5: case 5:
$r = array(); $r = [];
$r[] = self::readLShort(substr($value, $offset, 2)); $r[] = self::readLShort(substr($value, $offset, 2));
$offset += 2; $offset += 2;
$r[] = ord($value{$offset}); $r[] = ord($value{$offset});
@ -152,7 +152,7 @@ class Binary{
$offset += 2; $offset += 2;
break; break;
case 6: case 6:
$r = array(); $r = [];
for($i = 0; $i < 3; ++$i){ for($i = 0; $i < 3; ++$i){
$r[] = self::readLInt(substr($value, $offset, 4)); $r[] = self::readLInt(substr($value, $offset, 4));
$offset += 4; $offset += 4;

View File

@ -23,7 +23,7 @@ namespace pocketmine\utils;
class Cache{ class Cache{
public static $cached = array(); public static $cached = [];
/** /**
* Adds something to the cache * Adds something to the cache

View File

@ -71,7 +71,7 @@ class Config{
* @param array $default Array with the default values, will be set if not existent * @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 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); $this->load($file, $type, $default);
$correct = $this->correct; $correct = $this->correct;
} }
@ -102,12 +102,12 @@ class Config{
* *
* @return bool * @return bool
*/ */
public function load($file, $type = Config::DETECT, $default = array()){ public function load($file, $type = Config::DETECT, $default = []){
$this->correct = true; $this->correct = true;
$this->type = (int) $type; $this->type = (int) $type;
$this->file = $file; $this->file = $file;
if(!is_array($default)){ if(!is_array($default)){
$default = array(); $default = [];
} }
if(!file_exists($file)){ if(!file_exists($file)){
$this->config = $default; $this->config = $default;
@ -275,7 +275,7 @@ class Config{
$final = array_pop($components); $final = array_pop($components);
foreach($components as $component){ foreach($components as $component){
if(!isset($currPath[$component])){ if(!isset($currPath[$component])){
$currPath[$component] = array(); $currPath[$component] = [];
} }
$currPath =& $currPath[$component]; $currPath =& $currPath[$component];
} }
@ -347,7 +347,7 @@ class Config{
foreach($default as $k => $v){ foreach($default as $k => $v){
if(is_array($v)){ if(is_array($v)){
if(!isset($data[$k]) or !is_array($data[$k])){ if(!isset($data[$k]) or !is_array($data[$k])){
$data[$k] = array(); $data[$k] = [];
} }
$changed += $this->fillDefaults($v, $data[$k]); $changed += $this->fillDefaults($v, $data[$k]);
}elseif(!isset($data[$k])){ }elseif(!isset($data[$k])){

View File

@ -42,7 +42,7 @@ class InstallerLang{
"tr" => "Türkçe", "tr" => "Türkçe",
//"et" => "Eesti", //"et" => "Eesti",
); );
private $texts = array(); private $texts = [];
private $lang; private $lang;
private $langfile; private $langfile;
@ -53,7 +53,7 @@ class InstallerLang{
}else{ }else{
$l = glob(\pocketmine\PATH . "src/lang/Installer/" . $lang . "_*.ini"); $l = glob(\pocketmine\PATH . "src/lang/Installer/" . $lang . "_*.ini");
if(count($l) > 0){ if(count($l) > 0){
$files = array(); $files = [];
foreach($l as $file){ foreach($l as $file){
$files[$file] = filesize($file); $files[$file] = filesize($file);
} }
@ -81,7 +81,7 @@ class InstallerLang{
} }
public function loadLang($langfile, $lang = "en"){ 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))); $texts = explode("\n", str_replace(array("\r", "\/\/"), array("", "//"), file_get_contents($langfile)));
foreach($texts as $line){ foreach($texts as $line){
$line = trim($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(!isset($this->texts[$this->lang][$name])){
if($this->lang !== "en" and isset($this->texts["en"][$name])){ if($this->lang !== "en" and isset($this->texts["en"][$name])){
return $this->texts["en"][$name]; return $this->texts["en"][$name];

View File

@ -50,7 +50,7 @@ class SplClassLoader implements SplAutoloader{
private $includePathLookup = false; private $includePathLookup = false;
/** @var array */ /** @var array */
private $resources = array(); private $resources = [];
/** @var integer */ /** @var integer */
private $mode = self::MODE_NORMAL; private $mode = self::MODE_NORMAL;

View File

@ -629,7 +629,7 @@ class Pool{
* *
* @link http://www.php.net/manual/en/pool.__construct.php * @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 = []){
} }
/** /**

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