mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Fixed a bunch of things PHPStan finds unpalatable
close #2614, fix a bunch of docs bugs, fix sendCreativeContents() crash on Human holders, move some inline variable declarations
This commit is contained in:
parent
5e0c3333cf
commit
d71a543d10
@ -216,12 +216,12 @@ class ParticleCommand extends VanillaCommand{
|
||||
}elseif(strpos($name, "blockcrack_") === 0){
|
||||
$d = explode("_", $name);
|
||||
if(count($d) === 2){
|
||||
return new TerrainParticle($pos, BlockFactory::get($d[1] & 0xff, $d[1] >> 12));
|
||||
return new TerrainParticle($pos, BlockFactory::get(((int) $d[1]) & 0xff, ((int) $d[1]) >> 12));
|
||||
}
|
||||
}elseif(strpos($name, "blockdust_") === 0){
|
||||
$d = explode("_", $name);
|
||||
if(count($d) >= 4){
|
||||
return new DustParticle($pos, $d[1] & 0xff, $d[2] & 0xff, $d[3] & 0xff, isset($d[4]) ? $d[4] & 0xff : 255);
|
||||
return new DustParticle($pos, ((int) $d[1]) & 0xff, ((int) $d[2]) & 0xff, ((int) $d[3]) & 0xff, isset($d[4]) ? ((int) $d[4]) & 0xff : 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,10 +74,10 @@ class EntityDamageEvent extends EntityEvent implements Cancellable{
|
||||
|
||||
|
||||
/**
|
||||
* @param Entity $entity
|
||||
* @param int $cause
|
||||
* @param float $damage
|
||||
* @param float|float[] $modifiers
|
||||
* @param Entity $entity
|
||||
* @param int $cause
|
||||
* @param float $damage
|
||||
* @param float[] $modifiers
|
||||
*/
|
||||
public function __construct(Entity $entity, int $cause, float $damage, array $modifiers = []){
|
||||
$this->entity = $entity;
|
||||
|
@ -27,6 +27,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
|
||||
interface Inventory{
|
||||
@ -120,6 +122,15 @@ interface Inventory{
|
||||
*/
|
||||
public function setContents(array $items, bool $send = true) : void;
|
||||
|
||||
/**
|
||||
* Drops the contents of the inventory into the specified Level at the specified position and clears the inventory
|
||||
* contents.
|
||||
*
|
||||
* @param Level $level
|
||||
* @param Vector3 $position
|
||||
*/
|
||||
public function dropContents(Level $level, Vector3 $position) : void;
|
||||
|
||||
/**
|
||||
* @param Player|Player[] $target
|
||||
*/
|
||||
|
@ -196,16 +196,21 @@ class PlayerInventory extends BaseInventory{
|
||||
}
|
||||
|
||||
public function sendCreativeContents(){
|
||||
//TODO: this mess shouldn't be in here
|
||||
$holder = $this->getHolder();
|
||||
if(!($holder instanceof Player)){
|
||||
throw new \LogicException("Cannot send creative inventory contents to non-player inventory holder");
|
||||
}
|
||||
$pk = new InventoryContentPacket();
|
||||
$pk->windowId = ContainerIds::CREATIVE;
|
||||
|
||||
if(!$this->getHolder()->isSpectator()){ //fill it for all gamemodes except spectator
|
||||
if(!$holder->isSpectator()){ //fill it for all gamemodes except spectator
|
||||
foreach(Item::getCreativeItems() as $i => $item){
|
||||
$pk->items[$i] = clone $item;
|
||||
}
|
||||
}
|
||||
|
||||
$this->getHolder()->dataPacket($pk);
|
||||
$holder->dataPacket($pk);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,7 +153,7 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $index
|
||||
* @param int $index
|
||||
*
|
||||
* @return Item|null
|
||||
*/
|
||||
|
@ -686,7 +686,9 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
public function unregisterChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ){
|
||||
if(isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)][$hash = $loader->getLoaderId()])){
|
||||
$index = Level::chunkHash($chunkX, $chunkZ);
|
||||
$hash = $loader->getLoaderId();
|
||||
if(isset($this->chunkLoaders[$index][$hash])){
|
||||
unset($this->chunkLoaders[$index][$hash]);
|
||||
unset($this->playerLoaders[$index][$hash]);
|
||||
if(count($this->chunkLoaders[$index]) === 0){
|
||||
@ -1346,9 +1348,9 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $x
|
||||
* @param $y
|
||||
* @param $z
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return int bitmap, (id << 4) | data
|
||||
*/
|
||||
@ -2079,7 +2081,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $tileId
|
||||
* @param int $tileId
|
||||
*
|
||||
* @return Tile|null
|
||||
*/
|
||||
@ -2185,7 +2187,9 @@ class Level implements ChunkManager, Metadatable{
|
||||
if(!$this->isInWorld($x, $y, $z)){ //TODO: bad hack but fixing this requires BC breaks to do properly :(
|
||||
return;
|
||||
}
|
||||
unset($this->blockCache[$chunkHash = Level::chunkHash($x >> 4, $z >> 4)][$blockHash = Level::blockHash($x, $y, $z)]);
|
||||
$chunkHash = Level::chunkHash($x >> 4, $z >> 4);
|
||||
$blockHash = Level::blockHash($x, $y, $z);
|
||||
unset($this->blockCache[$chunkHash][$blockHash]);
|
||||
$this->getChunk($x >> 4, $z >> 4, true)->setBlockId($x & 0x0f, $y, $z & 0x0f, $id & 0xff);
|
||||
|
||||
if(!isset($this->changedBlocks[$chunkHash])){
|
||||
@ -2222,7 +2226,9 @@ class Level implements ChunkManager, Metadatable{
|
||||
if(!$this->isInWorld($x, $y, $z)){ //TODO: bad hack but fixing this requires BC breaks to do properly :(
|
||||
return;
|
||||
}
|
||||
unset($this->blockCache[$chunkHash = Level::chunkHash($x >> 4, $z >> 4)][$blockHash = Level::blockHash($x, $y, $z)]);
|
||||
$chunkHash = Level::chunkHash($x >> 4, $z >> 4);
|
||||
$blockHash = Level::blockHash($x, $y, $z);
|
||||
unset($this->blockCache[$chunkHash][$blockHash]);
|
||||
|
||||
$this->getChunk($x >> 4, $z >> 4, true)->setBlockData($x & 0x0f, $y, $z & 0x0f, $data & 0x0f);
|
||||
|
||||
|
@ -118,7 +118,7 @@ interface LevelProvider{
|
||||
public function getTime() : int;
|
||||
|
||||
/**
|
||||
* @param int
|
||||
* @param int $value
|
||||
*/
|
||||
public function setTime(int $value);
|
||||
|
||||
@ -128,7 +128,7 @@ interface LevelProvider{
|
||||
public function getSeed() : int;
|
||||
|
||||
/**
|
||||
* @param int
|
||||
* @param int $value
|
||||
*/
|
||||
public function setSeed(int $value);
|
||||
|
||||
|
@ -75,8 +75,9 @@ abstract class BiomeSelector{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $x
|
||||
* @param $z
|
||||
* TODO: not sure on types here
|
||||
* @param int|float $x
|
||||
* @param int|float $z
|
||||
*
|
||||
* @return Biome
|
||||
*/
|
||||
|
@ -100,7 +100,7 @@ abstract class MetadataStore{
|
||||
* @param Plugin $owningPlugin
|
||||
*/
|
||||
public function invalidateAll(Plugin $owningPlugin){
|
||||
/** @var $values MetadataValue[] */
|
||||
/** @var MetadataValue[] $values */
|
||||
foreach($this->metadataMap as $values){
|
||||
if(isset($values[$owningPlugin])){
|
||||
$values[$owningPlugin]->invalidate();
|
||||
|
@ -96,7 +96,7 @@ abstract class Tile extends Position{
|
||||
* @param string $type
|
||||
* @param Level $level
|
||||
* @param CompoundTag $nbt
|
||||
* @param $args
|
||||
* @param mixed ...$args
|
||||
*
|
||||
* @return Tile|null
|
||||
*/
|
||||
|
@ -111,9 +111,9 @@ class Config{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file
|
||||
* @param int $type
|
||||
* @param array $default
|
||||
* @param string $file
|
||||
* @param int $type
|
||||
* @param array $default
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@ -289,7 +289,7 @@ class Config{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $k
|
||||
* @param string $k
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
@ -298,15 +298,15 @@ class Config{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $k
|
||||
* @param $v
|
||||
* @param string $k
|
||||
* @param mixed $v
|
||||
*/
|
||||
public function __set($k, $v){
|
||||
$this->set($k, $v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $k
|
||||
* @param string $k
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@ -315,15 +315,15 @@ class Config{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $k
|
||||
* @param string $k
|
||||
*/
|
||||
public function __unset($k){
|
||||
$this->remove($k);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param $value
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setNested($key, $value){
|
||||
$vars = explode(".", $key);
|
||||
@ -349,8 +349,8 @@ class Config{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param mixed $default
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@ -401,8 +401,8 @@ class Config{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $k
|
||||
* @param mixed $default
|
||||
* @param string $k
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
@ -433,8 +433,8 @@ class Config{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $k
|
||||
* @param bool $lowercase If set, searches Config in single-case / lowercase.
|
||||
* @param string $k
|
||||
* @param bool $lowercase If set, searches Config in single-case / lowercase.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@ -449,7 +449,7 @@ class Config{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $k
|
||||
* @param string $k
|
||||
*/
|
||||
public function remove($k){
|
||||
unset($this->config[$k]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user