commands: remove some nonsensical isValid() checks

a player who doesn't have a valid world has no business sending commands anyway.
This commit is contained in:
Dylan K. Taylor 2019-08-06 15:42:01 +01:00
parent dec6f73f2f
commit 9598af7683
2 changed files with 9 additions and 13 deletions

View File

@ -70,7 +70,6 @@ class SpawnpointCommand extends VanillaCommand{
} }
if(count($args) === 4){ if(count($args) === 4){
if($target->isValid()){
$world = $target->getWorld(); $world = $target->getWorld();
$pos = $sender instanceof Player ? $sender->getPosition() : $world->getSpawnLocation(); $pos = $sender instanceof Player ? $sender->getPosition() : $world->getSpawnLocation();
$x = $this->getRelativeDouble($pos->x, $sender, $args[1]); $x = $this->getRelativeDouble($pos->x, $sender, $args[1]);
@ -81,7 +80,6 @@ class SpawnpointCommand extends VanillaCommand{
Command::broadcastCommandMessage($sender, new TranslationContainer("commands.spawnpoint.success", [$target->getName(), round($x, 2), round($y, 2), round($z, 2)])); Command::broadcastCommandMessage($sender, new TranslationContainer("commands.spawnpoint.success", [$target->getName(), round($x, 2), round($y, 2), round($z, 2)]));
return true; return true;
}
}elseif(count($args) <= 1){ }elseif(count($args) <= 1){
if($sender instanceof Player){ if($sender instanceof Player){
$pos = new Position($sender->getFloorX(), $sender->getFloorY(), $sender->getFloorZ(), $sender->getWorld()); $pos = new Position($sender->getFloorX(), $sender->getFloorY(), $sender->getFloorZ(), $sender->getWorld());

View File

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