mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 12:27:51 +00:00
Clean up entity and tile saveID handling
we only ever need the first entry, so there's no point storing all of them. In addition, the field is private, which guarantees that nothing else needs the array either. This also fixes phpstan/phpstan@c50650c5dd.
This commit is contained in:
parent
574b7f6343
commit
e30b1ee2c7
@ -77,7 +77,6 @@ use function abs;
|
|||||||
use function assert;
|
use function assert;
|
||||||
use function cos;
|
use function cos;
|
||||||
use function count;
|
use function count;
|
||||||
use function current;
|
|
||||||
use function deg2rad;
|
use function deg2rad;
|
||||||
use function floor;
|
use function floor;
|
||||||
use function fmod;
|
use function fmod;
|
||||||
@ -334,8 +333,8 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
|||||||
*/
|
*/
|
||||||
private static $knownEntities = [];
|
private static $knownEntities = [];
|
||||||
/**
|
/**
|
||||||
* @var string[][]
|
* @var string[]
|
||||||
* @phpstan-var array<class-string<Entity>, list<string>>
|
* @phpstan-var array<class-string<Entity>, string>
|
||||||
*/
|
*/
|
||||||
private static $saveNames = [];
|
private static $saveNames = [];
|
||||||
|
|
||||||
@ -414,7 +413,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
|||||||
self::$knownEntities[$name] = $className;
|
self::$knownEntities[$name] = $className;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$saveNames[$className] = $saveNames;
|
self::$saveNames[$className] = reset($saveNames);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -872,8 +871,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
|||||||
if(!isset(self::$saveNames[static::class])){
|
if(!isset(self::$saveNames[static::class])){
|
||||||
throw new \InvalidStateException("Entity " . static::class . " is not registered");
|
throw new \InvalidStateException("Entity " . static::class . " is not registered");
|
||||||
}
|
}
|
||||||
reset(self::$saveNames[static::class]);
|
return self::$saveNames[static::class];
|
||||||
return current(self::$saveNames[static::class]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveNBT() : void{
|
public function saveNBT() : void{
|
||||||
|
@ -39,7 +39,6 @@ use pocketmine\Player;
|
|||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
use pocketmine\timings\Timings;
|
use pocketmine\timings\Timings;
|
||||||
use pocketmine\timings\TimingsHandler;
|
use pocketmine\timings\TimingsHandler;
|
||||||
use function current;
|
|
||||||
use function get_class;
|
use function get_class;
|
||||||
use function in_array;
|
use function in_array;
|
||||||
use function is_a;
|
use function is_a;
|
||||||
@ -74,8 +73,8 @@ abstract class Tile extends Position{
|
|||||||
*/
|
*/
|
||||||
private static $knownTiles = [];
|
private static $knownTiles = [];
|
||||||
/**
|
/**
|
||||||
* @var string[][]
|
* @var string[]
|
||||||
* @phpstan-var array<class-string<Tile>, list<string>>
|
* @phpstan-var array<class-string<Tile>, string>
|
||||||
*/
|
*/
|
||||||
private static $saveNames = [];
|
private static $saveNames = [];
|
||||||
|
|
||||||
@ -138,7 +137,7 @@ abstract class Tile extends Position{
|
|||||||
self::$knownTiles[$name] = $className;
|
self::$knownTiles[$name] = $className;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$saveNames[$className] = $saveNames;
|
self::$saveNames[$className] = reset($saveNames);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -154,8 +153,7 @@ abstract class Tile extends Position{
|
|||||||
throw new \InvalidStateException("Tile is not registered");
|
throw new \InvalidStateException("Tile is not registered");
|
||||||
}
|
}
|
||||||
|
|
||||||
reset(self::$saveNames[static::class]);
|
return self::$saveNames[static::class];
|
||||||
return current(self::$saveNames[static::class]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct(Level $level, CompoundTag $nbt){
|
public function __construct(Level $level, CompoundTag $nbt){
|
||||||
|
@ -185,11 +185,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/pocketmine/entity/Effect.php
|
path: ../../../src/pocketmine/entity/Effect.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method pocketmine\\\\entity\\\\Entity\\:\\:getSaveId\\(\\) should return string but returns mixed\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/pocketmine/entity/Entity.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Cannot cast mixed to int\\.$#"
|
message: "#^Cannot cast mixed to int\\.$#"
|
||||||
count: 2
|
count: 2
|
||||||
@ -560,11 +555,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/pocketmine/scheduler/AsyncTask.php
|
path: ../../../src/pocketmine/scheduler/AsyncTask.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method pocketmine\\\\tile\\\\Tile\\:\\:getSaveId\\(\\) should return string but returns mixed\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/pocketmine/tile/Tile.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Parameter \\#2 \\$timestamp of function date expects int, mixed given\\.$#"
|
message: "#^Parameter \\#2 \\$timestamp of function date expects int, mixed given\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
@ -390,6 +390,11 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/pocketmine/command/defaults/TimingsCommand.php
|
path: ../../../src/pocketmine/command/defaults/TimingsCommand.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Array \\(array\\<class\\-string\\<pocketmine\\\\entity\\\\Entity\\>, string\\>\\) does not accept string\\|false\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: ../../../src/pocketmine/entity/Entity.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Parameter \\#1 \\$index of method pocketmine\\\\inventory\\\\BaseInventory\\:\\:setItem\\(\\) expects int, int\\|string given\\.$#"
|
message: "#^Parameter \\#1 \\$index of method pocketmine\\\\inventory\\\\BaseInventory\\:\\:setItem\\(\\) expects int, int\\|string given\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
@ -985,6 +990,11 @@ parameters:
|
|||||||
count: 3
|
count: 3
|
||||||
path: ../../../src/pocketmine/tile/Spawnable.php
|
path: ../../../src/pocketmine/tile/Spawnable.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Array \\(array\\<class\\-string\\<pocketmine\\\\tile\\\\Tile\\>, string\\>\\) does not accept string\\|false\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: ../../../src/pocketmine/tile/Tile.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Parameter \\#2 \\$value of method pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\:\\:setInt\\(\\) expects int, float\\|int given\\.$#"
|
message: "#^Parameter \\#2 \\$value of method pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\:\\:setInt\\(\\) expects int, float\\|int given\\.$#"
|
||||||
count: 3
|
count: 3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user