Deprecated Level->getSpawn() in favor of Level->getSpawnLocation()

This commit is contained in:
Shoghi Cervantes 2014-10-10 11:43:54 +02:00
parent 9ede8177df
commit 8b585fd9f7
4 changed files with 12 additions and 11 deletions

View File

@ -1378,9 +1378,9 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
if(($level = $this->server->getLevelByName($nbt["Level"])) === null){ if(($level = $this->server->getLevelByName($nbt["Level"])) === null){
$this->setLevel($this->server->getDefaultLevel(), true); $this->setLevel($this->server->getDefaultLevel(), true);
$nbt["Level"] = $this->getLevel()->getName(); $nbt["Level"] = $this->getLevel()->getName();
$nbt["Pos"][0] = $this->getLevel()->getSpawn()->x; $nbt["Pos"][0] = $this->getLevel()->getSpawnLocation()->x;
$nbt["Pos"][1] = $this->getLevel()->getSpawn()->y; $nbt["Pos"][1] = $this->getLevel()->getSpawnLocation()->y;
$nbt["Pos"][2] = $this->getLevel()->getSpawn()->z; $nbt["Pos"][2] = $this->getLevel()->getSpawnLocation()->z;
}else{ }else{
$this->setLevel($level, true); $this->setLevel($level, true);
} }

View File

@ -1114,8 +1114,8 @@ class Server{
$radiusSquared = ($this->getViewDistance() + 1) / M_PI; $radiusSquared = ($this->getViewDistance() + 1) / M_PI;
$radius = ceil(sqrt($radiusSquared)); $radius = ceil(sqrt($radiusSquared));
$centerX = $level->getSpawn()->getX() >> 4; $centerX = $level->getSpawnLocation()->getX() >> 4;
$centerZ = $level->getSpawn()->getZ() >> 4; $centerZ = $level->getSpawnLocation()->getZ() >> 4;
$order = []; $order = [];

View File

@ -66,7 +66,7 @@ class SpawnpointCommand extends VanillaCommand{
if(count($args) === 4){ if(count($args) === 4){
if($level !== null){ if($level !== null){
$pos = $sender instanceof Player ? $sender->getPosition() : $level->getSpawn(); $pos = $sender instanceof Player ? $sender->getPosition() : $level->getSpawnLocation();
$x = (int) $this->getRelativeDouble($pos->x, $sender, $args[1]); $x = (int) $this->getRelativeDouble($pos->x, $sender, $args[1]);
$y = $this->getRelativeDouble($pos->y, $sender, $args[2], 0, 128); $y = $this->getRelativeDouble($pos->y, $sender, $args[2], 0, 128);
$z = $this->getRelativeDouble($pos->z, $sender, $args[3]); $z = $this->getRelativeDouble($pos->z, $sender, $args[3]);

View File

@ -1025,7 +1025,7 @@ class Level implements ChunkManager, Metadatable{
} }
if(!$player->isOp() and ($distance = $this->server->getConfigInt("spawn-protection", 16)) > -1){ if(!$player->isOp() and ($distance = $this->server->getConfigInt("spawn-protection", 16)) > -1){
$t = new Vector2($target->x, $target->z); $t = new Vector2($target->x, $target->z);
$s = new Vector2($this->getSpawn()->x, $this->getSpawn()->z); $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
if($t->distance($s) <= $distance){ //set it to cancelled so plugins can bypass this if($t->distance($s) <= $distance){ //set it to cancelled so plugins can bypass this
$ev->setCancelled(); $ev->setCancelled();
} }
@ -1115,7 +1115,7 @@ class Level implements ChunkManager, Metadatable{
$ev = new PlayerInteractEvent($player, $item, $target, $face); $ev = new PlayerInteractEvent($player, $item, $target, $face);
if(!$player->isOp() and ($distance = $this->server->getConfigInt("spawn-protection", 16)) > -1){ if(!$player->isOp() and ($distance = $this->server->getConfigInt("spawn-protection", 16)) > -1){
$t = new Vector2($target->x, $target->z); $t = new Vector2($target->x, $target->z);
$s = new Vector2($this->getSpawn()->x, $this->getSpawn()->z); $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
if($t->distance($s) <= $distance){ //set it to cancelled so plugins can bypass this if($t->distance($s) <= $distance){ //set it to cancelled so plugins can bypass this
$ev->setCancelled(); $ev->setCancelled();
} }
@ -1180,7 +1180,7 @@ class Level implements ChunkManager, Metadatable{
$ev = new BlockPlaceEvent($player, $hand, $block, $target, $item); $ev = new BlockPlaceEvent($player, $hand, $block, $target, $item);
if(!$player->isOp() and ($distance = $this->server->getConfigInt("spawn-protection", 16)) > -1){ if(!$player->isOp() and ($distance = $this->server->getConfigInt("spawn-protection", 16)) > -1){
$t = new Vector2($target->x, $target->z); $t = new Vector2($target->x, $target->z);
$s = new Vector2($this->getSpawn()->x, $this->getSpawn()->z); $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
if($t->distance($s) <= $distance){ //set it to cancelled so plugins can bypass this if($t->distance($s) <= $distance){ //set it to cancelled so plugins can bypass this
$ev->setCancelled(); $ev->setCancelled();
} }
@ -1868,10 +1868,11 @@ class Level implements ChunkManager, Metadatable{
/** /**
* Returns the raw spawnpoint * Returns the raw spawnpoint
* *
* @deprecated
* @return Position * @return Position
*/ */
public function getSpawn(){ public function getSpawn(){
return Position::fromObject($this->provider->getSpawn(), $this); return $this->getSpawnLocation();
} }
/** /**
@ -1881,7 +1882,7 @@ class Level implements ChunkManager, Metadatable{
*/ */
public function getSafeSpawn($spawn = null){ public function getSafeSpawn($spawn = null){
if(!($spawn instanceof Vector3)){ if(!($spawn instanceof Vector3)){
$spawn = $this->getSpawn(); $spawn = $this->getSpawnLocation();
} }
if($spawn instanceof Vector3){ if($spawn instanceof Vector3){
$x = Math::floorFloat($spawn->x); $x = Math::floorFloat($spawn->x);