mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-19 04:05:31 +00:00
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:
parent
dec6f73f2f
commit
9598af7683
@ -70,18 +70,16 @@ 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]);
|
$y = $this->getRelativeDouble($pos->y, $sender, $args[2], 0, World::Y_MAX);
|
||||||
$y = $this->getRelativeDouble($pos->y, $sender, $args[2], 0, World::Y_MAX);
|
$z = $this->getRelativeDouble($pos->z, $sender, $args[3]);
|
||||||
$z = $this->getRelativeDouble($pos->z, $sender, $args[3]);
|
$target->setSpawn(new Position($x, $y, $z, $world));
|
||||||
$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){
|
}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());
|
||||||
|
@ -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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user