mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
Added Inventory interfaces and types, updated long array() to []
This commit is contained in:
parent
0be679c9d5
commit
6cbd39de9b
@ -40,7 +40,6 @@ It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accept
|
||||
* Files MUST NOT have an ending `?>` tag.
|
||||
* Code MUST use namespaces.
|
||||
* Strings SHOULD use the double quote `"` except when the single quote is required.
|
||||
* Arrays SHOULD be declared using `array()`, not the `[]` shortcut.
|
||||
* Argument lists MAY NOT be split across multiple lines, except long arrays.
|
||||
|
||||
```php
|
||||
|
@ -33,7 +33,7 @@ abstract class Achievement{
|
||||
public static $list = array(
|
||||
/*"openInventory" => array(
|
||||
"name" => "Taking Inventory",
|
||||
"requires" => array(),
|
||||
"requires" => [],
|
||||
),*/
|
||||
"mineWood" => array(
|
||||
"name" => "Getting Wood",
|
||||
@ -118,7 +118,7 @@ abstract class Achievement{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function add($achievementId, $achievementName, array $requires = array()){
|
||||
public static function add($achievementId, $achievementName, array $requires = []){
|
||||
if(!isset(Achievement::$list[$achievementId])){
|
||||
Achievement::$list[$achievementId] = array(
|
||||
"name" => $achievementName,
|
||||
|
@ -103,15 +103,15 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
public $gamemode;
|
||||
public $lastBreak;
|
||||
public $windowCnt = 2;
|
||||
public $windows = array();
|
||||
public $windows = [];
|
||||
public $blocked = true;
|
||||
public $achievements = array();
|
||||
public $chunksLoaded = array();
|
||||
public $achievements = [];
|
||||
public $chunksLoaded = [];
|
||||
public $lastCorrect;
|
||||
public $craftingItems = array();
|
||||
public $toCraft = array();
|
||||
public $craftingItems = [];
|
||||
public $toCraft = [];
|
||||
public $lastCraft = 0;
|
||||
public $loginData = array();
|
||||
public $loginData = [];
|
||||
protected $lastMovement = 0;
|
||||
protected $forceMovement = false;
|
||||
protected $connected = true;
|
||||
@ -123,13 +123,13 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
protected $displayName;
|
||||
protected $startAction = false;
|
||||
protected $sleeping = false;
|
||||
protected $chunksOrder = array();
|
||||
protected $chunksOrder = [];
|
||||
/** @var Player[] */
|
||||
protected $hiddenPlayers = array();
|
||||
private $recoveryQueue = array();
|
||||
private $receiveQueue = array();
|
||||
private $resendQueue = array();
|
||||
private $ackQueue = array();
|
||||
protected $hiddenPlayers = [];
|
||||
private $recoveryQueue = [];
|
||||
private $receiveQueue = [];
|
||||
private $resendQueue = [];
|
||||
private $ackQueue = [];
|
||||
private $receiveCount = -1;
|
||||
/** @var \pocketmine\network\raknet\Packet */
|
||||
private $buffer;
|
||||
@ -141,7 +141,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
private $lastMeasure = 0;
|
||||
private $bandwidthRaw = 0;
|
||||
private $bandwidthStats = array(0, 0, 0);
|
||||
private $lag = array();
|
||||
private $lag = [];
|
||||
private $lagStat = 0;
|
||||
private $spawnPosition;
|
||||
private $packetLoss = 0;
|
||||
@ -150,13 +150,13 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
private $inAction = false;
|
||||
private $bigCnt;
|
||||
private $packetStats;
|
||||
private $chunkCount = array();
|
||||
private $received = array();
|
||||
private $chunkCount = [];
|
||||
private $received = [];
|
||||
|
||||
/**
|
||||
* @var \pocketmine\scheduler\TaskHandler[]
|
||||
*/
|
||||
private $tasks = array();
|
||||
private $tasks = [];
|
||||
|
||||
/** @var PermissibleBase */
|
||||
private $perm = null;
|
||||
@ -377,7 +377,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
$this->hotbar = array(0, -1, -1, -1, -1, -1, -1, -1, -1);
|
||||
$this->packetStats = array(0, 0);
|
||||
$this->buffer = new Packet(Info::DATA_PACKET_0);
|
||||
$this->buffer->data = array();
|
||||
$this->buffer->data = [];
|
||||
$this->tasks[] = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask(array($this, "handlePacketQueues")), 1);
|
||||
$this->tasks[] = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask(array($this, "clearQueue")), 20 * 60);
|
||||
console("[DEBUG] New Session started with " . $ip . ":" . $port . ". MTU " . $this->MTU . ", Client ID " . $this->clientID, true, true, 2);
|
||||
@ -399,7 +399,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
*/
|
||||
public function hasAchievement($achievementId){
|
||||
if(!isset(Achievement::$list[$achievementId]) or !isset($this->achievements)){
|
||||
$this->achievements = array();
|
||||
$this->achievements = [];
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -565,7 +565,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
if($cnt === false){
|
||||
return false;
|
||||
}
|
||||
$this->chunkCount = array();
|
||||
$this->chunkCount = [];
|
||||
foreach($cnt as $i => $count){
|
||||
$this->chunkCount[$count] = true;
|
||||
}
|
||||
@ -590,7 +590,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
return false;
|
||||
}
|
||||
|
||||
$newOrder = array();
|
||||
$newOrder = [];
|
||||
$lastChunk = $this->chunksLoaded;
|
||||
$centerX = $this->x >> 4;
|
||||
$centerZ = $this->z >> 4;
|
||||
@ -672,7 +672,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
@$this->buffer->data[] = $packet;
|
||||
$this->bufferLen += 6 + $len;
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
private function directBigRawPacket(DataPacket $packet){
|
||||
@ -686,7 +686,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
$buffer = str_split($packet->buffer, $size);
|
||||
$bigCnt = $this->bigCnt;
|
||||
$this->bigCnt = ($this->bigCnt + 1) % 0x10000;
|
||||
$cnts = array();
|
||||
$cnts = [];
|
||||
$bufCount = count($buffer);
|
||||
foreach($buffer as $i => $buf){
|
||||
$cnts[] = $count = $this->counter[0]++;
|
||||
@ -742,7 +742,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
}
|
||||
$this->bufferLen = 0;
|
||||
$this->buffer = new Packet(Info::DATA_PACKET_0);
|
||||
$this->buffer->data = array();
|
||||
$this->buffer->data = [];
|
||||
$this->nextBuffer = microtime(true) + 0.1;
|
||||
}
|
||||
}
|
||||
@ -1064,7 +1064,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
$this->bandwidthStats[] = $this->bandwidthRaw / max(0.00001, microtime(true) - $this->lastMeasure);
|
||||
$this->bandwidthRaw = 0;
|
||||
$this->lagStat = array_sum($this->lag) / max(1, count($this->lag));
|
||||
$this->lag = array();
|
||||
$this->lag = [];
|
||||
$this->sendBuffer();
|
||||
$this->lastMeasure = microtime(true);
|
||||
}
|
||||
@ -1141,7 +1141,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
$packetCnt = (int) ($ackCnt / $safeCount + 1);
|
||||
for($p = 0; $p < $packetCnt; ++$p){
|
||||
$pk = new Packet(Info::ACK);
|
||||
$pk->packets = array();
|
||||
$pk->packets = [];
|
||||
for($c = 0; $c < $safeCount; ++$c){
|
||||
if(($k = array_pop($this->ackQueue)) === null){
|
||||
break;
|
||||
@ -1150,7 +1150,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
}
|
||||
$this->send($pk);
|
||||
}
|
||||
$this->ackQueue = array();
|
||||
$this->ackQueue = [];
|
||||
}
|
||||
|
||||
if(($receiveCnt = count($this->receiveQueue)) > 0){
|
||||
@ -1350,7 +1350,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->achievements = array();
|
||||
$this->achievements = [];
|
||||
foreach($nbt->Achievements as $achievement){
|
||||
$this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false;
|
||||
}
|
||||
@ -1559,8 +1559,8 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
$this->dataPacket($pk);
|
||||
break;
|
||||
}
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = array();
|
||||
$this->craftingItems = [];
|
||||
$this->toCraft = [];
|
||||
$packet->eid = $this->id;
|
||||
|
||||
if($packet->face >= 0 and $packet->face <= 5){ //Use Block, place
|
||||
@ -1618,8 +1618,8 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
break;
|
||||
}
|
||||
$packet->eid = $this->id;
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = array();
|
||||
$this->craftingItems = [];
|
||||
$this->toCraft = [];
|
||||
|
||||
switch($packet->action){
|
||||
case 5: //Shot arrow
|
||||
@ -1693,8 +1693,8 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
if($this->spawned === false or $this->blocked === true){
|
||||
break;
|
||||
}
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = array();
|
||||
$this->craftingItems = [];
|
||||
$this->toCraft = [];
|
||||
|
||||
$vector = new Vector3($packet->x, $packet->y, $packet->z);
|
||||
|
||||
@ -1725,8 +1725,8 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
if($this->spawned === false or $this->blocked === true){
|
||||
break;
|
||||
}
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = array();
|
||||
$this->craftingItems = [];
|
||||
$this->toCraft = [];
|
||||
|
||||
for($i = 0; $i < 4; ++$i){
|
||||
$s = $packet->slots[$i];
|
||||
@ -1774,12 +1774,12 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
break;
|
||||
}
|
||||
$packet->eid = $this->id;
|
||||
$data = array();
|
||||
$data = [];
|
||||
$data["target"] = $packet->target;
|
||||
$data["eid"] = $packet->eid;
|
||||
$data["action"] = $packet->action;
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = array();
|
||||
$this->craftingItems = [];
|
||||
$this->toCraft = [];
|
||||
$target = Entity::get($packet->target);
|
||||
if($target instanceof Entity and $this->gamemode !== VIEW and $this->blocked === false and ($target instanceof Entity) and $this->entity->distance($target) <= 8){
|
||||
$data["targetentity"] = $target;
|
||||
@ -1869,8 +1869,8 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
if($this->spawned === false or $this->dead === false){
|
||||
break;
|
||||
}
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = array();
|
||||
$this->craftingItems = [];
|
||||
$this->toCraft = [];
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->spawnPosition));
|
||||
|
||||
@ -1889,8 +1889,8 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
if($this->spawned === false or $this->blocked === true){
|
||||
break;
|
||||
}
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = array();
|
||||
$this->craftingItems = [];
|
||||
$this->toCraft = [];
|
||||
$packet->eid = $this->id;
|
||||
if($this->entity->inAction === true){
|
||||
$this->entity->inAction = false;
|
||||
@ -1945,9 +1945,9 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
}
|
||||
$packet->eid = $this->id;
|
||||
$packet->item = $this->getSlot($this->getCurrentEquipment());
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = array();
|
||||
$data = array();
|
||||
$this->craftingItems = [];
|
||||
$this->toCraft = [];
|
||||
$data = [];
|
||||
$data["eid"] = $packet->eid;
|
||||
$data["unknown"] = $packet->unknown;
|
||||
$data["item"] = $packet->item;
|
||||
@ -1965,8 +1965,8 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
if($this->spawned === false){
|
||||
break;
|
||||
}
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = array();
|
||||
$this->craftingItems = [];
|
||||
$this->toCraft = [];
|
||||
$packet->message = TextFormat::clean($packet->message);
|
||||
if(trim($packet->message) != "" and strlen($packet->message) <= 255){
|
||||
$message = $packet->message;
|
||||
@ -1988,8 +1988,8 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
if($this->spawned === false){
|
||||
break;
|
||||
}
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = array();
|
||||
$this->craftingItems = [];
|
||||
$this->toCraft = [];
|
||||
if(isset($this->windows[$packet->windowid])){
|
||||
if(is_array($this->windows[$packet->windowid])){
|
||||
foreach($this->windows[$packet->windowid] as $ob){
|
||||
@ -2026,9 +2026,9 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
if(isset($this->toCraft[-1])){
|
||||
$this->toCraft = array(-1 => $this->toCraft[-1]);
|
||||
}else{
|
||||
$this->toCraft = array();
|
||||
$this->toCraft = [];
|
||||
}
|
||||
$this->craftingItems = array();
|
||||
$this->craftingItems = [];
|
||||
}
|
||||
|
||||
if($packet->windowid === 0){
|
||||
@ -2063,15 +2063,15 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
if($craft === true and count($this->craftingItems) > 0 and count($this->toCraft) > 0 and ($recipe = $this->craftItems($this->toCraft, $this->craftingItems, $this->toCraft[-1])) !== true){
|
||||
if($recipe === false){
|
||||
$this->sendInventory();
|
||||
$this->toCraft = array();
|
||||
$this->toCraft = [];
|
||||
}else{
|
||||
$this->toCraft = array(-1 => $this->toCraft[-1]);
|
||||
}
|
||||
$this->craftingItems = array();
|
||||
$this->craftingItems = [];
|
||||
}
|
||||
}else{
|
||||
$this->toCraft = array();
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = [];
|
||||
$this->craftingItems = [];
|
||||
}
|
||||
if(!isset($this->windows[$packet->windowid])){
|
||||
break;
|
||||
@ -2206,8 +2206,8 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
if($this->spawned === false or $this->blocked === true){
|
||||
break;
|
||||
}
|
||||
$this->craftingItems = array();
|
||||
$this->toCraft = array();
|
||||
$this->craftingItems = [];
|
||||
$this->toCraft = [];
|
||||
$t = $this->getLevel()->getTile(new Vector3($packet->x, $packet->y, $packet->z));
|
||||
if($t instanceof Sign){
|
||||
if($t->namedtag->creator !== $this->username){
|
||||
@ -2307,11 +2307,11 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
foreach($this->tasks as $task){
|
||||
$task->cancel();
|
||||
}
|
||||
$this->tasks = array();
|
||||
$this->recoveryQueue = array();
|
||||
$this->receiveQueue = array();
|
||||
$this->resendQueue = array();
|
||||
$this->ackQueue = array();
|
||||
$this->tasks = [];
|
||||
$this->recoveryQueue = [];
|
||||
$this->receiveQueue = [];
|
||||
$this->resendQueue = [];
|
||||
$this->ackQueue = [];
|
||||
|
||||
if(isset($ev) and $this->username != "" and $this->spawned !== false and $ev->getQuitMessage() != ""){
|
||||
$this->server->broadcastMessage($ev->getQuitMessage());
|
||||
@ -2319,14 +2319,14 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
$this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
|
||||
$this->spawned = false;
|
||||
console("[INFO] " . TextFormat::AQUA . $this->username . TextFormat::RESET . "[/" . $this->ip . ":" . $this->port . "] logged out due to " . $reason);
|
||||
$this->windows = array();
|
||||
$this->armor = array();
|
||||
$this->inventory = array();
|
||||
$this->chunksLoaded = array();
|
||||
$this->chunksOrder = array();
|
||||
$this->chunkCount = array();
|
||||
$this->craftingItems = array();
|
||||
$this->received = array();
|
||||
$this->windows = [];
|
||||
$this->armor = [];
|
||||
$this->inventory = [];
|
||||
$this->chunksLoaded = [];
|
||||
$this->chunksOrder = [];
|
||||
$this->chunkCount = [];
|
||||
$this->craftingItems = [];
|
||||
$this->received = [];
|
||||
$this->buffer = null;
|
||||
unset($this->buffer);
|
||||
}
|
||||
@ -2372,7 +2372,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new DataPacketSendEvent($this, $packet));
|
||||
if($ev->isCancelled()){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
$packet->encode();
|
||||
$pk = new Packet(Info::DATA_PACKET_0);
|
||||
@ -2432,7 +2432,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
|
||||
}
|
||||
|
||||
$recipeItems = array();
|
||||
$recipeItems = [];
|
||||
foreach($recipe as $item){
|
||||
if(!isset($recipeItems[$item->getID()])){
|
||||
$recipeItems[$item->getID()] = array($item->getID(), $item->getDamage(), $item->getCount());
|
||||
@ -2558,7 +2558,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
if(($this->gamemode & 0x01) === 1){
|
||||
return;
|
||||
}
|
||||
$hotbar = array();
|
||||
$hotbar = [];
|
||||
foreach($this->hotbar as $slot){
|
||||
$hotbar[] = $slot <= -1 ? -1 : $slot + 9;
|
||||
}
|
||||
@ -2634,7 +2634,7 @@ class Player extends Human implements CommandSender, IPlayer{
|
||||
case Info::DATA_PACKET_E:
|
||||
case Info::DATA_PACKET_F:
|
||||
$this->ackQueue[] = $packet->seqNumber;
|
||||
$this->receiveQueue[$packet->seqNumber] = array();
|
||||
$this->receiveQueue[$packet->seqNumber] = [];
|
||||
foreach($packet->data as $pk){
|
||||
$this->receiveQueue[$packet->seqNumber][] = $pk;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ namespace pocketmine {
|
||||
function getTrace($start = 1){
|
||||
$e = new \Exception();
|
||||
$trace = $e->getTrace();
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
$j = 0;
|
||||
for($i = (int) $start; isset($trace[$i]); ++$i, ++$j){
|
||||
$params = "";
|
||||
@ -277,7 +277,7 @@ namespace pocketmine {
|
||||
if((!defined("pocketmine\\DEBUG") or \pocketmine\DEBUG >= $level) and (!defined("pocketmine\\LOG") or \pocketmine\LOG === true)){
|
||||
$message .= $EOL === true ? PHP_EOL : "";
|
||||
if(!isset($fpointers)){
|
||||
$fpointers = array();
|
||||
$fpointers = [];
|
||||
}
|
||||
if(!isset($fpointers[$name]) or $fpointers[$name] === false){
|
||||
$fpointers[$name] = @fopen(\pocketmine\DATA . "/" . $name . ".log", "ab");
|
||||
|
@ -39,6 +39,7 @@ use pocketmine\event\HandlerList;
|
||||
use pocketmine\event\server\PacketReceiveEvent;
|
||||
use pocketmine\event\server\PacketSendEvent;
|
||||
use pocketmine\event\server\ServerCommandEvent;
|
||||
use pocketmine\inventory\InventoryType;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\generator\Flat;
|
||||
use pocketmine\level\generator\Generator;
|
||||
@ -171,10 +172,10 @@ class Server{
|
||||
private $properties;
|
||||
|
||||
/** @var Player[] */
|
||||
private $players = array();
|
||||
private $players = [];
|
||||
|
||||
/** @var Level[] */
|
||||
private $levels = array();
|
||||
private $levels = [];
|
||||
|
||||
/** @var Level */
|
||||
private $levelDefault = null;
|
||||
@ -551,8 +552,8 @@ class Server{
|
||||
new Int("SpawnY", (int) $spawn->y),
|
||||
new Int("SpawnZ", (int) $spawn->z),
|
||||
new Byte("SpawnForced", 1), //TODO
|
||||
new Enum("Inventory", array()),
|
||||
new Compound("Achievements", array()),
|
||||
new Enum("Inventory", []),
|
||||
new Compound("Achievements", []),
|
||||
new Int("playerGameType", $this->getGamemode()),
|
||||
new Enum("Motion", array(
|
||||
new Double(0, 0.0),
|
||||
@ -576,7 +577,7 @@ class Server{
|
||||
$nbt->Rotation->setTagType(NBT::TAG_Float);
|
||||
|
||||
if(file_exists($path . "$name.yml")){ //Importing old PocketMine-MP files
|
||||
$data = new Config($path . "$name.yml", Config::YAML, array());
|
||||
$data = new Config($path . "$name.yml", Config::YAML, []);
|
||||
$nbt["playerGameType"] = (int) $data->get("gamemode");
|
||||
$nbt["Level"] = $data->get("position")["level"];
|
||||
$nbt["Pos"][0] = $data->get("position")["x"];
|
||||
@ -696,7 +697,7 @@ class Server{
|
||||
*/
|
||||
public function matchPlayer($partialName){
|
||||
$partialName = strtolower($partialName);
|
||||
$matchedPlayers = array();
|
||||
$matchedPlayers = [];
|
||||
foreach($this->getOnlinePlayers() as $player){
|
||||
if(strtolower($player->getName()) === $partialName){
|
||||
$matchedPlayers = array($player);
|
||||
@ -849,11 +850,11 @@ class Server{
|
||||
}
|
||||
$level->loadChunk($tile["x"] >> 4, $tile["z"] >> 4);
|
||||
|
||||
$nbt = new Compound(false, array());
|
||||
$nbt = new Compound(false, []);
|
||||
foreach($tile as $index => $data){
|
||||
switch($index){
|
||||
case "Items":
|
||||
$tag = new Enum("Items", array());
|
||||
$tag = new Enum("Items", []);
|
||||
$tag->setTagType(NBT::TAG_Compound);
|
||||
foreach($data as $slot => $fields){
|
||||
$tag[(int) $slot] = new Compound(false, array(
|
||||
@ -918,7 +919,7 @@ class Server{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function generateLevel($name, $seed = null, $generator = null, array $options = array()){
|
||||
public function generateLevel($name, $seed = null, $generator = null, array $options = []){
|
||||
if(trim($name) === "" or $this->isLevelGenerated($name)){
|
||||
return false;
|
||||
}
|
||||
@ -1273,6 +1274,8 @@ class Server{
|
||||
//TODO: update checking (async)
|
||||
|
||||
$this->enablePlugins(PluginLoadOrder::STARTUP);
|
||||
|
||||
InventoryType::init();
|
||||
Block::init();
|
||||
Item::init();
|
||||
Crafting::init();
|
||||
@ -1666,7 +1669,7 @@ class Server{
|
||||
$dump .= "\r\n\r\n";
|
||||
}
|
||||
|
||||
$extensions = array();
|
||||
$extensions = [];
|
||||
foreach(get_loaded_extensions() as $ext){
|
||||
$extensions[$ext] = phpversion($ext);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class Beetroot extends Flowable{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = array();
|
||||
$drops = [];
|
||||
if($this->meta >= 0x07){
|
||||
$drops[] = array(Item::BEETROOT, 0, 1);
|
||||
$drops[] = array(Item::BEETROOT_SEEDS, 0, mt_rand(0, 3));
|
||||
|
@ -405,7 +405,7 @@ abstract class Block extends Position implements Metadatable{
|
||||
);
|
||||
|
||||
/** @var Block[] */
|
||||
public static $list = array();
|
||||
public static $list = [];
|
||||
protected $id;
|
||||
protected $meta;
|
||||
protected $name;
|
||||
@ -650,7 +650,7 @@ abstract class Block extends Position implements Metadatable{
|
||||
*/
|
||||
public function getDrops(Item $item){
|
||||
if(!isset(self::$list[$this->id])){ //Unknown blocks
|
||||
return array();
|
||||
return [];
|
||||
}else{
|
||||
return array(
|
||||
array($this->id, $this->meta, 1),
|
||||
|
@ -52,7 +52,7 @@ class Bricks extends Solid{
|
||||
array(Item::BRICKS_BLOCK, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ class BurningFurnace extends Solid{
|
||||
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
|
||||
$this->getLevel()->setBlock($block, $this, true, false, true);
|
||||
$nbt = new Compound(false, array(
|
||||
new Enum("Items", array()),
|
||||
new Enum("Items", []),
|
||||
new String("id", Tile::FURNACE),
|
||||
new Int("x", $this->x),
|
||||
new Int("y", $this->y),
|
||||
@ -74,7 +74,7 @@ class BurningFurnace extends Solid{
|
||||
$furnace = $t;
|
||||
}else{
|
||||
$nbt = new Compound(false, array(
|
||||
new Enum("Items", array()),
|
||||
new Enum("Items", []),
|
||||
new String("id", Tile::FURNACE),
|
||||
new Int("x", $this->x),
|
||||
new Int("y", $this->y),
|
||||
@ -112,7 +112,7 @@ class BurningFurnace extends Solid{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = array();
|
||||
$drops = [];
|
||||
if($item->isPickaxe() >= 1){
|
||||
$drops[] = array(Item::FURNACE, 0, 1);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class Cake extends Transparent{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
|
@ -81,7 +81,7 @@ class Carrot extends Flowable{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = array();
|
||||
$drops = [];
|
||||
if($this->meta >= 0x07){
|
||||
$drops[] = array(Item::CARROT, 0, mt_rand(1, 4));
|
||||
}else{
|
||||
|
@ -69,7 +69,7 @@ class Chest extends Transparent{
|
||||
|
||||
$this->getLevel()->setBlock($block, $this, true, false, true);
|
||||
$nbt = new Compound(false, array(
|
||||
new Enum("Items", array()),
|
||||
new Enum("Items", []),
|
||||
new String("id", Tile::CHEST),
|
||||
new Int("x", $this->x),
|
||||
new Int("y", $this->y),
|
||||
@ -109,7 +109,7 @@ class Chest extends Transparent{
|
||||
$chest = $t;
|
||||
}else{
|
||||
$nbt = new Compound(false, array(
|
||||
new Enum("Items", array()),
|
||||
new Enum("Items", []),
|
||||
new String("id", Tile::CHEST),
|
||||
new Int("x", $this->x),
|
||||
new Int("y", $this->y),
|
||||
|
@ -52,7 +52,7 @@ class Coal extends Solid{
|
||||
array(Item::COAL_BLOCK, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -52,7 +52,7 @@ class CoalOre extends Solid{
|
||||
array(Item::COAL, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class Cobblestone extends Solid{
|
||||
array(Item::COBBLESTONE, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -32,6 +32,6 @@ class Cobweb extends Flowable{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ class Diamond extends Solid{
|
||||
array(Item::DIAMOND_BLOCK, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ class DiamondOre extends Solid{
|
||||
array(Item::DIAMOND, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -62,7 +62,7 @@ class DoubleSlab extends Solid{
|
||||
array(Item::SLAB, $this->meta & 0x07, 2),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class Fire extends Flowable{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -30,6 +30,6 @@ class Glass extends Transparent{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ class GlowingRedstoneOre extends Solid{
|
||||
array(Item::REDSTONE_DUST, 0, mt_rand(4, 5)),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ class Gold extends Solid{
|
||||
array(Item::GOLD_BLOCK, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ class GoldOre extends Solid{
|
||||
array(Item::GOLD_ORE, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -53,6 +53,6 @@ class Ice extends Transparent{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ class Iron extends Solid{
|
||||
array(Item::IRON_BLOCK, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@ class IronDoor extends Door{
|
||||
array(Item::IRON_DOOR, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ class IronOre extends Solid{
|
||||
array(Item::IRON_ORE, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ class Lapis extends Solid{
|
||||
array(Item::LAPIS_BLOCK, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ class LapisOre extends Solid{
|
||||
array(Item::DYE, 4, mt_rand(4, 8)),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ class Leaves extends Transparent{
|
||||
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
|
||||
if(($this->meta & 0b00001100) === 0x08){
|
||||
$this->meta &= 0x03;
|
||||
$visited = array();
|
||||
$visited = [];
|
||||
$check = 0;
|
||||
if($this->findLog($this, $visited, 0, $check) === true){
|
||||
$this->getLevel()->setBlock($this, $this, false, false, true);
|
||||
@ -146,7 +146,7 @@ class Leaves extends Transparent{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = array();
|
||||
$drops = [];
|
||||
if($item->isShears()){
|
||||
$drops[] = array(Item::LEAVES, $this->meta & 0x03, 1);
|
||||
}else{
|
||||
|
@ -53,7 +53,7 @@ class MossStone extends Solid{
|
||||
array(Item::MOSS_STONE, $this->meta, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@ class NetherBrick extends Solid{
|
||||
array(Item::NETHER_BRICKS, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@ class Netherrack extends Solid{
|
||||
array(Item::NETHERRACK, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -44,7 +44,7 @@ class Obsidian extends Solid{
|
||||
array(Item::OBSIDIAN, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -83,7 +83,7 @@ class Potato extends Flowable{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = array();
|
||||
$drops = [];
|
||||
if($this->meta >= 0x07){
|
||||
$drops[] = array(Item::POTATO, 0, mt_rand(1, 4));
|
||||
}else{
|
||||
|
@ -59,7 +59,7 @@ class Quartz extends Solid{
|
||||
array(Item::QUARTZ_BLOCK, $this->meta & 0x03, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ class RedstoneOre extends Solid{
|
||||
array(Item::REDSTONE_DUST, 0, mt_rand(4, 5)),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -59,7 +59,7 @@ class Sandstone extends Solid{
|
||||
array(Item::SANDSTONE, $this->meta & 0x03, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ class Slab extends Transparent{
|
||||
array($this->id, $this->meta & 0x07, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -64,6 +64,6 @@ class SnowLayer extends Flowable{
|
||||
);
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ class Stair extends Transparent{
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@ class Stone extends Solid{
|
||||
array(Item::COBBLESTONE, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ class StoneBricks extends Solid{
|
||||
array(Item::STONE_BRICKS, $this->meta & 0x03, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class TallGrass extends Flowable{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = array();
|
||||
$drops = [];
|
||||
$possibleDrops = array(
|
||||
array(Item::WHEAT_SEEDS, 0, 1),
|
||||
array(Item::CARROT, 0, 1),
|
||||
|
@ -79,7 +79,7 @@ class Wheat extends Flowable{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = array();
|
||||
$drops = [];
|
||||
if($this->meta >= 0x07){
|
||||
$drops[] = array(Item::WHEAT, 0, 1);
|
||||
$drops[] = array(Item::WHEAT_SEEDS, 0, mt_rand(0, 3));
|
||||
|
@ -40,12 +40,12 @@ abstract class Command{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $aliases = array();
|
||||
private $aliases = [];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $activeAliases = array();
|
||||
private $activeAliases = [];
|
||||
|
||||
/** @var CommandMap */
|
||||
private $commandMap = null;
|
||||
@ -68,7 +68,7 @@ abstract class Command{
|
||||
* @param string $usageMessage
|
||||
* @param string[] $aliases
|
||||
*/
|
||||
public function __construct($name, $description = "", $usageMessage = null, array $aliases = array()){
|
||||
public function __construct($name, $description = "", $usageMessage = null, array $aliases = []){
|
||||
$this->name = $name;
|
||||
$this->nextLabel = $name;
|
||||
$this->label = $name;
|
||||
|
@ -61,7 +61,7 @@ class SimpleCommandMap implements CommandMap{
|
||||
/**
|
||||
* @var Command[]
|
||||
*/
|
||||
protected $knownCommands = array();
|
||||
protected $knownCommands = [];
|
||||
|
||||
/** @var Server */
|
||||
private $server;
|
||||
@ -184,7 +184,7 @@ class SimpleCommandMap implements CommandMap{
|
||||
foreach($this->knownCommands as $command){
|
||||
$command->unregister($this);
|
||||
}
|
||||
$this->knownCommands = array();
|
||||
$this->knownCommands = [];
|
||||
$this->setDefaultCommands();
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ class HelpCommand extends VanillaCommand{
|
||||
}
|
||||
|
||||
if($command === ""){
|
||||
$commands = array();
|
||||
$commands = [];
|
||||
foreach(Server::getInstance()->getCommandMap()->getCommands() as $command){
|
||||
if($command->testPermissionSilent($sender)){
|
||||
$commands[$command->getName()] = $command;
|
||||
|
@ -29,7 +29,7 @@ abstract class VanillaCommand extends Command{
|
||||
const MAX_COORD = 524288;
|
||||
const MIN_COORD = -524288;
|
||||
|
||||
public function __construct($name, $description = "", $usageMessage = null, array $aliases = array()){
|
||||
public function __construct($name, $description = "", $usageMessage = null, array $aliases = []){
|
||||
parent::__construct($name, $description, $usageMessage, $aliases);
|
||||
}
|
||||
|
||||
|
@ -53,17 +53,17 @@ abstract class Entity extends Position implements Metadatable{
|
||||
/**
|
||||
* @var Entity[]
|
||||
*/
|
||||
public static $list = array();
|
||||
public static $list = [];
|
||||
|
||||
/**
|
||||
* @var Entity[]
|
||||
*/
|
||||
public static $needUpdate = array();
|
||||
public static $needUpdate = [];
|
||||
|
||||
/**
|
||||
* @var Player[]
|
||||
*/
|
||||
protected $hasSpawned = array();
|
||||
protected $hasSpawned = [];
|
||||
|
||||
protected $id;
|
||||
|
||||
@ -424,7 +424,7 @@ abstract class Entity extends Position implements Metadatable{
|
||||
$this->setLevel($targetLevel, true); //Hard reference
|
||||
$this->getLevel()->entities[$this->id] = $this; //Oops, TODO!!
|
||||
if($this instanceof Player){
|
||||
$this->chunksLoaded = array();
|
||||
$this->chunksLoaded = [];
|
||||
$pk = new SetTimePacket();
|
||||
$pk->time = $this->getLevel()->getTime();
|
||||
$pk->started = $this->getLevel()->stopTime == false;
|
||||
|
@ -42,10 +42,10 @@ use pocketmine\Server;
|
||||
class Human extends Creature implements ProjectileSource, InventorySource{
|
||||
|
||||
protected $nameTag = "TESTIFICATE";
|
||||
protected $inventory = array();
|
||||
protected $inventory = [];
|
||||
public $slot;
|
||||
protected $hotbar = array();
|
||||
protected $armor = array();
|
||||
protected $hotbar = [];
|
||||
protected $armor = [];
|
||||
|
||||
protected function initEntity(){
|
||||
if(isset($this->namedtag->NameTag)){
|
||||
@ -76,7 +76,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
|
||||
|
||||
public function saveNBT(){
|
||||
parent::saveNBT();
|
||||
$this->namedtag->Inventory = new Enum("Inventory", array());
|
||||
$this->namedtag->Inventory = new Enum("Inventory", []);
|
||||
$this->namedtag->Inventory->setTagType(NBT::TAG_Compound);
|
||||
for($slot = 0; $slot < 9; ++$slot){
|
||||
if(isset($this->hotbar[$slot]) and $this->hotbar[$slot] !== -1){
|
||||
@ -240,7 +240,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
|
||||
}
|
||||
|
||||
public function sendArmor($player = null){
|
||||
$slots = array();
|
||||
$slots = [];
|
||||
for($i = 0; $i < 4; ++$i){
|
||||
if(isset($this->armor[$i]) and ($this->armor[$i] instanceof Item) and $this->armor[$i]->getID() > Item::AIR){
|
||||
$slots[$i] = $this->armor[$i]->getID() !== Item::AIR ? $this->armor[$i]->getID() - 256 : 0;
|
||||
|
@ -34,12 +34,12 @@ class HandlerList{
|
||||
/**
|
||||
* @var RegisteredListener[][]
|
||||
*/
|
||||
private $handlerSlots = array();
|
||||
private $handlerSlots = [];
|
||||
|
||||
/**
|
||||
* @var HandlerList[]
|
||||
*/
|
||||
private static $allLists = array();
|
||||
private static $allLists = [];
|
||||
|
||||
public static function bakeAll(){
|
||||
foreach(self::$allLists as $h){
|
||||
@ -61,7 +61,7 @@ class HandlerList{
|
||||
}else{
|
||||
foreach(self::$allLists as $h){
|
||||
foreach($h->handlerSlots as $key => $list){
|
||||
$h->handlerSlots[$key] = array();
|
||||
$h->handlerSlots[$key] = [];
|
||||
}
|
||||
$h->handlers = null;
|
||||
}
|
||||
@ -70,12 +70,12 @@ class HandlerList{
|
||||
|
||||
public function __construct(){
|
||||
$this->handlerSlots = array(
|
||||
EventPriority::MONITOR => array(),
|
||||
EventPriority::HIGHEST => array(),
|
||||
EventPriority::HIGH => array(),
|
||||
EventPriority::NORMAL => array(),
|
||||
EventPriority::LOW => array(),
|
||||
EventPriority::LOWEST => array()
|
||||
EventPriority::MONITOR => [],
|
||||
EventPriority::HIGHEST => [],
|
||||
EventPriority::HIGH => [],
|
||||
EventPriority::NORMAL => [],
|
||||
EventPriority::LOW => [],
|
||||
EventPriority::LOWEST => []
|
||||
);
|
||||
self::$allLists[] = $this;
|
||||
}
|
||||
@ -133,7 +133,7 @@ class HandlerList{
|
||||
if($this->handlers !== null){
|
||||
return;
|
||||
}
|
||||
$entries = array();
|
||||
$entries = [];
|
||||
foreach($this->handlerSlots as $list){
|
||||
foreach($list as $hash => $listener){
|
||||
$entries[$hash] = $listener;
|
||||
@ -149,7 +149,7 @@ class HandlerList{
|
||||
*/
|
||||
public function getRegisteredListeners($plugin = null){
|
||||
if($plugin instanceof Plugin){
|
||||
$listeners = array();
|
||||
$listeners = [];
|
||||
foreach($this->getRegisteredListeners(null) as $hash => $listener){
|
||||
if($listener->getPlugin() === $plugin){
|
||||
$listeners[$hash] = $plugin;
|
||||
|
@ -40,7 +40,7 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{
|
||||
/**
|
||||
* @var Player[]
|
||||
*/
|
||||
protected $recipients = array();
|
||||
protected $recipients = [];
|
||||
|
||||
public function __construct(Player $player, $message, $format = "<%s> %s", array $recipients = null){
|
||||
$this->player = $player;
|
||||
|
153
src/pocketmine/inventory/Inventory.php
Normal file
153
src/pocketmine/inventory/Inventory.php
Normal 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();
|
||||
}
|
32
src/pocketmine/inventory/InventoryHolder.php
Normal file
32
src/pocketmine/inventory/InventoryHolder.php
Normal 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();
|
||||
}
|
77
src/pocketmine/inventory/InventoryType.php
Normal file
77
src/pocketmine/inventory/InventoryType.php
Normal 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;
|
||||
}
|
||||
}
|
39
src/pocketmine/inventory/SlotType.php
Normal file
39
src/pocketmine/inventory/SlotType.php
Normal 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;
|
||||
}
|
@ -359,7 +359,7 @@ class Item{
|
||||
|
||||
|
||||
/** @var Item[] */
|
||||
public static $list = array();
|
||||
public static $list = [];
|
||||
protected $block;
|
||||
protected $id;
|
||||
protected $meta;
|
||||
@ -447,7 +447,7 @@ class Item{
|
||||
|
||||
public static function fromString($str, $multiple = false){
|
||||
if($multiple === true){
|
||||
$blocks = array();
|
||||
$blocks = [];
|
||||
foreach(explode(",", $str) as $b){
|
||||
$blocks[] = self::fromString($b, false);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class Explosion{
|
||||
/**
|
||||
* @var Block[]
|
||||
*/
|
||||
public $affectedBlocks = array();
|
||||
public $affectedBlocks = [];
|
||||
public $stepLen = 0.3;
|
||||
private $what;
|
||||
|
||||
@ -95,7 +95,7 @@ class Explosion{
|
||||
}
|
||||
}
|
||||
|
||||
$send = array();
|
||||
$send = [];
|
||||
$source = $this->source->floor();
|
||||
$radius = 2 * $this->size;
|
||||
$yield = (1 / $this->size) * 100;
|
||||
|
@ -64,19 +64,19 @@ class Level{
|
||||
const BLOCK_UPDATE_TOUCH = 5;
|
||||
|
||||
/** @var Player[] */
|
||||
public $players = array();
|
||||
public $players = [];
|
||||
|
||||
/** @var Entity[] */
|
||||
public $entities = array();
|
||||
public $entities = [];
|
||||
|
||||
/** @var Entity[][] */
|
||||
public $chunkEntities = array();
|
||||
public $chunkEntities = [];
|
||||
|
||||
/** @var Tile[] */
|
||||
public $tiles = array();
|
||||
public $tiles = [];
|
||||
|
||||
/** @var Tile[][] */
|
||||
public $chunkTiles = array();
|
||||
public $chunkTiles = [];
|
||||
|
||||
public $nextSave;
|
||||
|
||||
@ -116,9 +116,9 @@ class Level{
|
||||
$this->nextSave += 90;
|
||||
$this->stopTime = false;
|
||||
$this->name = $name;
|
||||
$this->usedChunks = array();
|
||||
$this->changedBlocks = array();
|
||||
$this->changedCount = array();
|
||||
$this->usedChunks = [];
|
||||
$this->changedBlocks = [];
|
||||
$this->changedCount = [];
|
||||
$gen = Generator::getGenerator($this->level->levelData["generator"]);
|
||||
$this->generator = new $gen((array) $this->level->levelData["generatorSettings"]);
|
||||
$this->generator->init($this, new Random($this->level->levelData["seed"]));
|
||||
@ -184,7 +184,7 @@ class Level{
|
||||
public function getUsingChunk($X, $Z){
|
||||
$index = LevelFormat::getIndex($X, $Z);
|
||||
|
||||
return isset($this->usedChunks[$index]) ? $this->usedChunks[$index] : array();
|
||||
return isset($this->usedChunks[$index]) ? $this->usedChunks[$index] : [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,7 +292,7 @@ class Level{
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->changedCount = array();
|
||||
$this->changedCount = [];
|
||||
|
||||
if(count($this->changedBlocks) > 0){
|
||||
foreach($this->changedBlocks as $index => $mini){
|
||||
@ -308,7 +308,7 @@ class Level{
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->changedBlocks = array();
|
||||
$this->changedBlocks = [];
|
||||
}
|
||||
|
||||
$X = null;
|
||||
@ -429,8 +429,8 @@ class Level{
|
||||
foreach($this->usedChunks as $index => $d){
|
||||
LevelFormat::getXZ($index, $X, $Z);
|
||||
$nbt = new Compound("", array(
|
||||
new Enum("Entities", array()),
|
||||
new Enum("TileEntities", array()),
|
||||
new Enum("Entities", []),
|
||||
new Enum("TileEntities", []),
|
||||
));
|
||||
$nbt->Entities->setTagType(NBT::TAG_Compound);
|
||||
$nbt->TileEntities->setTagType(NBT::TAG_Compound);
|
||||
@ -531,12 +531,12 @@ class Level{
|
||||
Cache::remove("world:{$this->name}:{$index}");
|
||||
}
|
||||
if(!isset($this->changedBlocks[$index])){
|
||||
$this->changedBlocks[$index] = array();
|
||||
$this->changedBlocks[$index] = [];
|
||||
$this->changedCount[$index] = 0;
|
||||
}
|
||||
$Y = $pos->y >> 4;
|
||||
if(!isset($this->changedBlocks[$index][$Y])){
|
||||
$this->changedBlocks[$index][$Y] = array();
|
||||
$this->changedBlocks[$index][$Y] = [];
|
||||
$this->changedCount[$index] |= 1 << $Y;
|
||||
}
|
||||
$this->changedBlocks[$index][$Y][] = clone $block;
|
||||
@ -581,12 +581,12 @@ class Level{
|
||||
Cache::remove("world:{$this->name}:{$index}");
|
||||
}
|
||||
if(!isset($this->changedBlocks[$index])){
|
||||
$this->changedBlocks[$index] = array();
|
||||
$this->changedBlocks[$index] = [];
|
||||
$this->changedCount[$index] = 0;
|
||||
}
|
||||
$Y = $pos->y >> 4;
|
||||
if(!isset($this->changedBlocks[$index][$Y])){
|
||||
$this->changedBlocks[$index][$Y] = array();
|
||||
$this->changedBlocks[$index][$Y] = [];
|
||||
$this->changedCount[$index] |= 1 << $Y;
|
||||
}
|
||||
$this->changedBlocks[$index][$Y][] = clone $block;
|
||||
@ -896,7 +896,7 @@ class Level{
|
||||
return $this->chunkEntities[$index];
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -913,7 +913,7 @@ class Level{
|
||||
return $this->chunkTiles[$index];
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -929,9 +929,9 @@ class Level{
|
||||
if(isset($this->usedChunks[$index])){
|
||||
return true;
|
||||
}elseif($this->level->loadChunk($X, $Z) !== false){
|
||||
$this->usedChunks[$index] = array();
|
||||
$this->chunkTiles[$index] = array();
|
||||
$this->chunkEntities[$index] = array();
|
||||
$this->usedChunks[$index] = [];
|
||||
$this->chunkTiles[$index] = [];
|
||||
$this->chunkEntities[$index] = [];
|
||||
$tags = $this->level->getChunkNBT($X, $Z);
|
||||
if(isset($tags->Entities)){
|
||||
foreach($tags->Entities as $nbt){
|
||||
@ -1027,7 +1027,7 @@ class Level{
|
||||
}
|
||||
|
||||
|
||||
$raw = array();
|
||||
$raw = [];
|
||||
for($Y = 0; $Y < 8; ++$Y){
|
||||
if(($Yndex & (1 << $Y)) !== 0){
|
||||
$raw[$Y] = $this->level->getMiniChunk($X, $Z, $Y);
|
||||
|
@ -53,7 +53,7 @@ class LevelImport{
|
||||
$nbt->read(substr(file_get_contents($this->path . "entities.dat"), 12));
|
||||
$entities = $nbt->getData();
|
||||
if(!isset($entities->TileEntities)){
|
||||
$entities->TileEntities = array();
|
||||
$entities->TileEntities = [];
|
||||
}
|
||||
$tiles = $entities->TileEntities;
|
||||
$entities = $entities->Entities;
|
||||
|
@ -35,13 +35,13 @@ class PocketChunkParser{
|
||||
private $file;
|
||||
public $sectorLength = 4096; //16 * 16 * 16
|
||||
public $chunkLength = 86016; //21 * $sectorLength
|
||||
public $map = array();
|
||||
public $map = [];
|
||||
|
||||
public function __construct(){
|
||||
}
|
||||
|
||||
private function loadLocationTable(){
|
||||
$this->location = array();
|
||||
$this->location = [];
|
||||
console("[DEBUG] Loading Chunk Location table...", true, true, 2);
|
||||
for($offset = 0; $offset < 0x1000; $offset += 4){
|
||||
$data = Binary::readLInt(substr($this->raw, $offset, 4));
|
||||
@ -116,10 +116,10 @@ class PocketChunkParser{
|
||||
$len = Binary::readLInt(substr($this->raw, $offset, 4));
|
||||
$offset += 4;
|
||||
$chunk = array(
|
||||
0 => array(), //Block
|
||||
1 => array(), //Data
|
||||
2 => array(), //SkyLight
|
||||
3 => array(), //BlockLight
|
||||
0 => [], //Block
|
||||
1 => [], //Data
|
||||
2 => [], //SkyLight
|
||||
3 => [], //BlockLight
|
||||
);
|
||||
foreach($chunk as $section => &$data){
|
||||
$l = $section === 0 ? 128 : 64;
|
||||
@ -139,7 +139,7 @@ class PocketChunkParser{
|
||||
$this->loadLocationTable();
|
||||
console("[DEBUG] Loading chunks...", true, true, 2);
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
$this->map[$x] = array();
|
||||
$this->map[$x] = [];
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
$this->map[$x][$z] = $this->parseChunk($x, $z);
|
||||
}
|
||||
|
@ -38,32 +38,32 @@ class Chunk extends BaseChunk{
|
||||
if($this->nbt->Entities instanceof Enum){
|
||||
$this->nbt->Entities->setTagType(NBT::TAG_Compound);
|
||||
}else{
|
||||
$this->nbt->Entities = new Enum("Entities", array());
|
||||
$this->nbt->Entities = new Enum("Entities", []);
|
||||
$this->nbt->Entities->setTagType(NBT::TAG_Compound);
|
||||
}
|
||||
|
||||
if($this->nbt->TileEntities instanceof Enum){
|
||||
$this->nbt->TileEntities->setTagType(NBT::TAG_Compound);
|
||||
}else{
|
||||
$this->nbt->TileEntities = new Enum("TileEntities", array());
|
||||
$this->nbt->TileEntities = new Enum("TileEntities", []);
|
||||
$this->nbt->TileEntities->setTagType(NBT::TAG_Compound);
|
||||
}
|
||||
|
||||
if($this->nbt->TileTicks instanceof Enum){
|
||||
$this->nbt->TileTicks->setTagType(NBT::TAG_Compound);
|
||||
}else{
|
||||
$this->nbt->TileTicks = new Enum("TileTicks", array());
|
||||
$this->nbt->TileTicks = new Enum("TileTicks", []);
|
||||
$this->nbt->TileTicks->setTagType(NBT::TAG_Compound);
|
||||
}
|
||||
|
||||
if($this->nbt->Sections instanceof Enum){
|
||||
$this->nbt->Sections->setTagType(NBT::TAG_Compound);
|
||||
}else{
|
||||
$this->nbt->Sections = new Enum("Sections", array());
|
||||
$this->nbt->Sections = new Enum("Sections", []);
|
||||
$this->nbt->Sections->setTagType(NBT::TAG_Compound);
|
||||
}
|
||||
|
||||
$sections = array();
|
||||
$sections = [];
|
||||
foreach($this->nbt->Sections as $section){
|
||||
if($section instanceof Compound){
|
||||
$sections[(int) $section["Y"]] = new ChunkSection($section);
|
||||
|
@ -43,7 +43,7 @@ class RegionLoader{
|
||||
protected $filePath;
|
||||
protected $filePointer;
|
||||
protected $lastSector;
|
||||
protected $locationTable = array();
|
||||
protected $locationTable = [];
|
||||
|
||||
public function __construct($path,/*Level $level, */$regionX, $regionZ){
|
||||
$this->x = $regionX;
|
||||
@ -118,7 +118,7 @@ class RegionLoader{
|
||||
}
|
||||
|
||||
public function generateChunk($x, $z){
|
||||
$nbt = new Compound("Level", array());
|
||||
$nbt = new Compound("Level", []);
|
||||
$nbt->xPos = new Int("xPos", ($this->getX() * 32) + $x);
|
||||
$nbt->zPos = new Int("xPos", ($this->getZ() * 32) + $z);
|
||||
$nbt->LastUpdate = new Long("LastUpdate", 0);
|
||||
@ -128,13 +128,13 @@ class RegionLoader{
|
||||
$nbt->InhabitedTime = new Long("InhabitedTime", 0);
|
||||
$nbt->Biomes = new ByteArray("Biomes", str_repeat(Binary::writeByte(-1), 256));
|
||||
$nbt->HeightMap = new IntArray("HeightMap", array_fill(0, 256, 127));
|
||||
$nbt->Sections = new Enum("Sections", array());
|
||||
$nbt->Sections = new Enum("Sections", []);
|
||||
$nbt->Sections->setTagType(NBT::TAG_Compound);
|
||||
$nbt->Entities = new Enum("Entities", array());
|
||||
$nbt->Entities = new Enum("Entities", []);
|
||||
$nbt->Entities->setTagType(NBT::TAG_Compound);
|
||||
$nbt->TileEntities = new Enum("TileEntities", array());
|
||||
$nbt->TileEntities = new Enum("TileEntities", []);
|
||||
$nbt->TileEntities->setTagType(NBT::TAG_Compound);
|
||||
$nbt->TileTicks = new Enum("TileTicks", array());
|
||||
$nbt->TileTicks = new Enum("TileTicks", []);
|
||||
$nbt->TileTicks->setTagType(NBT::TAG_Compound);
|
||||
$writer = new NBT(NBT::BIG_ENDIAN);
|
||||
$writer->setData(new Compound("", array($nbt)));
|
||||
@ -187,7 +187,7 @@ class RegionLoader{
|
||||
}
|
||||
|
||||
private function cleanGarbage(){
|
||||
$sectors = array();
|
||||
$sectors = [];
|
||||
foreach($this->locationTable as $index => $data){ //Calculate file usage
|
||||
if($data[0] === 0 or $data[1] === 0){
|
||||
$this->locationTable[$index] = array(0, 0, 0);
|
||||
|
@ -27,7 +27,7 @@ use pocketmine\level\Level;
|
||||
abstract class BaseChunk implements Chunk{
|
||||
|
||||
/** @var ChunkSection[] */
|
||||
protected $sections = array();
|
||||
protected $sections = [];
|
||||
protected $level;
|
||||
|
||||
protected $x;
|
||||
|
@ -34,11 +34,11 @@ class LevelFormat extends PMF{
|
||||
const ZLIB_ENCODING = 15; //15 = zlib, -15 = raw deflate, 31 = gzip
|
||||
|
||||
public $level;
|
||||
public $levelData = array();
|
||||
public $levelData = [];
|
||||
public $isLoaded = true;
|
||||
private $chunks = array();
|
||||
private $chunkChange = array();
|
||||
private $chunkInfo = array();
|
||||
private $chunks = [];
|
||||
private $chunkChange = [];
|
||||
private $chunkInfo = [];
|
||||
public $isGenerating = 0;
|
||||
|
||||
public function getData($index){
|
||||
@ -69,9 +69,9 @@ class LevelFormat extends PMF{
|
||||
* @param bool|array $blank default false
|
||||
*/
|
||||
public function __construct($file, $blank = false){
|
||||
$this->chunks = array();
|
||||
$this->chunkChange = array();
|
||||
$this->chunkInfo = array();
|
||||
$this->chunks = [];
|
||||
$this->chunkChange = [];
|
||||
$this->chunkInfo = [];
|
||||
if(is_array($blank)){
|
||||
$this->create($file, 0);
|
||||
$this->levelData = $blank;
|
||||
@ -189,8 +189,8 @@ class LevelFormat extends PMF{
|
||||
private function upgrade_From1_To2(){
|
||||
console("[NOTICE] Old PMF Level format version #1 detected, upgrading to version #2");
|
||||
$nbt = new Compound("", array(
|
||||
new Enum("Entities", array()),
|
||||
new Enum("TileEntities", array())
|
||||
new Enum("Entities", []),
|
||||
new Enum("TileEntities", [])
|
||||
));
|
||||
$nbt->Entities->setTagType(NBT::TAG_Compound);
|
||||
$nbt->TileEntities->setTagType(NBT::TAG_Compound);
|
||||
@ -301,7 +301,7 @@ class LevelFormat extends PMF{
|
||||
$nbt->read(substr($chunk, $offset, $len));
|
||||
$this->chunkInfo[$index][2] = $nbt->getData();
|
||||
$offset += $len;
|
||||
$this->chunks[$index] = array();
|
||||
$this->chunks[$index] = [];
|
||||
$this->chunkChange[$index] = array(-1 => false);
|
||||
$this->chunkInfo[$index][3] = substr($chunk, $offset, 256); //Biome data
|
||||
$offset += 256;
|
||||
@ -421,8 +421,8 @@ class LevelFormat extends PMF{
|
||||
7 => 8192,
|
||||
);
|
||||
$nbt = new Compound("", array(
|
||||
new Enum("Entities", array()),
|
||||
new Enum("TileEntities", array())
|
||||
new Enum("Entities", []),
|
||||
new Enum("TileEntities", [])
|
||||
));
|
||||
$nbt->Entities->setTagType(NBT::TAG_Compound);
|
||||
$nbt->TileEntities->setTagType(NBT::TAG_Compound);
|
||||
|
@ -37,7 +37,7 @@ use pocketmine\math\Vector3 as Vector3;
|
||||
use pocketmine\utils\Random;
|
||||
|
||||
class Flat extends Generator{
|
||||
private $level, $random, $structure, $chunks, $options, $floorLevel, $preset, $populators = array();
|
||||
private $level, $random, $structure, $chunks, $options, $floorLevel, $preset, $populators = [];
|
||||
|
||||
public function getSettings(){
|
||||
return $this->options;
|
||||
@ -47,7 +47,7 @@ class Flat extends Generator{
|
||||
return "flat";
|
||||
}
|
||||
|
||||
public function __construct(array $options = array()){
|
||||
public function __construct(array $options = []){
|
||||
$this->preset = "2;7,59x1,3x3,2;1;spawn(radius=10 block=89),decoration(treecount=80 grasscount=45)";
|
||||
$this->options = $options;
|
||||
if(isset($options["preset"])){
|
||||
@ -84,8 +84,8 @@ class Flat extends Generator{
|
||||
$options = isset($preset[3]) ? $preset[3] : "";
|
||||
preg_match_all('#(([0-9]{0,})x?([0-9]{1,3}:?[0-9]{0,2})),?#', $blocks, $matches);
|
||||
$y = 0;
|
||||
$this->structure = array();
|
||||
$this->chunks = array();
|
||||
$this->structure = [];
|
||||
$this->chunks = [];
|
||||
foreach($matches[3] as $i => $b){
|
||||
$b = Item::fromString($b);
|
||||
$cnt = $matches[2][$i] === "" ? 1 : intval($matches[2][$i]);
|
||||
@ -122,7 +122,7 @@ class Flat extends Generator{
|
||||
foreach($matches[2] as $i => $option){
|
||||
$params = true;
|
||||
if($matches[3][$i] !== ""){
|
||||
$params = array();
|
||||
$params = [];
|
||||
$p = explode(" ", $matches[3][$i]);
|
||||
foreach($p as $k){
|
||||
$k = explode("=", $k);
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\level\Level;
|
||||
use pocketmine\utils\Random;
|
||||
|
||||
abstract class Generator{
|
||||
private static $list = array();
|
||||
private static $list = [];
|
||||
|
||||
public static function addGenerator($object, $name){
|
||||
if(is_subclass_of($object, "pocketmine\\level\\generator\\Generator") and !isset(Generator::$list[$name])){
|
||||
@ -48,7 +48,7 @@ abstract class Generator{
|
||||
return "pocketmine\\level\\generator\\Normal";
|
||||
}
|
||||
|
||||
public abstract function __construct(array $settings = array());
|
||||
public abstract function __construct(array $settings = []);
|
||||
|
||||
public abstract function init(Level $level, Random $random);
|
||||
|
||||
|
@ -40,7 +40,7 @@ use pocketmine\utils\Random;
|
||||
|
||||
class Normal extends Generator{
|
||||
|
||||
private $populators = array();
|
||||
private $populators = [];
|
||||
private $level;
|
||||
private $random;
|
||||
private $worldHeight = 65;
|
||||
@ -50,7 +50,7 @@ class Normal extends Generator{
|
||||
private $noisePatchesSmall;
|
||||
private $noiseBase;
|
||||
|
||||
public function __construct(array $options = array()){
|
||||
public function __construct(array $options = []){
|
||||
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ class Normal extends Generator{
|
||||
}
|
||||
|
||||
public function getSettings(){
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function init(Level $level, Random $random){
|
||||
@ -98,10 +98,10 @@ class Normal extends Generator{
|
||||
|
||||
public function generateChunk($chunkX, $chunkZ){
|
||||
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
|
||||
$hills = array();
|
||||
$patches = array();
|
||||
$patchesSmall = array();
|
||||
$base = array();
|
||||
$hills = [];
|
||||
$patches = [];
|
||||
$patchesSmall = [];
|
||||
$base = [];
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
$i = ($z << 4) + $x;
|
||||
|
@ -29,7 +29,7 @@ namespace pocketmine\level\generator\noise;
|
||||
|
||||
|
||||
abstract class Generator{
|
||||
protected $perm = array();
|
||||
protected $perm = [];
|
||||
protected $offsetX = 0;
|
||||
protected $offsetY = 0;
|
||||
protected $offsetZ = 0;
|
||||
|
@ -27,7 +27,7 @@ use pocketmine\math\Vector3 as Vector3;
|
||||
use pocketmine\utils\Random;
|
||||
|
||||
class Ore extends Populator{
|
||||
private $oreTypes = array();
|
||||
private $oreTypes = [];
|
||||
|
||||
public function populate(Level $level, $chunkX, $chunkZ, Random $random){
|
||||
foreach($this->oreTypes as $type){
|
||||
|
@ -23,7 +23,7 @@ namespace pocketmine\math;
|
||||
|
||||
|
||||
class Matrix implements \ArrayAccess{
|
||||
private $matrix = array();
|
||||
private $matrix = [];
|
||||
private $rows = 0;
|
||||
private $columns = 0;
|
||||
|
||||
@ -43,7 +43,7 @@ class Matrix implements \ArrayAccess{
|
||||
unset($this->matrix[(int) $offset]);
|
||||
}
|
||||
|
||||
public function __construct($rows, $columns, array $set = array()){
|
||||
public function __construct($rows, $columns, array $set = []){
|
||||
$this->rows = max(1, (int) $rows);
|
||||
$this->columns = max(1, (int) $columns);
|
||||
$this->set($set);
|
||||
@ -51,7 +51,7 @@ class Matrix implements \ArrayAccess{
|
||||
|
||||
public function set(array $m){
|
||||
for($r = 0; $r < $this->rows; ++$r){
|
||||
$this->matrix[$r] = array();
|
||||
$this->matrix[$r] = [];
|
||||
for($c = 0; $c < $this->columns; ++$c){
|
||||
$this->matrix[$r][$c] = isset($m[$r][$c]) ? $m[$r][$c] : 0;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ use pocketmine\nbt\NBT;
|
||||
|
||||
class Compound extends NamedTag implements \ArrayAccess{
|
||||
|
||||
public function __construct($name = "", $value = array()){
|
||||
public function __construct($name = "", $value = []){
|
||||
$this->name = $name;
|
||||
foreach($value as $tag){
|
||||
$this->{$tag->getName()} = $tag;
|
||||
@ -65,7 +65,7 @@ class Compound extends NamedTag implements \ArrayAccess{
|
||||
}
|
||||
|
||||
public function read(NBT $nbt){
|
||||
$this->value = array();
|
||||
$this->value = [];
|
||||
do{
|
||||
$tag = $nbt->readTag();
|
||||
if($tag instanceof NamedTag and $tag->getName() !== ""){
|
||||
|
@ -28,7 +28,7 @@ class Enum extends NamedTag implements \ArrayAccess{
|
||||
|
||||
private $tagType;
|
||||
|
||||
public function __construct($name = "", $value = array()){
|
||||
public function __construct($name = "", $value = []){
|
||||
$this->name = $name;
|
||||
foreach($value as $k => $v){
|
||||
$this->{$k} = $v;
|
||||
@ -76,7 +76,7 @@ class Enum extends NamedTag implements \ArrayAccess{
|
||||
}
|
||||
|
||||
public function read(NBT $nbt){
|
||||
$this->value = array();
|
||||
$this->value = [];
|
||||
$this->tagType = $nbt->getByte();
|
||||
$size = $nbt->getInt();
|
||||
for($i = 0; $i < $size and !$nbt->feof(); ++$i){
|
||||
@ -156,7 +156,7 @@ class Enum extends NamedTag implements \ArrayAccess{
|
||||
|
||||
$nbt->putByte($this->tagType);
|
||||
|
||||
$tags = array();
|
||||
$tags = [];
|
||||
foreach($this as $tag){
|
||||
if($tag instanceof Tag){
|
||||
$tags[] = $tag;
|
||||
|
@ -30,7 +30,7 @@ class IntArray extends NamedTag{
|
||||
}
|
||||
|
||||
public function read(NBT $nbt){
|
||||
$this->value = array();
|
||||
$this->value = [];
|
||||
$size = $nbt->getInt();
|
||||
for($i = 0; $i < $size and !$nbt->feof(); ++$i){
|
||||
$this->value[] = $nbt->getInt();
|
||||
|
@ -24,8 +24,8 @@ namespace pocketmine\network\protocol;
|
||||
|
||||
class ContainerSetContentPacket extends DataPacket{
|
||||
public $windowid;
|
||||
public $slots = array();
|
||||
public $hotbar = array();
|
||||
public $slots = [];
|
||||
public $hotbar = [];
|
||||
|
||||
public function pid(){
|
||||
return Info::CONTAINER_SET_CONTENT_PACKET;
|
||||
|
@ -137,7 +137,7 @@ abstract class DataPacket extends \stdClass{
|
||||
}
|
||||
|
||||
protected function getDataArray($len = 10){
|
||||
$data = array();
|
||||
$data = [];
|
||||
for($i = 1; $i <= $len and !$this->feof(); ++$i){
|
||||
$data[] = $this->get($this->getTriad());
|
||||
}
|
||||
@ -145,7 +145,7 @@ abstract class DataPacket extends \stdClass{
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function putDataArray(array $data = array()){
|
||||
protected function putDataArray(array $data = []){
|
||||
foreach($data as $v){
|
||||
$this->putTriad(strlen($v));
|
||||
$this->put($v);
|
||||
|
@ -24,7 +24,7 @@ namespace pocketmine\network\protocol;
|
||||
|
||||
class PlayerArmorEquipmentPacket extends DataPacket{
|
||||
public $eid;
|
||||
public $slots = array();
|
||||
public $slots = [];
|
||||
|
||||
public function pid(){
|
||||
return Info::PLAYER_ARMOR_EQUIPMENT_PACKET;
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\network\protocol;
|
||||
class SendInventoryPacket extends DataPacket{
|
||||
public $eid;
|
||||
public $windowid;
|
||||
public $slots = array();
|
||||
public $armor = array();
|
||||
public $slots = [];
|
||||
public $armor = [];
|
||||
|
||||
public function pid(){
|
||||
return Info::SEND_INVENTORY_PACKET;
|
||||
|
@ -84,7 +84,7 @@ use pocketmine\utils\Utils;
|
||||
class Packet extends NetworkPacket{
|
||||
private $packetID;
|
||||
private $offset = 1;
|
||||
public $data = array();
|
||||
public $data = [];
|
||||
|
||||
public function __construct($packetID){
|
||||
$this->packetID = (int) $packetID;
|
||||
@ -172,7 +172,7 @@ class Packet extends NetworkPacket{
|
||||
case Info::DATA_PACKET_E:
|
||||
case Info::DATA_PACKET_F:
|
||||
$this->seqNumber = $this->getLTriad();
|
||||
$this->data = array();
|
||||
$this->data = [];
|
||||
while(!$this->feof() and $this->parseDataPacket() !== false){
|
||||
|
||||
}
|
||||
@ -180,7 +180,7 @@ class Packet extends NetworkPacket{
|
||||
case Info::NACK:
|
||||
case Info::ACK:
|
||||
$count = $this->getShort();
|
||||
$this->packets = array();
|
||||
$this->packets = [];
|
||||
for($i = 0; $i < $count and !$this->feof(); ++$i){
|
||||
if($this->getByte() === 0){
|
||||
$start = $this->getLTriad();
|
||||
|
@ -41,7 +41,7 @@ class RCON{
|
||||
private $rconSender;
|
||||
|
||||
public function __construct($password, $port = 19132, $interface = "0.0.0.0", $threads = 1, $clientsPerThread = 50){
|
||||
$this->workers = array();
|
||||
$this->workers = [];
|
||||
$this->password = (string) $password;
|
||||
console("[INFO] Starting remote control listener");
|
||||
if($this->password === ""){
|
||||
|
@ -26,7 +26,7 @@ use pocketmine\Server;
|
||||
class BanList{
|
||||
|
||||
/** @var BanEntry[] */
|
||||
private $list = array();
|
||||
private $list = [];
|
||||
|
||||
/** @var string */
|
||||
private $file;
|
||||
@ -128,7 +128,7 @@ class BanList{
|
||||
}
|
||||
|
||||
public function load(){
|
||||
$this->list = array();
|
||||
$this->list = [];
|
||||
$fp = @fopen($this->file, "r");
|
||||
if(is_resource($fp)){
|
||||
while(($line = fgets($fp)) !== false){
|
||||
|
@ -34,12 +34,12 @@ class PermissibleBase implements Permissible{
|
||||
/**
|
||||
* @var PermissionAttachment[]
|
||||
*/
|
||||
private $attachments = array();
|
||||
private $attachments = [];
|
||||
|
||||
/**
|
||||
* @var PermissionAttachmentInfo[]
|
||||
*/
|
||||
private $permissions = array();
|
||||
private $permissions = [];
|
||||
|
||||
/**
|
||||
* @param ServerOperator $opable
|
||||
@ -190,7 +190,7 @@ class PermissibleBase implements Permissible{
|
||||
Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(false, $this->parent);
|
||||
Server::getInstance()->getPluginManager()->unsubscribeFromDefaultPerms(true, $this->parent);
|
||||
|
||||
$this->permissions = array();
|
||||
$this->permissions = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ class Permission{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $children = array();
|
||||
private $children = [];
|
||||
|
||||
/** @var string */
|
||||
private $defaultValue;
|
||||
@ -97,7 +97,7 @@ class Permission{
|
||||
* @param string $defaultValue
|
||||
* @param Permission[] $children
|
||||
*/
|
||||
public function __construct($name, $description = null, $defaultValue = null, array $children = array()){
|
||||
public function __construct($name, $description = null, $defaultValue = null, array $children = []){
|
||||
$this->name = $name;
|
||||
$this->description = $description !== null ? $description : "";
|
||||
$this->defaultValue = $defaultValue !== null ? $defaultValue : self::$DEFAULT_PERMISSION;
|
||||
@ -199,7 +199,7 @@ class Permission{
|
||||
* @return Permission[]
|
||||
*/
|
||||
public static function loadPermissions(array $data, $default = self::DEFAULT_OP){
|
||||
$result = array();
|
||||
$result = [];
|
||||
foreach($data as $key => $entry){
|
||||
$result[] = self::loadPermission($key, $entry, $default, $result);
|
||||
}
|
||||
@ -215,9 +215,9 @@ class Permission{
|
||||
*
|
||||
* @return Permission
|
||||
*/
|
||||
public static function loadPermission($name, array $data, $default = self::DEFAULT_OP, &$output = array()){
|
||||
public static function loadPermission($name, array $data, $default = self::DEFAULT_OP, &$output = []){
|
||||
$desc = null;
|
||||
$children = array();
|
||||
$children = [];
|
||||
if(isset($data["default"])){
|
||||
$value = Permission::getByName($data["default"]);
|
||||
if($value !== null){
|
||||
|
@ -30,7 +30,7 @@ class PermissionAttachment{
|
||||
/**
|
||||
* @var bool[]
|
||||
*/
|
||||
private $permissions = array();
|
||||
private $permissions = [];
|
||||
|
||||
/** @var Permissible */
|
||||
private $permissible;
|
||||
|
@ -218,7 +218,7 @@ abstract class PluginBase implements Plugin{
|
||||
* @return string[]
|
||||
*/
|
||||
public function getResources(){
|
||||
$resources = array();
|
||||
$resources = [];
|
||||
if(is_dir($this->file . "resources/")){
|
||||
foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->file . "resources/")) as $resource){
|
||||
$resources[] = $resource;
|
||||
|
@ -27,13 +27,13 @@ class PluginDescription{
|
||||
private $name;
|
||||
private $main;
|
||||
private $api;
|
||||
private $depend = array();
|
||||
private $softDepend = array();
|
||||
private $loadBefore = array();
|
||||
private $depend = [];
|
||||
private $softDepend = [];
|
||||
private $loadBefore = [];
|
||||
private $version;
|
||||
private $commands = array();
|
||||
private $commands = [];
|
||||
private $description = null;
|
||||
private $authors = array();
|
||||
private $authors = [];
|
||||
private $website = null;
|
||||
private $prefix = null;
|
||||
private $order = PluginLoadOrder::POSTWORLD;
|
||||
@ -41,7 +41,7 @@ class PluginDescription{
|
||||
/**
|
||||
* @var Permission[]
|
||||
*/
|
||||
private $permissions = array();
|
||||
private $permissions = [];
|
||||
|
||||
/**
|
||||
* @param string $yamlString
|
||||
@ -100,7 +100,7 @@ class PluginDescription{
|
||||
$this->order = constant("pocketmine\\plugin\\PluginLoadOrder::" . $order);
|
||||
}
|
||||
}
|
||||
$this->authors = array();
|
||||
$this->authors = [];
|
||||
if(isset($plugin["author"])){
|
||||
$this->authors[] = $plugin["author"];
|
||||
}
|
||||
|
@ -45,12 +45,12 @@ class PluginManager{
|
||||
/**
|
||||
* @var Plugin[]
|
||||
*/
|
||||
protected $plugins = array();
|
||||
protected $plugins = [];
|
||||
|
||||
/**
|
||||
* @var Permission[]
|
||||
*/
|
||||
protected $permissions = array();
|
||||
protected $permissions = [];
|
||||
|
||||
/**
|
||||
* @var Permission[]
|
||||
@ -65,7 +65,7 @@ class PluginManager{
|
||||
/**
|
||||
* @var Permissible[]
|
||||
*/
|
||||
protected $permSubs = array();
|
||||
protected $permSubs = [];
|
||||
|
||||
/**
|
||||
* @var Permissible[]
|
||||
@ -80,7 +80,7 @@ class PluginManager{
|
||||
/**
|
||||
* @var PluginLoader[]
|
||||
*/
|
||||
protected $fileAssociations = array();
|
||||
protected $fileAssociations = [];
|
||||
|
||||
/**
|
||||
* @param Server $server
|
||||
@ -166,12 +166,12 @@ class PluginManager{
|
||||
public function loadPlugins($directory, $newLoaders = null){
|
||||
|
||||
if(is_dir($directory)){
|
||||
$plugins = array();
|
||||
$loadedPlugins = array();
|
||||
$dependencies = array();
|
||||
$softDependencies = array();
|
||||
$plugins = [];
|
||||
$loadedPlugins = [];
|
||||
$dependencies = [];
|
||||
$softDependencies = [];
|
||||
if(is_array($newLoaders)){
|
||||
$loaders = array();
|
||||
$loaders = [];
|
||||
foreach($newLoaders as $key){
|
||||
if(isset($this->fileAssociations[$key])){
|
||||
$loaders[$key] = $this->fileAssociations[$key];
|
||||
@ -302,14 +302,14 @@ class PluginManager{
|
||||
foreach($plugins as $name => $file){
|
||||
console("[SEVERE] Could not load plugin '" . $name . "': circular dependency detected");
|
||||
}
|
||||
$plugins = array();
|
||||
$plugins = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $loadedPlugins;
|
||||
}else{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@ -432,7 +432,7 @@ class PluginManager{
|
||||
return $this->permSubs[$permission];
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -512,7 +512,7 @@ class PluginManager{
|
||||
* @return PluginCommand[]
|
||||
*/
|
||||
protected function parseYamlCommands(Plugin $plugin){
|
||||
$pluginCmds = array();
|
||||
$pluginCmds = [];
|
||||
|
||||
foreach($plugin->getDescription()->getCommands() as $key => $data){
|
||||
if(strpos($key, ":") !== false){
|
||||
@ -530,7 +530,7 @@ class PluginManager{
|
||||
}
|
||||
|
||||
if(isset($data["aliases"]) and is_array($data["aliases"])){
|
||||
$aliasList = array();
|
||||
$aliasList = [];
|
||||
foreach($data["aliases"] as $alias){
|
||||
if(strpos($alias, ":") !== false){
|
||||
console("[SEVERE] Could not load alias " . $alias . " for plugin " . $plugin->getDescription()->getName());
|
||||
@ -579,11 +579,11 @@ class PluginManager{
|
||||
|
||||
public function clearPlugins(){
|
||||
$this->disablePlugins();
|
||||
$this->plugins = array();
|
||||
$this->fileAssociations = array();
|
||||
$this->permissions = array();
|
||||
$this->defaultPerms = array();
|
||||
$this->defaultPermsOp = array();
|
||||
$this->plugins = [];
|
||||
$this->fileAssociations = [];
|
||||
$this->permissions = [];
|
||||
$this->defaultPerms = [];
|
||||
$this->defaultPermsOp = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\item\Item;
|
||||
|
||||
abstract class Crafting{
|
||||
|
||||
private static $lookupTable = array();
|
||||
private static $lookupTable = [];
|
||||
|
||||
private static $small = array( //Probably means craftable on crafting bench and in inventory. Name it better!
|
||||
//Building
|
||||
@ -221,11 +221,11 @@ abstract class Crafting{
|
||||
"COBBLESTONE:?x6=>COBBLESTONE_STAIRS:0x4",
|
||||
);
|
||||
|
||||
private static $recipes = array();
|
||||
private static $recipes = [];
|
||||
|
||||
private static function parseRecipe($recipe){
|
||||
$recipe = explode("=>", $recipe);
|
||||
$recipeItems = array();
|
||||
$recipeItems = [];
|
||||
foreach(explode(",", $recipe[0]) as $item){
|
||||
$item = explode("x", $item);
|
||||
$id = explode(":", $item[0]);
|
||||
@ -257,34 +257,34 @@ abstract class Crafting{
|
||||
public static function init(){
|
||||
$id = 1;
|
||||
|
||||
self::$lookupTable[0] = array();
|
||||
self::$lookupTable[0] = [];
|
||||
foreach(self::$small as $recipe){
|
||||
$recipe = self::parseRecipe($recipe);
|
||||
self::$recipes[$id] = $recipe;
|
||||
if(!isset(self::$lookupTable[0][$recipe[2]])){
|
||||
self::$lookupTable[0][$recipe[2]] = array();
|
||||
self::$lookupTable[0][$recipe[2]] = [];
|
||||
}
|
||||
self::$lookupTable[0][$recipe[2]][] = $id;
|
||||
++$id;
|
||||
}
|
||||
|
||||
self::$lookupTable[1] = array();
|
||||
self::$lookupTable[1] = [];
|
||||
foreach(self::$big as $recipe){
|
||||
$recipe = self::parseRecipe($recipe);
|
||||
self::$recipes[$id] = $recipe;
|
||||
if(!isset(self::$lookupTable[1][$recipe[2]])){
|
||||
self::$lookupTable[1][$recipe[2]] = array();
|
||||
self::$lookupTable[1][$recipe[2]] = [];
|
||||
}
|
||||
self::$lookupTable[1][$recipe[2]][] = $id;
|
||||
++$id;
|
||||
}
|
||||
|
||||
self::$lookupTable[2] = array();
|
||||
self::$lookupTable[2] = [];
|
||||
foreach(self::$stone as $recipe){
|
||||
$recipe = self::parseRecipe($recipe);
|
||||
self::$recipes[$id] = $recipe;
|
||||
if(!isset(self::$lookupTable[2][$recipe[2]])){
|
||||
self::$lookupTable[2][$recipe[2]] = array();
|
||||
self::$lookupTable[2][$recipe[2]] = [];
|
||||
}
|
||||
self::$lookupTable[2][$recipe[2]][] = $id;
|
||||
++$id;
|
||||
|
@ -39,7 +39,7 @@ class CallbackTask extends Task{
|
||||
* @param callable $callable
|
||||
* @param array $args
|
||||
*/
|
||||
public function __construct(callable $callable, array $args = array()){
|
||||
public function __construct(callable $callable, array $args = []){
|
||||
$this->callable = $callable;
|
||||
$this->args = $args;
|
||||
$this->args[] = $this;
|
||||
|
@ -37,7 +37,7 @@ class ServerScheduler{
|
||||
/**
|
||||
* @var TaskHandler[]
|
||||
*/
|
||||
protected $tasks = array();
|
||||
protected $tasks = [];
|
||||
|
||||
/** @var \Pool */
|
||||
protected $asyncPool;
|
||||
@ -134,7 +134,7 @@ class ServerScheduler{
|
||||
foreach($this->tasks as $task){
|
||||
$task->cancel();
|
||||
}
|
||||
$this->tasks = array();
|
||||
$this->tasks = [];
|
||||
$this->asyncPool->shutdown();
|
||||
$this->asyncTasks = 0;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ trait Container{
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$player->dataPacket($pk);
|
||||
$slots = array();
|
||||
$slots = [];
|
||||
|
||||
if(is_array($player->windows[$id])){
|
||||
$all = $this->getLevel()->getPlayers();
|
||||
@ -121,7 +121,7 @@ trait Container{
|
||||
$pk->z = $this->z;
|
||||
$player->dataPacket($pk);
|
||||
|
||||
$slots = array();
|
||||
$slots = [];
|
||||
for($s = 0; $s < Furnace::SLOTS; ++$s){
|
||||
$slot = $this->getSlot($s);
|
||||
if($slot->getID() > Item::AIR and $slot->getCount() > 0){
|
||||
|
@ -41,12 +41,12 @@ abstract class Tile extends Position{
|
||||
/**
|
||||
* @var Tile[]
|
||||
*/
|
||||
public static $list = array();
|
||||
public static $list = [];
|
||||
|
||||
/**
|
||||
* @var Tile[]
|
||||
*/
|
||||
public static $needUpdate = array();
|
||||
public static $needUpdate = [];
|
||||
|
||||
public $chunkIndex;
|
||||
public $name;
|
||||
|
@ -113,7 +113,7 @@ class Binary{
|
||||
*/
|
||||
public static function readMetadata($value, $types = false){
|
||||
$offset = 0;
|
||||
$m = array();
|
||||
$m = [];
|
||||
$b = ord($value{$offset});
|
||||
++$offset;
|
||||
while($b !== 127 and isset($value{$offset})){
|
||||
@ -143,7 +143,7 @@ class Binary{
|
||||
$offset += $len;
|
||||
break;
|
||||
case 5:
|
||||
$r = array();
|
||||
$r = [];
|
||||
$r[] = self::readLShort(substr($value, $offset, 2));
|
||||
$offset += 2;
|
||||
$r[] = ord($value{$offset});
|
||||
@ -152,7 +152,7 @@ class Binary{
|
||||
$offset += 2;
|
||||
break;
|
||||
case 6:
|
||||
$r = array();
|
||||
$r = [];
|
||||
for($i = 0; $i < 3; ++$i){
|
||||
$r[] = self::readLInt(substr($value, $offset, 4));
|
||||
$offset += 4;
|
||||
|
@ -23,7 +23,7 @@ namespace pocketmine\utils;
|
||||
|
||||
|
||||
class Cache{
|
||||
public static $cached = array();
|
||||
public static $cached = [];
|
||||
|
||||
/**
|
||||
* Adds something to the cache
|
||||
|
@ -71,7 +71,7 @@ class Config{
|
||||
* @param array $default Array with the default values, will be set if not existent
|
||||
* @param null &$correct Sets correct to true if everything has been loaded correctly
|
||||
*/
|
||||
public function __construct($file, $type = Config::DETECT, $default = array(), &$correct = null){
|
||||
public function __construct($file, $type = Config::DETECT, $default = [], &$correct = null){
|
||||
$this->load($file, $type, $default);
|
||||
$correct = $this->correct;
|
||||
}
|
||||
@ -102,12 +102,12 @@ class Config{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function load($file, $type = Config::DETECT, $default = array()){
|
||||
public function load($file, $type = Config::DETECT, $default = []){
|
||||
$this->correct = true;
|
||||
$this->type = (int) $type;
|
||||
$this->file = $file;
|
||||
if(!is_array($default)){
|
||||
$default = array();
|
||||
$default = [];
|
||||
}
|
||||
if(!file_exists($file)){
|
||||
$this->config = $default;
|
||||
@ -275,7 +275,7 @@ class Config{
|
||||
$final = array_pop($components);
|
||||
foreach($components as $component){
|
||||
if(!isset($currPath[$component])){
|
||||
$currPath[$component] = array();
|
||||
$currPath[$component] = [];
|
||||
}
|
||||
$currPath =& $currPath[$component];
|
||||
}
|
||||
@ -347,7 +347,7 @@ class Config{
|
||||
foreach($default as $k => $v){
|
||||
if(is_array($v)){
|
||||
if(!isset($data[$k]) or !is_array($data[$k])){
|
||||
$data[$k] = array();
|
||||
$data[$k] = [];
|
||||
}
|
||||
$changed += $this->fillDefaults($v, $data[$k]);
|
||||
}elseif(!isset($data[$k])){
|
||||
|
@ -42,7 +42,7 @@ class InstallerLang{
|
||||
"tr" => "Türkçe",
|
||||
//"et" => "Eesti",
|
||||
);
|
||||
private $texts = array();
|
||||
private $texts = [];
|
||||
private $lang;
|
||||
private $langfile;
|
||||
|
||||
@ -53,7 +53,7 @@ class InstallerLang{
|
||||
}else{
|
||||
$l = glob(\pocketmine\PATH . "src/lang/Installer/" . $lang . "_*.ini");
|
||||
if(count($l) > 0){
|
||||
$files = array();
|
||||
$files = [];
|
||||
foreach($l as $file){
|
||||
$files[$file] = filesize($file);
|
||||
}
|
||||
@ -81,7 +81,7 @@ class InstallerLang{
|
||||
}
|
||||
|
||||
public function loadLang($langfile, $lang = "en"){
|
||||
$this->texts[$lang] = array();
|
||||
$this->texts[$lang] = [];
|
||||
$texts = explode("\n", str_replace(array("\r", "\/\/"), array("", "//"), file_get_contents($langfile)));
|
||||
foreach($texts as $line){
|
||||
$line = trim($line);
|
||||
@ -93,7 +93,7 @@ class InstallerLang{
|
||||
}
|
||||
}
|
||||
|
||||
public function get($name, $search = array(), $replace = array()){
|
||||
public function get($name, $search = [], $replace = []){
|
||||
if(!isset($this->texts[$this->lang][$name])){
|
||||
if($this->lang !== "en" and isset($this->texts["en"][$name])){
|
||||
return $this->texts["en"][$name];
|
||||
|
@ -50,7 +50,7 @@ class SplClassLoader implements SplAutoloader{
|
||||
private $includePathLookup = false;
|
||||
|
||||
/** @var array */
|
||||
private $resources = array();
|
||||
private $resources = [];
|
||||
|
||||
/** @var integer */
|
||||
private $mode = self::MODE_NORMAL;
|
||||
|
@ -629,7 +629,7 @@ class Pool{
|
||||
*
|
||||
* @link http://www.php.net/manual/en/pool.__construct.php
|
||||
*/
|
||||
public function __construct($size, $class, array $ctor = array()){
|
||||
public function __construct($size, $class, array $ctor = []){
|
||||
}
|
||||
|
||||
/**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user