mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 22:15:30 +00:00
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:
parent
5c12bee874
commit
562179bdd6
@ -1046,7 +1046,7 @@ class Server{
|
||||
*/
|
||||
public function unloadLevel(Level $level, bool $forceUnload = false) : bool{
|
||||
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);
|
||||
@ -1072,7 +1072,7 @@ class Server{
|
||||
*/
|
||||
public function loadLevel(string $name) : bool{
|
||||
if(trim($name) === ""){
|
||||
throw new LevelException("Invalid empty level name");
|
||||
throw new LevelException("Invalid empty world name");
|
||||
}
|
||||
if($this->isLevelLoaded($name)){
|
||||
return true;
|
||||
@ -1130,7 +1130,7 @@ class Server{
|
||||
if(($providerClass = LevelProviderManager::getProviderByName($this->getProperty("level-settings.default-format", "pmanvil"))) === null){
|
||||
$providerClass = LevelProviderManager::getProviderByName("pmanvil");
|
||||
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(){
|
||||
$this->logger->info("Saving levels...");
|
||||
$this->logger->info("Saving worlds...");
|
||||
|
||||
foreach($this->levels as $level){
|
||||
$level->save();
|
||||
@ -2097,7 +2097,7 @@ class Server{
|
||||
$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){
|
||||
$this->unloadLevel($level, true);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class Explosion{
|
||||
*/
|
||||
public function __construct(Position $center, float $size, $what = null){
|
||||
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->level = $center->getLevel();
|
||||
|
@ -474,7 +474,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
public function close(){
|
||||
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){
|
||||
@ -588,7 +588,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
*/
|
||||
public function unload(bool $force = false) : bool{
|
||||
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);
|
||||
@ -607,7 +607,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
$defaultLevel = $this->server->getDefaultLevel();
|
||||
foreach($this->getPlayers() as $player){
|
||||
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){
|
||||
$player->teleport($this->server->getDefaultLevel()->getSafeSpawn());
|
||||
}
|
||||
@ -785,7 +785,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
*/
|
||||
public function doTick(int $currentTick){
|
||||
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();
|
||||
@ -2699,10 +2699,10 @@ class Level implements ChunkManager, Metadatable{
|
||||
*/
|
||||
public function addEntity(Entity $entity){
|
||||
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){
|
||||
throw new LevelException("Invalid Entity level");
|
||||
throw new LevelException("Invalid Entity world");
|
||||
}
|
||||
|
||||
if($entity instanceof Player){
|
||||
@ -2720,7 +2720,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
*/
|
||||
public function removeEntity(Entity $entity){
|
||||
if($entity->getLevel() !== $this){
|
||||
throw new LevelException("Invalid Entity level");
|
||||
throw new LevelException("Invalid Entity world");
|
||||
}
|
||||
|
||||
if($entity instanceof Player){
|
||||
@ -2739,10 +2739,10 @@ class Level implements ChunkManager, Metadatable{
|
||||
*/
|
||||
public function addTile(Tile $tile){
|
||||
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){
|
||||
throw new LevelException("Invalid Tile level");
|
||||
throw new LevelException("Invalid Tile world");
|
||||
}
|
||||
|
||||
$chunkX = $tile->getFloorX() >> 4;
|
||||
@ -2765,7 +2765,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
*/
|
||||
public function removeTile(Tile $tile){
|
||||
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()]);
|
||||
|
@ -64,7 +64,7 @@ class Position extends Vector3{
|
||||
*/
|
||||
public function getLevel(){
|
||||
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;
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ class Position extends Vector3{
|
||||
*/
|
||||
public function setLevel(Level $level = null){
|
||||
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;
|
||||
|
@ -74,10 +74,10 @@ class ChunkRequestTask extends AsyncTask{
|
||||
$batch->isEncoded = true;
|
||||
$level->chunkRequestCallback($this->chunkX, $this->chunkZ, $batch);
|
||||
}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{
|
||||
$server->getLogger()->debug("Dropped chunk task due to level not loaded");
|
||||
$server->getLogger()->debug("Dropped chunk task due to world not loaded");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user