Files
PocketMine-MP/src/pocketmine/metadata/EntityMetadataStore.php
Dylan K. Taylor 6579930638 Revamp MetadataStore API (#2477)
This would be a lot less messy if we had generics, but no tango.
2018-10-12 12:16:21 +01:00

51 lines
1.7 KiB
PHP

<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\metadata;
use pocketmine\entity\Entity;
use pocketmine\plugin\Plugin;
class EntityMetadataStore extends MetadataStore{
private function disambiguate(Entity $entity, string $metadataKey) : string{
return $entity->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){
$this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin);
}
public function setMetadata(Entity $subject, string $metadataKey, MetadataValue $newMetadataValue){
$this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue);
}
}