From 9598af76834216296659f0e9eea3a266d57f9ce8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 6 Aug 2019 15:42:01 +0100 Subject: [PATCH] commands: remove some nonsensical isValid() checks a player who doesn't have a valid world has no business sending commands anyway. --- src/command/defaults/SpawnpointCommand.php | 18 ++++++++---------- src/command/defaults/TeleportCommand.php | 4 +--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/command/defaults/SpawnpointCommand.php b/src/command/defaults/SpawnpointCommand.php index a0f87ca61..071433b3b 100644 --- a/src/command/defaults/SpawnpointCommand.php +++ b/src/command/defaults/SpawnpointCommand.php @@ -70,18 +70,16 @@ class SpawnpointCommand extends VanillaCommand{ } if(count($args) === 4){ - if($target->isValid()){ - $world = $target->getWorld(); - $pos = $sender instanceof Player ? $sender->getPosition() : $world->getSpawnLocation(); - $x = $this->getRelativeDouble($pos->x, $sender, $args[1]); - $y = $this->getRelativeDouble($pos->y, $sender, $args[2], 0, World::Y_MAX); - $z = $this->getRelativeDouble($pos->z, $sender, $args[3]); - $target->setSpawn(new Position($x, $y, $z, $world)); + $world = $target->getWorld(); + $pos = $sender instanceof Player ? $sender->getPosition() : $world->getSpawnLocation(); + $x = $this->getRelativeDouble($pos->x, $sender, $args[1]); + $y = $this->getRelativeDouble($pos->y, $sender, $args[2], 0, World::Y_MAX); + $z = $this->getRelativeDouble($pos->z, $sender, $args[3]); + $target->setSpawn(new Position($x, $y, $z, $world)); - 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){ if($sender instanceof Player){ $pos = new Position($sender->getFloorX(), $sender->getFloorY(), $sender->getFloorZ(), $sender->getWorld()); diff --git a/src/command/defaults/TeleportCommand.php b/src/command/defaults/TeleportCommand.php index 8170fbb6d..512ce095d 100644 --- a/src/command/defaults/TeleportCommand.php +++ b/src/command/defaults/TeleportCommand.php @@ -101,7 +101,7 @@ class TeleportCommand extends VanillaCommand{ Command::broadcastCommandMessage($sender, new TranslationContainer("commands.tp.success", [$origin->getName(), $target->getName()])); return true; - }elseif($target->isValid()){ + }else{ if(count($args) === 4 or count($args) === 6){ $pos = 1; }else{ @@ -124,7 +124,5 @@ class TeleportCommand extends VanillaCommand{ return true; } - - throw new InvalidCommandSyntaxException(); } }