public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { switch ($cmd->getName()) { case "back": if ($this->deathpos === null) { $sender->sendMessage(TextFormat::RED . mc::_("/back command was disabled")); return true; } if (!MPMU::inGame($sender)) { return true; } $n = strtolower($sender->getName()); if (!isset($this->deathpos[$n])) { $sender->sendMessage(TextFormat::RED . mc::_("You need to die first")); return true; } $sender->sendMessage(TextFormat::GREEN . mc::_("Teleporting you back to death location!")); $sender->teleport($this->deathpos[$n]); unset($this->deathpos[$n]); return true; } return false; }
/** * Check's if $sender is a player in game * * @param CommandSender $sender * @param bool $msg If false, no message is shown * @return bool */ public static function inGame(CommandSender $sender, $msg = true) { if (!$sender instanceof Player) { if ($msg) { $sender->sendMessage(mc::_("You can only do this in-game")); } return false; } return true; }