More PhpStorm inspections, import cleanup

This commit is contained in:
Dylan K. Taylor 2017-01-04 14:52:57 +00:00
parent 07f18d8f6c
commit 598e7aac8f
35 changed files with 73 additions and 98 deletions

View File

@ -118,7 +118,6 @@ use pocketmine\network\protocol\PlayerActionPacket;
use pocketmine\network\protocol\PlayStatusPacket;
use pocketmine\network\protocol\ResourcePacksInfoPacket;
use pocketmine\network\protocol\RespawnPacket;
use pocketmine\network\protocol\SetDifficultyPacket;
use pocketmine\network\protocol\SetEntityMotionPacket;
use pocketmine\network\protocol\SetHealthPacket;
use pocketmine\network\protocol\SetPlayerGameTypePacket;
@ -134,10 +133,7 @@ use pocketmine\permission\PermissibleBase;
use pocketmine\permission\PermissionAttachment;
use pocketmine\plugin\Plugin;
use pocketmine\tile\ItemFrame;
use pocketmine\tile\Sign;
use pocketmine\tile\Spawnable;
use pocketmine\tile\Tile;
use pocketmine\utils\Binary;
use pocketmine\utils\TextFormat;
use pocketmine\utils\UUID;
@ -3612,27 +3608,4 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
public function isLoaderActive(){
return $this->isConnected();
}
/**
* @param int $chunkX
* @param int $chunkZ
* @param string $payload
*
* @return DataPacket
*/
public static function getChunkCacheFromData($chunkX, $chunkZ, $payload){
$pk = new FullChunkDataPacket();
$pk->chunkX = $chunkX;
$pk->chunkZ = $chunkZ;
$pk->data = $payload;
$pk->encode();
$batch = new BatchPacket();
$batch->payload = zlib_encode(Binary::writeUnsignedVarInt(strlen($pk->getBuffer())) . $pk->getBuffer(), ZLIB_ENCODING_DEFLATE, Server::getInstance()->networkCompressionLevel);
$batch->encode();
$batch->isEncoded = true;
return $batch;
}
}

View File

@ -489,7 +489,7 @@ namespace pocketmine {
}
ThreadManager::init();
$server = new Server($autoloader, $logger, \pocketmine\PATH, \pocketmine\DATA, \pocketmine\PLUGIN_PATH);
new Server($autoloader, $logger, \pocketmine\PATH, \pocketmine\DATA, \pocketmine\PLUGIN_PATH);
$logger->info("Stopping other threads");

View File

@ -29,7 +29,7 @@ use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\Player;
use pocketmine\tile\Furnace;
use pocketmine\tile\Furnace as TileFurnace;
use pocketmine\tile\Tile;
class BurningFurnace extends Solid{
@ -101,11 +101,7 @@ class BurningFurnace extends Solid{
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){
$t = $this->getLevel()->getTile($this);
$furnace = false;
if($t instanceof Furnace){
$furnace = $t;
}else{
if(!(($furnace = $this->getLevel()->getTile($this)) instanceof TileFurnace)){
$nbt = new CompoundTag("", [
new ListTag("Items", []),
new StringTag("id", Tile::FURNACE),

View File

@ -21,7 +21,6 @@
namespace pocketmine\block;
use pocketmine\item\Tool;
use pocketmine\item\Item;
class SeaLantern extends Solid{

View File

@ -25,7 +25,6 @@ use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\ItemDespawnEvent;
use pocketmine\event\entity\ItemSpawnEvent;
use pocketmine\item\Item as ItemItem;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag;

View File

@ -32,7 +32,6 @@ use pocketmine\item\Item as ItemItem;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\ShortTag;
use pocketmine\network\protocol\EntityEventPacket;
use pocketmine\Server;
use pocketmine\utils\BlockIterator;
abstract class Living extends Entity implements Damageable{

View File

@ -28,7 +28,6 @@ use pocketmine\math\Vector3;
use pocketmine\network\protocol\AddEntityPacket;
use pocketmine\network\protocol\EntityEventPacket;
use pocketmine\Player;
use pocketmine\Server;
class Squid extends WaterAnimal implements Ageable{
const NETWORK_ID = 17;

View File

@ -22,7 +22,6 @@
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\Event;
use pocketmine\event\Cancellable;
use pocketmine\item\Item;

View File

@ -22,7 +22,6 @@
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\Event;
use pocketmine\event\Cancellable;
use pocketmine\item\Item;

View File

@ -22,7 +22,6 @@
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\Event;
use pocketmine\event\Cancellable;
use pocketmine\level\Level;

View File

@ -22,7 +22,6 @@
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\Event;
use pocketmine\event\Cancellable;
use pocketmine\math\Vector3;

View File

@ -22,7 +22,6 @@
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\Event;
use pocketmine\event\Cancellable;
use pocketmine\level\Position;

View File

@ -21,7 +21,6 @@
namespace pocketmine\event\player;
use pocketmine\Event;
use pocketmine\event\Cancellable;
use pocketmine\item\Item;
use pocketmine\Player;

View File

@ -21,7 +21,6 @@
namespace pocketmine\event\server;
use pocketmine\event;
use pocketmine\event\Cancellable;
use pocketmine\network\protocol\DataPacket;
use pocketmine\Player;

View File

@ -21,7 +21,6 @@
namespace pocketmine\event\server;
use pocketmine\event;
use pocketmine\event\Cancellable;
use pocketmine\network\protocol\DataPacket;
use pocketmine\Player;

View File

@ -21,7 +21,6 @@
namespace pocketmine\event\server;
use pocketmine\event;
use pocketmine\Server;
use pocketmine\utils\Binary;

View File

@ -26,7 +26,6 @@ use pocketmine\entity\Human;
use pocketmine\event\entity\EntityEatItemEvent;
use pocketmine\network\protocol\EntityEventPacket;
use pocketmine\Player;
use pocketmine\Server;
abstract class Food extends Item implements FoodSource{
public function canBeConsumed() : bool{

View File

@ -67,7 +67,6 @@ use pocketmine\inventory\InventoryHolder;
use pocketmine\item\Item;
use pocketmine\level\format\Chunk;
use pocketmine\level\format\generic\BaseLevelProvider;
use pocketmine\level\format\generic\EmptyChunkSection;
use pocketmine\level\format\LevelProvider;
use pocketmine\level\generator\GenerationTask;
use pocketmine\level\generator\Generator;
@ -85,13 +84,13 @@ use pocketmine\math\Vector3;
use pocketmine\metadata\BlockMetadataStore;
use pocketmine\metadata\Metadatable;
use pocketmine\metadata\MetadataValue;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\network\protocol\BatchPacket;
use pocketmine\network\protocol\DataPacket;
use pocketmine\network\protocol\FullChunkDataPacket;
use pocketmine\network\protocol\LevelEventPacket;
@ -104,6 +103,7 @@ use pocketmine\plugin\Plugin;
use pocketmine\Server;
use pocketmine\tile\Chest;
use pocketmine\tile\Tile;
use pocketmine\utils\Binary;
use pocketmine\utils\LevelException;
use pocketmine\utils\Random;
use pocketmine\utils\ReversePriorityQueue;
@ -896,8 +896,6 @@ class Level implements ChunkManager, Metadatable{
}
}
$blockTest = 0;
foreach($this->chunkTickList as $index => $loaders){
Level::getXZ($index, $chunkX, $chunkZ);
@ -2297,7 +2295,7 @@ class Level implements ChunkManager, Metadatable{
$index = Level::chunkHash($x, $z);
if(!isset($this->chunkCache[$index]) and $this->cacheChunks and $this->server->getMemoryManager()->canUseChunkCache()){
$this->chunkCache[$index] = Player::getChunkCacheFromData($x, $z, $payload);
$this->chunkCache[$index] = Level::getChunkCacheFromData($x, $z, $payload);
$this->sendChunkFromCache($x, $z);
$this->timings->syncChunkSendTimer->stopTiming();
return;
@ -2731,7 +2729,7 @@ class Level implements ChunkManager, Metadatable{
$this->timings->doChunkGC->startTiming();
foreach($this->chunks as $index => $chunk){
if(!isset($this->unloadQueue[$index]) and (!isset($this->usedChunks[$index]) or count($this->usedChunks[$index]) === 0)){
if(!isset($this->unloadQueue[$index])){
Level::getXZ($index, $X, $Z);
if(!$this->isSpawnChunk($X, $Z)){
$this->unloadChunkRequest($X, $Z, true);
@ -2774,6 +2772,28 @@ class Level implements ChunkManager, Metadatable{
}
}
/**
* @param int $chunkX
* @param int $chunkZ
* @param string $payload
*
* @return DataPacket
*/
public static function getChunkCacheFromData($chunkX, $chunkZ, $payload){
$pk = new FullChunkDataPacket();
$pk->chunkX = $chunkX;
$pk->chunkZ = $chunkZ;
$pk->data = $payload;
$pk->encode();
$batch = new BatchPacket();
$batch->payload = zlib_encode(Binary::writeUnsignedVarInt(strlen($pk->getBuffer())) . $pk->getBuffer(), ZLIB_ENCODING_DEFLATE, Server::getInstance()->networkCompressionLevel);
$batch->encode();
$batch->isEncoded = true;
return $batch;
}
public function setMetadata($metadataKey, MetadataValue $metadataValue){
$this->server->getLevelMetadata()->setMetadata($this, $metadataKey, $metadataValue);
}

View File

@ -27,6 +27,8 @@ use pocketmine\utils\LevelException;
class WeakPosition extends Position{
protected $levelId = -1;
/**
* @param int $x
* @param int $y

View File

@ -23,7 +23,6 @@ declare(strict_types = 1);
namespace pocketmine\level\format;
use pocketmine\level\format\Chunk;
use pocketmine\level\Level;
use pocketmine\math\Vector3;

View File

@ -32,6 +32,7 @@ use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\LongTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\utils\ChunkException;
use pocketmine\utils\LevelException;
abstract class BaseLevelProvider implements LevelProvider{

View File

@ -19,7 +19,7 @@
*
*/
namespace pocketmine\level\format;
namespace pocketmine\level\format\generic;
use pocketmine\level\Level;
use pocketmine\nbt\NBT;

View File

@ -23,8 +23,6 @@ declare(strict_types = 1);
namespace pocketmine\level\format\generic;
use pocketmine\utils\ChunkException;
class EmptySubChunk extends SubChunk{
public function __construct(){

View File

@ -30,13 +30,13 @@ use pocketmine\block\Block;
use pocketmine\entity\Entity;
use pocketmine\level\format\Chunk;
use pocketmine\level\format\LevelProvider;
use pocketmine\level\Level;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\Player;
use pocketmine\tile\Tile;
use pocketmine\tile\Spawnable;
use pocketmine\utils\BinaryStream;
use pocketmine\utils\ChunkException;
class GenericChunk implements Chunk{

View File

@ -23,15 +23,19 @@ declare(strict_types = 1);
namespace pocketmine\level\format\region;
use pocketmine\level\format\Chunk;
use pocketmine\level\format\generic\GenericChunk;
use pocketmine\level\format\generic\SubChunk;
use pocketmine\level\Level;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\{ByteArrayTag, ByteTag, CompoundTag, IntArrayTag, IntTag, ListTag, LongTag};
use pocketmine\nbt\tag\{
ByteArrayTag,
ByteTag,
CompoundTag,
IntArrayTag,
IntTag,
ListTag,
LongTag
};
use pocketmine\Player;
use pocketmine\tile\Spawnable;
use pocketmine\utils\BinaryStream;
use pocketmine\utils\ChunkException;
use pocketmine\utils\MainLogger;

View File

@ -24,16 +24,23 @@ declare(strict_types = 1);
namespace pocketmine\level\format\region;
use pocketmine\level\format\Chunk;
use pocketmine\level\format\LevelProvider;
use pocketmine\level\format\generic\GenericChunk;
use pocketmine\level\format\generic\SubChunk;
use pocketmine\level\format\generic\BaseLevelProvider;
use pocketmine\level\generator\Generator;
use pocketmine\level\Level;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\{ByteArrayTag, ByteTag, CompoundTag, IntArrayTag, IntTag, ListTag, LongTag, StringTag};
use pocketmine\nbt\tag\{
ByteArrayTag,
ByteTag,
CompoundTag,
IntArrayTag,
IntTag,
ListTag,
LongTag,
StringTag
};
use pocketmine\Player;
use pocketmine\utils\ChunkException;
use pocketmine\utils\MainLogger;
class McRegion extends BaseLevelProvider{
@ -137,9 +144,9 @@ class McRegion extends BaseLevelProvider{
$subChunks = [];
$fullIds = isset($chunk->Blocks) ? $chunk->Blocks->getValue() : str_repeat("\x00", 32768);
$fullData = isset($chunk->Data) ? $chunk->Data->getValue() : ($half = str_repeat("\x00", 16384));
$fullData = isset($chunk->Data) ? $chunk->Data->getValue() : (str_repeat("\x00", 16384));
$fullSkyLight = isset($chunk->SkyLight) ? $chunk->SkyLight->getValue() : str_repeat("\xff", 16384);
$fullBlockLight = isset($chunk->BlockLight) ? $chunk->BlockLight->getValue() : $half;
$fullBlockLight = isset($chunk->BlockLight) ? $chunk->BlockLight->getValue() : (str_repeat("\x00", 16384));
for($y = 0; $y < 8; ++$y){
$offset = ($y << 4);

View File

@ -23,15 +23,19 @@ declare(strict_types = 1);
namespace pocketmine\level\format\region;
use pocketmine\level\format\Chunk;
use pocketmine\level\format\generic\GenericChunk;
use pocketmine\level\format\generic\SubChunk;
use pocketmine\level\Level;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\{ByteArrayTag, ByteTag, CompoundTag, IntArrayTag, IntTag, ListTag, LongTag};
use pocketmine\nbt\tag\{
ByteArrayTag,
ByteTag,
CompoundTag,
IntArrayTag,
IntTag,
ListTag,
LongTag
};
use pocketmine\Player;
use pocketmine\tile\Spawnable;
use pocketmine\utils\BinaryStream;
use pocketmine\utils\ChunkException;
use pocketmine\utils\MainLogger;

View File

@ -32,7 +32,6 @@ use pocketmine\block\RedstoneOre;
use pocketmine\item\Item;
use pocketmine\level\ChunkManager;
use pocketmine\level\format\Chunk;
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\populator\Ore;
use pocketmine\level\generator\populator\Populator;
use pocketmine\math\Vector3;

View File

@ -53,7 +53,6 @@ class GenerationTask extends AsyncTask{
}
/** @var Chunk $chunk */
$chunk = $this->chunkClass;
$chunk = GenericChunk::fastDeserialize($this->chunk);
if($chunk === null){
//TODO error
@ -79,7 +78,6 @@ class GenerationTask extends AsyncTask{
return;
}
/** @var Chunk $chunk */
$chunk = $this->chunkClass;
$chunk = GenericChunk::fastDeserialize($this->chunk, $level->getProvider());
if($chunk === null){
//TODO error

View File

@ -22,7 +22,7 @@
namespace pocketmine\level\generator;
use pocketmine\level\format\Chunk;
use pocketmine\level\format\generic\FullChunk;
use pocketmine\level\format\generic\GenericChunk;
use pocketmine\level\Level;
use pocketmine\scheduler\AsyncTask;
use pocketmine\Server;
@ -41,7 +41,6 @@ class LightPopulationTask extends AsyncTask{
public function onRun(){
/** @var Chunk $chunk */
$chunk = $this->chunkClass;
$chunk = GenericChunk::fastDeserialize($this->chunk);
if($chunk === null){
//TODO error
@ -59,7 +58,6 @@ class LightPopulationTask extends AsyncTask{
$level = $server->getLevel($this->levelId);
if($level !== null){
/** @var Chunk $chunk */
$chunk = $this->chunkClass;
$chunk = GenericChunk::fastDeserialize($this->chunk, $level->getProvider());
if($chunk === null){
//TODO error

View File

@ -28,8 +28,4 @@ class HellBiome extends Biome{
public function getName(){
return "Hell";
}
public function getColor(){
return 0;
}
}

View File

@ -25,7 +25,4 @@ use pocketmine\level\generator\biome\Biome;
abstract class NormalBiome extends Biome{
public function getColor(){
return $this->grassColor;
}
}

View File

@ -35,8 +35,4 @@ class SwampBiome extends GrassyBiome{
public function getName(){
return "Swamp";
}
public function getColor(){
return 0x6a7039;
}
}

View File

@ -94,7 +94,6 @@ use pocketmine\network\protocol\UpdateBlockPacket;
use pocketmine\network\protocol\UseItemPacket;
use pocketmine\Player;
use pocketmine\Server;
use pocketmine\utils\Binary;
use pocketmine\utils\BinaryStream;
class Network{

View File

@ -21,16 +21,18 @@
namespace pocketmine\network\protocol;
use pocketmine\resourcepacks\ResourcePackInfoEntry;
#include <rules/DataPacket.h>
class ResourcePacksInfoPacket extends DataPacket{
const NETWORK_ID = Info::RESOURCE_PACKS_INFO_PACKET;
public $mustAccept = false; //force client to use selected resource packs
/** @var ResourcePackInfoEntry */
public $behaviourPackEntries = [];
/** @var ResourcePackInfoEntry */
public $mustAccept = false; //if true, forces client to use selected resource packs
/** @var ResourcePackInfoEntry[] */
public $behaviorPackEntries = [];
/** @var ResourcePackInfoEntry[] */
public $resourcePackEntries = [];
public function decode(){
@ -41,8 +43,8 @@ class ResourcePacksInfoPacket extends DataPacket{
$this->reset();
$this->putBool($this->mustAccept);
$this->putShort(count($this->behaviourPackEntries));
foreach($this->behaviourPackEntries as $entry){
$this->putShort(count($this->behaviorPackEntries));
foreach($this->behaviorPackEntries as $entry){
$this->putString($entry->getPackId());
$this->putString($entry->getVersion());
$this->putLong($entry->getPackSize());