Backport 58cafc853f2caa013c65d98ab56f13ac3abe521c: s/level/world (strings only)

we should look at doing this for code too, but for now I'm not planning to break everyone's plugins.
This commit is contained in:
Dylan K. Taylor 2019-02-20 15:33:46 +00:00
parent 5c12bee874
commit 562179bdd6
5 changed files with 20 additions and 20 deletions

View File

@ -1046,7 +1046,7 @@ class Server{
*/ */
public function unloadLevel(Level $level, bool $forceUnload = false) : bool{ public function unloadLevel(Level $level, bool $forceUnload = false) : bool{
if($level === $this->getDefaultLevel() and !$forceUnload){ if($level === $this->getDefaultLevel() and !$forceUnload){
throw new \InvalidStateException("The default level cannot be unloaded while running, please switch levels."); throw new \InvalidStateException("The default world cannot be unloaded while running, please switch worlds.");
} }
return $level->unload($forceUnload); return $level->unload($forceUnload);
@ -1072,7 +1072,7 @@ class Server{
*/ */
public function loadLevel(string $name) : bool{ public function loadLevel(string $name) : bool{
if(trim($name) === ""){ if(trim($name) === ""){
throw new LevelException("Invalid empty level name"); throw new LevelException("Invalid empty world name");
} }
if($this->isLevelLoaded($name)){ if($this->isLevelLoaded($name)){
return true; return true;
@ -1130,7 +1130,7 @@ class Server{
if(($providerClass = LevelProviderManager::getProviderByName($this->getProperty("level-settings.default-format", "pmanvil"))) === null){ if(($providerClass = LevelProviderManager::getProviderByName($this->getProperty("level-settings.default-format", "pmanvil"))) === null){
$providerClass = LevelProviderManager::getProviderByName("pmanvil"); $providerClass = LevelProviderManager::getProviderByName("pmanvil");
if($providerClass === null){ if($providerClass === null){
throw new \InvalidStateException("Default level provider has not been registered"); throw new \InvalidStateException("Default world provider has not been registered");
} }
} }
@ -2019,7 +2019,7 @@ class Server{
} }
public function reload(){ public function reload(){
$this->logger->info("Saving levels..."); $this->logger->info("Saving worlds...");
foreach($this->levels as $level){ foreach($this->levels as $level){
$level->save(); $level->save();
@ -2097,7 +2097,7 @@ class Server{
$player->close($player->getLeaveMessage(), $this->getProperty("settings.shutdown-message", "Server closed")); $player->close($player->getLeaveMessage(), $this->getProperty("settings.shutdown-message", "Server closed"));
} }
$this->getLogger()->debug("Unloading all levels"); $this->getLogger()->debug("Unloading all worlds");
foreach($this->getLevels() as $level){ foreach($this->getLevels() as $level){
$this->unloadLevel($level, true); $this->unloadLevel($level, true);
} }

View File

@ -74,7 +74,7 @@ class Explosion{
*/ */
public function __construct(Position $center, float $size, $what = null){ public function __construct(Position $center, float $size, $what = null){
if(!$center->isValid()){ if(!$center->isValid()){
throw new \InvalidArgumentException("Position does not have a valid level"); throw new \InvalidArgumentException("Position does not have a valid world");
} }
$this->source = $center; $this->source = $center;
$this->level = $center->getLevel(); $this->level = $center->getLevel();

View File

@ -474,7 +474,7 @@ class Level implements ChunkManager, Metadatable{
public function close(){ public function close(){
if($this->closed){ if($this->closed){
throw new \InvalidStateException("Tried to close a level which is already closed"); throw new \InvalidStateException("Tried to close a world which is already closed");
} }
foreach($this->chunks as $chunk){ foreach($this->chunks as $chunk){
@ -588,7 +588,7 @@ class Level implements ChunkManager, Metadatable{
*/ */
public function unload(bool $force = false) : bool{ public function unload(bool $force = false) : bool{
if($this->doingTick and !$force){ if($this->doingTick and !$force){
throw new \InvalidStateException("Cannot unload a level during level tick"); throw new \InvalidStateException("Cannot unload a world during world tick");
} }
$ev = new LevelUnloadEvent($this); $ev = new LevelUnloadEvent($this);
@ -607,7 +607,7 @@ class Level implements ChunkManager, Metadatable{
$defaultLevel = $this->server->getDefaultLevel(); $defaultLevel = $this->server->getDefaultLevel();
foreach($this->getPlayers() as $player){ foreach($this->getPlayers() as $player){
if($this === $defaultLevel or $defaultLevel === null){ if($this === $defaultLevel or $defaultLevel === null){
$player->close($player->getLeaveMessage(), "Forced default level unload"); $player->close($player->getLeaveMessage(), "Forced default world unload");
}elseif($defaultLevel instanceof Level){ }elseif($defaultLevel instanceof Level){
$player->teleport($this->server->getDefaultLevel()->getSafeSpawn()); $player->teleport($this->server->getDefaultLevel()->getSafeSpawn());
} }
@ -785,7 +785,7 @@ class Level implements ChunkManager, Metadatable{
*/ */
public function doTick(int $currentTick){ public function doTick(int $currentTick){
if($this->closed){ if($this->closed){
throw new \InvalidStateException("Attempted to tick a Level which has been closed"); throw new \InvalidStateException("Attempted to tick a world which has been closed");
} }
$this->timings->doTick->startTiming(); $this->timings->doTick->startTiming();
@ -2699,10 +2699,10 @@ class Level implements ChunkManager, Metadatable{
*/ */
public function addEntity(Entity $entity){ public function addEntity(Entity $entity){
if($entity->isClosed()){ if($entity->isClosed()){
throw new \InvalidArgumentException("Attempted to add a garbage closed Entity to Level"); throw new \InvalidArgumentException("Attempted to add a garbage closed Entity to world");
} }
if($entity->getLevel() !== $this){ if($entity->getLevel() !== $this){
throw new LevelException("Invalid Entity level"); throw new LevelException("Invalid Entity world");
} }
if($entity instanceof Player){ if($entity instanceof Player){
@ -2720,7 +2720,7 @@ class Level implements ChunkManager, Metadatable{
*/ */
public function removeEntity(Entity $entity){ public function removeEntity(Entity $entity){
if($entity->getLevel() !== $this){ if($entity->getLevel() !== $this){
throw new LevelException("Invalid Entity level"); throw new LevelException("Invalid Entity world");
} }
if($entity instanceof Player){ if($entity instanceof Player){
@ -2739,10 +2739,10 @@ class Level implements ChunkManager, Metadatable{
*/ */
public function addTile(Tile $tile){ public function addTile(Tile $tile){
if($tile->isClosed()){ if($tile->isClosed()){
throw new \InvalidArgumentException("Attempted to add a garbage closed Tile to Level"); throw new \InvalidArgumentException("Attempted to add a garbage closed Tile to world");
} }
if($tile->getLevel() !== $this){ if($tile->getLevel() !== $this){
throw new LevelException("Invalid Tile level"); throw new LevelException("Invalid Tile world");
} }
$chunkX = $tile->getFloorX() >> 4; $chunkX = $tile->getFloorX() >> 4;
@ -2765,7 +2765,7 @@ class Level implements ChunkManager, Metadatable{
*/ */
public function removeTile(Tile $tile){ public function removeTile(Tile $tile){
if($tile->getLevel() !== $this){ if($tile->getLevel() !== $this){
throw new LevelException("Invalid Tile level"); throw new LevelException("Invalid Tile world");
} }
unset($this->tiles[$tile->getId()], $this->updateTiles[$tile->getId()]); unset($this->tiles[$tile->getId()], $this->updateTiles[$tile->getId()]);

View File

@ -64,7 +64,7 @@ class Position extends Vector3{
*/ */
public function getLevel(){ public function getLevel(){
if($this->level !== null and $this->level->isClosed()){ if($this->level !== null and $this->level->isClosed()){
MainLogger::getLogger()->debug("Position was holding a reference to an unloaded Level"); MainLogger::getLogger()->debug("Position was holding a reference to an unloaded world");
$this->level = null; $this->level = null;
} }
@ -82,7 +82,7 @@ class Position extends Vector3{
*/ */
public function setLevel(Level $level = null){ public function setLevel(Level $level = null){
if($level !== null and $level->isClosed()){ if($level !== null and $level->isClosed()){
throw new \InvalidArgumentException("Specified level has been unloaded and cannot be used"); throw new \InvalidArgumentException("Specified world has been unloaded and cannot be used");
} }
$this->level = $level; $this->level = $level;

View File

@ -74,10 +74,10 @@ class ChunkRequestTask extends AsyncTask{
$batch->isEncoded = true; $batch->isEncoded = true;
$level->chunkRequestCallback($this->chunkX, $this->chunkZ, $batch); $level->chunkRequestCallback($this->chunkX, $this->chunkZ, $batch);
}else{ }else{
$server->getLogger()->error("Chunk request for level #" . $this->levelId . ", x=" . $this->chunkX . ", z=" . $this->chunkZ . " doesn't have any result data"); $server->getLogger()->error("Chunk request for world #" . $this->levelId . ", x=" . $this->chunkX . ", z=" . $this->chunkZ . " doesn't have any result data");
} }
}else{ }else{
$server->getLogger()->debug("Dropped chunk task due to level not loaded"); $server->getLogger()->debug("Dropped chunk task due to world not loaded");
} }
} }
} }