Renaming "Level" -> "World" (#2907)

This has been a pain point for a long time due to the misleading nature of the name "level". It's also confusing when trying to do things like getting the XP level of the player or such, and also does not translate well to other languages.

This transition was already executed on the UI some time ago (language strings) and now it's time for the same change to occur on the API.

This will burn a lot of plugins, but they'll acclimatize. Despite the scary size of this PR, there isn't actually so many changes to make. Most of this came from renaming `Position->getLevel()` to `Position->getWorld()`, or cosmetic changes like changing variable names or doc comments.
This commit is contained in:
Dylan T
2019-05-07 14:47:28 +01:00
committed by GitHub
parent 427e334426
commit 3cd6e12e71
310 changed files with 1647 additions and 1628 deletions

View File

@ -24,19 +24,19 @@ declare(strict_types=1);
namespace pocketmine\metadata;
use pocketmine\block\Block;
use pocketmine\level\Level;
use pocketmine\plugin\Plugin;
use pocketmine\world\World;
class BlockMetadataStore extends MetadataStore{
/** @var Level */
/** @var World */
private $owningLevel;
public function __construct(Level $owningLevel){
public function __construct(World $owningLevel){
$this->owningLevel = $owningLevel;
}
private function disambiguate(Block $block, string $metadataKey) : string{
if($block->getLevel() !== $this->owningLevel){
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;

View File

@ -23,29 +23,29 @@ declare(strict_types=1);
namespace pocketmine\metadata;
use pocketmine\level\Level;
use pocketmine\plugin\Plugin;
use pocketmine\world\World;
use function strtolower;
class LevelMetadataStore extends MetadataStore{
class WorldMetadataStore extends MetadataStore{
private function disambiguate(Level $level, string $metadataKey) : string{
return strtolower($level->getFolderName()) . ":" . $metadataKey;
private function disambiguate(World $world, string $metadataKey) : string{
return strtolower($world->getFolderName()) . ":" . $metadataKey;
}
public function getMetadata(Level $subject, string $metadataKey){
public function getMetadata(World $subject, string $metadataKey){
return $this->getMetadataInternal($this->disambiguate($subject, $metadataKey));
}
public function hasMetadata(Level $subject, string $metadataKey) : bool{
public function hasMetadata(World $subject, string $metadataKey) : bool{
return $this->hasMetadataInternal($this->disambiguate($subject, $metadataKey));
}
public function removeMetadata(Level $subject, string $metadataKey, Plugin $owningPlugin) : void{
public function removeMetadata(World $subject, string $metadataKey, Plugin $owningPlugin) : void{
$this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin);
}
public function setMetadata(Level $subject, string $metadataKey, MetadataValue $newMetadataValue) : void{
public function setMetadata(World $subject, string $metadataKey, MetadataValue $newMetadataValue) : void{
$this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue);
}
}