Merge pull request #166 from pmmp/0.16-isp

0.16 isp (PhpStorm inspections)
This commit is contained in:
SOFe 2016-12-15 18:45:05 +08:00 committed by GitHub
commit 252d1988dc
22 changed files with 49 additions and 41 deletions

View File

@ -2647,6 +2647,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
break;
}
/**
* @var int $i
* @var Item $item
*/
foreach($packet->input as $i => $item){
if($item->getDamage() === -1 or $item->getDamage() === 0xffff){
$item->setDamage(null);
@ -2719,8 +2723,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
foreach($ingredients as $ingredient){
$slot = -1;
foreach($this->inventory->getContents() as $index => $i){
if($ingredient->getId() !== 0 and $ingredient->deepEquals($i, $ingredient->getDamage() !== null) and ($i->getCount() - $used[$index]) >= 1){
foreach($this->inventory->getContents() as $index => $item){
if($ingredient->getId() !== 0 and $ingredient->deepEquals($item, $ingredient->getDamage() !== null) and ($item->getCount() - $used[$index]) >= 1){
$slot = $index;
$used[$index]++;
break;
@ -3140,6 +3144,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
/**
* Handles player data saving
*
* @param bool $async
*/
public function save($async = false){
if($this->closed){

View File

@ -185,7 +185,6 @@ class Server{
/** @var CommandReader */
private $console = null;
private $consoleThreaded;
/** @var SimpleCommandMap */
private $commandMap = null;

View File

@ -39,7 +39,7 @@ class BanListCommand extends VanillaCommand{
if(!$this->testPermission($sender)){
return true;
}
$list = $sender->getServer()->getNameBans();
if(isset($args[0])){
$args[0] = strtolower($args[0]);
if($args[0] === "ips"){

View File

@ -123,8 +123,13 @@ class ParticleCommand extends VanillaCommand{
}
/**
* @param $name
* @param string $name
*
* @param Vector3 $pos
* @param int $xd
* @param float $yd
* @param float $zd
* @param int|null $data
* @return Particle
*/
private function getParticle($name, Vector3 $pos, $xd, $yd, $zd, $data){

View File

@ -1610,6 +1610,7 @@ abstract class Entity extends Location implements Metadatable{
* @param int $id
* @param int $type
* @param mixed $value
* @param bool $send
*
* @return bool
*/

View File

@ -236,7 +236,8 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
}
public function recalculateXpProgress() : float{
$this->setXpProgress($this->getRemainderXp() / self::getTotalXpForLevel($this->getXpLevel()));
$this->setXpProgress($progress = $this->getRemainderXp() / self::getTotalXpForLevel($this->getXpLevel()));
return $progress;
}
public static function getTotalXpForLevel(int $level) : int{

View File

@ -63,8 +63,6 @@ abstract class Event{
/**
* @param bool $value
*
* @return bool
*
* @throws \BadMethodCallException
*/
public function setCancelled($value = true){

View File

@ -68,7 +68,7 @@ interface Inventory{
*
* Returns the Items that did not fit.
*
* @param Item ...$item
* @param Item ...$slots
*
* @return Item[]
*/
@ -87,7 +87,7 @@ interface Inventory{
* Removes the given Item from the inventory.
* It will return the Items that couldn't be removed.
*
* @param Item ...$item
* @param Item ...$slots
*
* @return Item[]
*/

View File

@ -36,4 +36,6 @@ interface Recipe{
* @return UUID
*/
public function getId();
public function setId(UUID $id);
}

View File

@ -35,6 +35,7 @@ use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\nbt\tag\Tag;
use pocketmine\Player;
use pocketmine\Server;
use pocketmine\utils\Config;
@ -594,6 +595,10 @@ class Item implements ItemIds, \JsonSerializable{
return $this;
}
/**
* @param $name
* @return Tag|null
*/
public function getNamedTagEntry($name){
$tag = $this->getNamedTag();
if($tag !== null){

View File

@ -91,6 +91,7 @@ class BaseLang{
/**
* @param string $str
* @param string[] $params
* @param string|null $onlyPrefix
*
* @return string
*/

View File

@ -287,6 +287,11 @@ class Level implements ChunkManager, Metadatable{
}
}
/**
* @param string|int $hash
* @param int|null $x
* @param int|null $z
*/
public static function getXZ($hash, &$x, &$z){
if(PHP_INT_SIZE === 8){
$x = ($hash >> 32) << 32 >> 32;
@ -1785,7 +1790,7 @@ class Level implements ChunkManager, Metadatable{
* Returns the entities colliding the current one inside the AxisAlignedBB
*
* @param AxisAlignedBB $bb
* @param Entity $entity
* @param Entity|null $entity
*
* @return Entity[]
*/
@ -2316,8 +2321,6 @@ class Level implements ChunkManager, Metadatable{
if(count($this->chunkSendQueue) > 0){
$this->timings->syncChunkSendTimer->startTiming();
$x = null;
$z = null;
foreach($this->chunkSendQueue as $index => $players){
if(isset($this->chunkSendTasks[$index])){
continue;
@ -2778,9 +2781,6 @@ class Level implements ChunkManager, Metadatable{
public function doChunkGarbageCollection(){
$this->timings->doChunkGC->startTiming();
$X = null;
$Z = null;
foreach($this->chunks as $index => $chunk){
if(!isset($this->unloadQueue[$index]) and (!isset($this->usedChunks[$index]) or count($this->usedChunks[$index]) === 0)){
Level::getXZ($index, $X, $Z);

View File

@ -50,9 +50,11 @@ class Location extends Position{
* @param Level|null $level default null
* @param float $yaw default 0.0
* @param float $pitch default 0.0
*
* @return Location
*/
public static function fromObject(Vector3 $pos, Level $level = null, $yaw = 0.0, $pitch = 0.0){
return new Location($pos->x, $pos->y, $pos->z, $yaw, $pitch, ($level === null) ? (($pos instanceof Position) ? $pos->level : null) : $level);
return new Location($pos->x, $pos->y, $pos->z, $yaw, $pitch, $level ?? (($pos instanceof Position) ? $pos->level : null));
}
public function getYaw(){

View File

@ -84,6 +84,7 @@ abstract class BaseFullChunk implements FullChunk{
* @param int[] $heightMap
* @param CompoundTag[] $entities
* @param CompoundTag[] $tiles
* @param int[] $extraData
*/
protected function __construct($provider, $x, $z, $blocks, $data, $skyLight, $blockLight, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = [], array $extraData = []){
$this->provider = $provider;

View File

@ -34,14 +34,13 @@ use pocketmine\nbt\tag\IntArrayTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\LongTag;
use pocketmine\nbt\tag\NamedTAG;
use pocketmine\nbt\tag\NamedTag;
use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\nbt\tag\Tag;
#ifndef COMPILE
use pocketmine\utils\Binary;
#endif
@ -532,7 +531,7 @@ class NBT{
public function writeTag(Tag $tag, bool $network = false){
$this->putByte($tag->getType());
if($tag instanceof NamedTAG){
if($tag instanceof NamedTag){
$this->putString($tag->getName(), $network);
}
$tag->write($this, $network);

View File

@ -207,6 +207,8 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{
foreach($tags as $tag){
$tag->write($nbt, $network);
}
return true;
}
public function __toString(){

View File

@ -173,13 +173,13 @@ class Permission{
* @param string|Permission $name
* @param $value
*
* @return Permission|void Permission if $name is a string, void if it's a Permission
* @return Permission|null Permission if $name is a string, null if it's a Permission
*/
public function addParent($name, $value){
if($name instanceof Permission){
$name->getChildren()[$this->getName()] = $value;
$name->recalculatePermissibles();
return;
return null;
}else{
$perm = Server::getInstance()->getPluginManager()->getPermission($name);
if($perm === null){

View File

@ -89,9 +89,6 @@ class PermissionAttachment{
return $this->permissions;
}
/**
* @return bool[]
*/
public function clearPermissions(){
$this->permissions = [];
$this->permissible->recalculatePermissions();

View File

@ -259,7 +259,7 @@ abstract class PluginBase implements Plugin{
public function reloadConfig(){
$this->config = new Config($this->configFile);
if(($configStream = $this->getResource("config.yml")) !== null){
$this->config->setDefaults(yaml_parse(config::fixYAMLIndexes(stream_get_contents($configStream))));
$this->config->setDefaults(yaml_parse(Config::fixYAMLIndexes(stream_get_contents($configStream))));
fclose($configStream);
}
}

View File

@ -277,18 +277,6 @@ class ServerScheduler{
}elseif(!$task->getOwner()->isEnabled()){
throw new PluginException("Plugin '" . $task->getOwner()->getName() . "' attempted to register a task while disabled");
}
}elseif($task instanceof CallbackTask and Server::getInstance()->getProperty("settings.deprecated-verbose", true)){
$callable = $task->getCallable();
if(is_array($callable)){
if(is_object($callable[0])){
$taskName = "Callback#" . get_class($callable[0]) . "::" . $callable[1];
}else{
$taskName = "Callback#" . $callable[0] . "::" . $callable[1];
}
}else{
$taskName = "Callback#" . $callable;
}
Server::getInstance()->getLogger()->warning("A plugin attempted to register a deprecated CallbackTask ($taskName)");
}
if($delay <= 0){

View File

@ -22,7 +22,6 @@
namespace pocketmine\tile;
use pocketmine\item\Item;
use pocketmine\Network;
interface Container{

View File

@ -168,6 +168,8 @@ class Utils{
* BSD => bsd
* Other => other
*
* @param bool $recalculate
*
* @return string
*/
public static function getOS($recalculate = false){