mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Fixed invalid metadata and updated weak references on PluginManager
This commit is contained in:
@ -33,8 +33,10 @@ class BlockMetadataStore extends MetadataStore{
|
||||
$this->owningLevel = $owningLevel;
|
||||
}
|
||||
|
||||
/** @noinspection PhpHierarchyChecksInspection */
|
||||
public function disambiguate(Block $block, $metadataKey){
|
||||
public function disambiguate(Metadatable $block, $metadataKey){
|
||||
if(!($block instanceof Block)){
|
||||
throw new \InvalidArgumentException("Argument must be a Block instance");
|
||||
}
|
||||
return $block->x . ":" . $block->y . ":" . $block->z . ":" . $metadataKey;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,10 @@ use pocketmine\entity\Entity;
|
||||
|
||||
class EntityMetadataStore extends MetadataStore{
|
||||
|
||||
/** @noinspection PhpHierarchyChecksInspection */
|
||||
public function disambiguate(Entity $entity, $metadataKey){
|
||||
public function disambiguate(Metadatable $entity, $metadataKey){
|
||||
if(!($entity instanceof Entity)){
|
||||
throw new \InvalidArgumentException("Argument must be an Entity instance");
|
||||
}
|
||||
return $entity->getID() . ":" . $metadataKey;
|
||||
}
|
||||
}
|
@ -25,8 +25,10 @@ use pocketmine\level\Level;
|
||||
|
||||
class LevelMetadataStore extends MetadataStore{
|
||||
|
||||
/** @noinspection PhpHierarchyChecksInspection */
|
||||
public function disambiguate(Level $level, $metadataKey){
|
||||
public function disambiguate(Metadatable $level, $metadataKey){
|
||||
if(!($level instanceof Level)){
|
||||
throw new \InvalidArgumentException("Argument must be a Level instance");
|
||||
}
|
||||
return strtolower($level->getName()) . ":" . $metadataKey;
|
||||
}
|
||||
}
|
@ -45,7 +45,7 @@ abstract class MetadataStore{
|
||||
return;
|
||||
}
|
||||
|
||||
$key = $this->disambiguate($subject, $newMetadataValue);
|
||||
$key = $this->disambiguate($subject, $metadataKey);
|
||||
if(!isset($this->metadataMap[$key])){
|
||||
$entry = new \WeakMap();
|
||||
$this->metadataMap[$key] = $entry;
|
||||
@ -122,10 +122,12 @@ abstract class MetadataStore{
|
||||
* Creates a unique name for the object receiving metadata by combining
|
||||
* unique data from the subject with a metadataKey.
|
||||
*
|
||||
* @param mixed $subject
|
||||
* @param string $metadataKey
|
||||
* @param Metadatable $subject
|
||||
* @param string $metadataKey
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public abstract function disambiguate($subject, $metadataKey);
|
||||
public abstract function disambiguate(Metadatable $subject, $metadataKey);
|
||||
}
|
@ -25,8 +25,10 @@ use pocketmine\OfflinePlayer;
|
||||
|
||||
class PlayerMetadataStore extends MetadataStore{
|
||||
|
||||
/** @noinspection PhpHierarchyChecksInspection */
|
||||
public function disambiguate(OfflinePlayer $player, $metadataKey){
|
||||
public function disambiguate(Metadatable $player, $metadataKey){
|
||||
if(!($player instanceof OfflinePlayer)){
|
||||
throw new \InvalidArgumentException("Argument must be an OfflinePlayer instance");
|
||||
}
|
||||
return strtolower($player->getName()) . ":" . $metadataKey;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user