Replaced Position->getLevel() null checks with isValid()

This commit is contained in:
Dylan K. Taylor
2018-03-20 11:10:36 +00:00
parent 73e09392b6
commit 1648fff916
7 changed files with 22 additions and 23 deletions

View File

@@ -67,10 +67,9 @@ class SpawnpointCommand extends VanillaCommand{
}
}
$level = $target->getLevel();
if(count($args) === 4){
if($level !== null){
if($target->isValid()){
$level = $target->getLevel();
$pos = $sender instanceof Player ? $sender->getPosition() : $level->getSpawnLocation();
$x = $this->getRelativeDouble($pos->x, $sender, $args[1]);
$y = $this->getRelativeDouble($pos->y, $sender, $args[2], 0, Level::Y_MAX);

View File

@@ -97,7 +97,7 @@ class TeleportCommand extends VanillaCommand{
Command::broadcastCommandMessage($sender, new TranslationContainer("commands.tp.success", [$origin->getName(), $target->getName()]));
return true;
}elseif($target->getLevel() !== null){
}elseif($target->isValid()){
if(count($args) === 4 or count($args) === 6){
$pos = 1;
}else{