diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index bcc93a2a2..ac556a550 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -46,9 +46,6 @@ use pocketmine\item\ItemFactory; use pocketmine\lang\Language; use pocketmine\lang\LanguageNotFoundException; use pocketmine\lang\TextContainer; -use pocketmine\metadata\EntityMetadataStore; -use pocketmine\metadata\PlayerMetadataStore; -use pocketmine\metadata\WorldMetadataStore; use pocketmine\nbt\BigEndianNbtSerializer; use pocketmine\nbt\NbtDataException; use pocketmine\nbt\tag\CompoundTag; @@ -246,15 +243,6 @@ class Server{ /** @var bool */ private $onlineMode = true; - /** @var EntityMetadataStore */ - private $entityMetadata; - - /** @var PlayerMetadataStore */ - private $playerMetadata; - - /** @var WorldMetadataStore */ - private $worldMetadata; - /** @var Network */ private $network; /** @var bool */ @@ -477,27 +465,6 @@ class Server{ return $this->logger; } - /** - * @return EntityMetadataStore - */ - public function getEntityMetadata(){ - return $this->entityMetadata; - } - - /** - * @return PlayerMetadataStore - */ - public function getPlayerMetadata(){ - return $this->playerMetadata; - } - - /** - * @return WorldMetadataStore - */ - public function getWorldMetadata(){ - return $this->worldMetadata; - } - /** * @return AutoUpdater */ @@ -1138,10 +1105,6 @@ class Server{ $this->doTitleTick = ((bool) $this->getProperty("console.title-tick", true)) && Terminal::hasFormattingCodes(); - $this->entityMetadata = new EntityMetadataStore(); - $this->playerMetadata = new PlayerMetadataStore(); - $this->worldMetadata = new WorldMetadataStore(); - $this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM); $this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM); if(file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")){ diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index b3261209b..4062d1235 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -38,12 +38,9 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; use pocketmine\math\RayTraceResult; use pocketmine\math\Vector3; -use pocketmine\metadata\Metadatable; -use pocketmine\metadata\MetadataValue; use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\mcpe\protocol\types\RuntimeBlockMapping; use pocketmine\player\Player; -use pocketmine\plugin\Plugin; use pocketmine\world\BlockTransaction; use pocketmine\world\Position; use pocketmine\world\World; @@ -52,7 +49,7 @@ use function assert; use function dechex; use const PHP_INT_MAX; -class Block extends Position implements BlockLegacyIds, Metadatable{ +class Block extends Position implements BlockLegacyIds{ /** * Returns a new Block instance with the specified ID, meta and position. @@ -752,32 +749,4 @@ class Block extends Position implements BlockLegacyIds, Metadatable{ return $currentHit; } - - public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue) : void{ - if($this->isValid()){ - $this->world->getBlockMetadata()->setMetadata($this, $metadataKey, $newMetadataValue); - } - } - - public function getMetadata(string $metadataKey){ - if($this->isValid()){ - return $this->world->getBlockMetadata()->getMetadata($this, $metadataKey); - } - - return null; - } - - public function hasMetadata(string $metadataKey) : bool{ - if($this->isValid()){ - return $this->world->getBlockMetadata()->hasMetadata($this, $metadataKey); - } - - return false; - } - - public function removeMetadata(string $metadataKey, Plugin $owningPlugin) : void{ - if($this->isValid()){ - $this->world->getBlockMetadata()->removeMetadata($this, $metadataKey, $owningPlugin); - } - } } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index db768c7fa..49bea4aa0 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -39,8 +39,6 @@ use pocketmine\math\Bearing; use pocketmine\math\Facing; use pocketmine\math\Vector2; use pocketmine\math\Vector3; -use pocketmine\metadata\Metadatable; -use pocketmine\metadata\MetadataValue; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\DoubleTag; use pocketmine\nbt\tag\FloatTag; @@ -58,7 +56,6 @@ use pocketmine\network\mcpe\protocol\types\EntityMetadataFlags; use pocketmine\network\mcpe\protocol\types\EntityMetadataProperties; use pocketmine\network\mcpe\protocol\types\EntityMetadataTypes; use pocketmine\player\Player; -use pocketmine\plugin\Plugin; use pocketmine\Server; use pocketmine\timings\Timings; use pocketmine\timings\TimingsHandler; @@ -81,7 +78,7 @@ use function sin; use function spl_object_id; use const M_PI_2; -abstract class Entity extends Location implements Metadatable, EntityIds{ +abstract class Entity extends Location implements EntityIds{ public const MOTION_THRESHOLD = 0.00001; @@ -1798,22 +1795,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->close(); } - public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue) : void{ - $this->server->getEntityMetadata()->setMetadata($this, $metadataKey, $newMetadataValue); - } - - public function getMetadata(string $metadataKey){ - return $this->server->getEntityMetadata()->getMetadata($this, $metadataKey); - } - - public function hasMetadata(string $metadataKey) : bool{ - return $this->server->getEntityMetadata()->hasMetadata($this, $metadataKey); - } - - public function removeMetadata(string $metadataKey, Plugin $owningPlugin) : void{ - $this->server->getEntityMetadata()->removeMetadata($this, $metadataKey, $owningPlugin); - } - public function __toString(){ return (new \ReflectionClass($this))->getShortName() . "(" . $this->getId() . ")"; } diff --git a/src/pocketmine/metadata/BlockMetadataStore.php b/src/pocketmine/metadata/BlockMetadataStore.php deleted file mode 100644 index 87cfd85f9..000000000 --- a/src/pocketmine/metadata/BlockMetadataStore.php +++ /dev/null @@ -1,60 +0,0 @@ -owningLevel = $owningLevel; - } - - private function disambiguate(Block $block, string $metadataKey) : string{ - if($block->getWorld() !== $this->owningLevel){ - throw new \InvalidStateException("Block does not belong to world " . $this->owningLevel->getDisplayName()); - } - return $block->x . ":" . $block->y . ":" . $block->z . ":" . $metadataKey; - } - - public function getMetadata(Block $subject, string $metadataKey){ - return $this->getMetadataInternal($this->disambiguate($subject, $metadataKey)); - } - - public function hasMetadata(Block $subject, string $metadataKey) : bool{ - return $this->hasMetadataInternal($this->disambiguate($subject, $metadataKey)); - } - - public function removeMetadata(Block $subject, string $metadataKey, Plugin $owningPlugin) : void{ - $this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin); - } - - public function setMetadata(Block $subject, string $metadataKey, MetadataValue $newMetadataValue) : void{ - $this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue); - } -} diff --git a/src/pocketmine/metadata/EntityMetadataStore.php b/src/pocketmine/metadata/EntityMetadataStore.php deleted file mode 100644 index b7d133261..000000000 --- a/src/pocketmine/metadata/EntityMetadataStore.php +++ /dev/null @@ -1,50 +0,0 @@ -getId() . ":" . $metadataKey; - } - - public function getMetadata(Entity $subject, string $metadataKey){ - return $this->getMetadataInternal($this->disambiguate($subject, $metadataKey)); - } - - public function hasMetadata(Entity $subject, string $metadataKey) : bool{ - return $this->hasMetadataInternal($this->disambiguate($subject, $metadataKey)); - } - - public function removeMetadata(Entity $subject, string $metadataKey, Plugin $owningPlugin) : void{ - $this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin); - } - - public function setMetadata(Entity $subject, string $metadataKey, MetadataValue $newMetadataValue) : void{ - $this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue); - } -} diff --git a/src/pocketmine/metadata/MetadataStore.php b/src/pocketmine/metadata/MetadataStore.php deleted file mode 100644 index 99e21a25e..000000000 --- a/src/pocketmine/metadata/MetadataStore.php +++ /dev/null @@ -1,110 +0,0 @@ -getOwningPlugin(); - - if(!isset($this->metadataMap[$key])){ - $entry = new \SplObjectStorage(); - $this->metadataMap[$key] = $entry; - }else{ - $entry = $this->metadataMap[$key]; - } - $entry[$owningPlugin] = $newMetadataValue; - } - - /** - * Returns all metadata values attached to an object. If multiple - * have attached metadata, each will value will be included. - * - * @param string $key - * - * @return MetadataValue[] - */ - protected function getMetadataInternal(string $key){ - if(isset($this->metadataMap[$key])){ - return $this->metadataMap[$key]; - }else{ - return []; - } - } - - /** - * Tests to see if a metadata attribute has been set on an object. - * - * @param string $key - * - * @return bool - */ - protected function hasMetadataInternal(string $key) : bool{ - return isset($this->metadataMap[$key]); - } - - /** - * Removes a metadata item owned by a plugin from a subject. - * - * @param string $key - * @param Plugin $owningPlugin - */ - protected function removeMetadataInternal(string $key, Plugin $owningPlugin) : void{ - if(isset($this->metadataMap[$key])){ - unset($this->metadataMap[$key][$owningPlugin]); - if($this->metadataMap[$key]->count() === 0){ - unset($this->metadataMap[$key]); - } - } - } - - /** - * Invalidates all metadata in the metadata store that originates from the - * given plugin. Doing this will force each invalidated metadata item to - * be recalculated the next time it is accessed. - * - * @param Plugin $owningPlugin - */ - public function invalidateAll(Plugin $owningPlugin) : void{ - /** @var MetadataValue[] $values */ - foreach($this->metadataMap as $values){ - if(isset($values[$owningPlugin])){ - $values[$owningPlugin]->invalidate(); - } - } - } -} diff --git a/src/pocketmine/metadata/MetadataValue.php b/src/pocketmine/metadata/MetadataValue.php deleted file mode 100644 index 9f678df3a..000000000 --- a/src/pocketmine/metadata/MetadataValue.php +++ /dev/null @@ -1,55 +0,0 @@ -owningPlugin = $owningPlugin; - } - - /** - * @return Plugin - */ - public function getOwningPlugin() : Plugin{ - return $this->owningPlugin; - } - - /** - * Fetches the value of this metadata item. - * - * @return mixed - */ - abstract public function value(); - - /** - * Invalidates this metadata item, forcing it to recompute when next - * accessed. - */ - abstract public function invalidate() : void; -} diff --git a/src/pocketmine/metadata/Metadatable.php b/src/pocketmine/metadata/Metadatable.php deleted file mode 100644 index eadcbef73..000000000 --- a/src/pocketmine/metadata/Metadatable.php +++ /dev/null @@ -1,67 +0,0 @@ -getName()) . ":" . $metadataKey; - } - - public function getMetadata(IPlayer $subject, string $metadataKey){ - return $this->getMetadataInternal($this->disambiguate($subject, $metadataKey)); - } - - public function hasMetadata(IPlayer $subject, string $metadataKey) : bool{ - return $this->hasMetadataInternal($this->disambiguate($subject, $metadataKey)); - } - - public function removeMetadata(IPlayer $subject, string $metadataKey, Plugin $owningPlugin) : void{ - $this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin); - } - - public function setMetadata(IPlayer $subject, string $metadataKey, MetadataValue $newMetadataValue) : void{ - $this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue); - } -} diff --git a/src/pocketmine/metadata/WorldMetadataStore.php b/src/pocketmine/metadata/WorldMetadataStore.php deleted file mode 100644 index 7893ba19a..000000000 --- a/src/pocketmine/metadata/WorldMetadataStore.php +++ /dev/null @@ -1,51 +0,0 @@ -getFolderName()) . ":" . $metadataKey; - } - - public function getMetadata(World $subject, string $metadataKey){ - return $this->getMetadataInternal($this->disambiguate($subject, $metadataKey)); - } - - public function hasMetadata(World $subject, string $metadataKey) : bool{ - return $this->hasMetadataInternal($this->disambiguate($subject, $metadataKey)); - } - - public function removeMetadata(World $subject, string $metadataKey, Plugin $owningPlugin) : void{ - $this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin); - } - - public function setMetadata(World $subject, string $metadataKey, MetadataValue $newMetadataValue) : void{ - $this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue); - } -} diff --git a/src/pocketmine/player/OfflinePlayer.php b/src/pocketmine/player/OfflinePlayer.php index 81a77d250..f04b79eac 100644 --- a/src/pocketmine/player/OfflinePlayer.php +++ b/src/pocketmine/player/OfflinePlayer.php @@ -23,14 +23,11 @@ declare(strict_types=1); namespace pocketmine\player; -use pocketmine\metadata\Metadatable; -use pocketmine\metadata\MetadataValue; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\LongTag; -use pocketmine\plugin\Plugin; use pocketmine\Server; -class OfflinePlayer implements IPlayer, Metadatable{ +class OfflinePlayer implements IPlayer{ /** @var string */ private $name; @@ -116,20 +113,4 @@ class OfflinePlayer implements IPlayer, Metadatable{ public function hasPlayedBefore() : bool{ return $this->namedtag !== null; } - - public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue) : void{ - $this->server->getPlayerMetadata()->setMetadata($this, $metadataKey, $newMetadataValue); - } - - public function getMetadata(string $metadataKey){ - return $this->server->getPlayerMetadata()->getMetadata($this, $metadataKey); - } - - public function hasMetadata(string $metadataKey) : bool{ - return $this->server->getPlayerMetadata()->hasMetadata($this, $metadataKey); - } - - public function removeMetadata(string $metadataKey, Plugin $owningPlugin) : void{ - $this->server->getPlayerMetadata()->removeMetadata($this, $metadataKey, $owningPlugin); - } } diff --git a/src/pocketmine/player/Player.php b/src/pocketmine/player/Player.php index b9dd0d655..f62428432 100644 --- a/src/pocketmine/player/Player.php +++ b/src/pocketmine/player/Player.php @@ -80,7 +80,6 @@ use pocketmine\item\ItemUseResult; use pocketmine\lang\TextContainer; use pocketmine\lang\TranslationContainer; use pocketmine\math\Vector3; -use pocketmine\metadata\MetadataValue; use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\DoubleTag; @@ -98,7 +97,6 @@ use pocketmine\network\mcpe\protocol\types\PlayerMetadataFlags; use pocketmine\permission\PermissibleBase; use pocketmine\permission\PermissibleDelegateTrait; use pocketmine\permission\PermissionManager; -use pocketmine\plugin\Plugin; use pocketmine\Server; use pocketmine\timings\Timings; use pocketmine\utils\TextFormat; @@ -2677,22 +2675,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, $this->permanentWindows = []; } - public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue) : void{ - $this->server->getPlayerMetadata()->setMetadata($this, $metadataKey, $newMetadataValue); - } - - public function getMetadata(string $metadataKey){ - return $this->server->getPlayerMetadata()->getMetadata($this, $metadataKey); - } - - public function hasMetadata(string $metadataKey) : bool{ - return $this->server->getPlayerMetadata()->hasMetadata($this, $metadataKey); - } - - public function removeMetadata(string $metadataKey, Plugin $owningPlugin) : void{ - $this->server->getPlayerMetadata()->removeMetadata($this, $metadataKey, $owningPlugin); - } - use ChunkListenerNoOpTrait { onChunkChanged as private; } diff --git a/src/pocketmine/world/World.php b/src/pocketmine/world/World.php index 2472868b6..d62276639 100644 --- a/src/pocketmine/world/World.php +++ b/src/pocketmine/world/World.php @@ -51,9 +51,6 @@ use pocketmine\item\ItemFactory; use pocketmine\item\ItemUseResult; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Vector3; -use pocketmine\metadata\BlockMetadataStore; -use pocketmine\metadata\Metadatable; -use pocketmine\metadata\MetadataValue; use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\StringTag; use pocketmine\network\mcpe\protocol\BlockEntityDataPacket; @@ -64,7 +61,6 @@ use pocketmine\network\mcpe\protocol\SetTimePacket; use pocketmine\network\mcpe\protocol\types\RuntimeBlockMapping; use pocketmine\network\mcpe\protocol\UpdateBlockPacket; use pocketmine\player\Player; -use pocketmine\plugin\Plugin; use pocketmine\Server; use pocketmine\timings\Timings; use pocketmine\utils\ReversePriorityQueue; @@ -115,7 +111,7 @@ use const PHP_INT_MIN; #include -class World implements ChunkManager, Metadatable{ +class World implements ChunkManager{ private static $worldIdCounter = 1; @@ -227,9 +223,6 @@ class World implements ChunkManager, Metadatable{ /** @var bool */ private $autoSave = true; - /** @var BlockMetadataStore */ - private $blockMetadata; - /** @var Position */ private $temporalPosition; /** @var Vector3 */ @@ -349,7 +342,6 @@ class World implements ChunkManager, Metadatable{ */ public function __construct(Server $server, string $name, WritableWorldProvider $provider){ $this->worldId = static::$worldIdCounter++; - $this->blockMetadata = new BlockMetadataStore($this); $this->server = $server; $this->provider = $provider; @@ -416,10 +408,6 @@ class World implements ChunkManager, Metadatable{ $this->generatorRegisteredWorkers = []; } - public function getBlockMetadata() : BlockMetadataStore{ - return $this->blockMetadata; - } - public function getServer() : Server{ return $this->server; } @@ -461,7 +449,6 @@ class World implements ChunkManager, Metadatable{ $this->provider->close(); $this->provider = null; - $this->blockMetadata = null; $this->blockCache = []; $this->temporalPosition = null; @@ -2857,20 +2844,4 @@ class World implements ChunkManager, Metadatable{ } } } - - public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue) : void{ - $this->server->getWorldMetadata()->setMetadata($this, $metadataKey, $newMetadataValue); - } - - public function getMetadata(string $metadataKey){ - return $this->server->getWorldMetadata()->getMetadata($this, $metadataKey); - } - - public function hasMetadata(string $metadataKey) : bool{ - return $this->server->getWorldMetadata()->hasMetadata($this, $metadataKey); - } - - public function removeMetadata(string $metadataKey, Plugin $owningPlugin) : void{ - $this->server->getWorldMetadata()->removeMetadata($this, $metadataKey, $owningPlugin); - } }