public function onDeath(PlayerDeathEvent $event) { $player = $event->getEntity(); if (Main::isActive($player)) { Main::removeActive($player); } }
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { if (strtolower($cmd->getName()) === "togglepos") { if (isset($args[0])) { if ($sender->hasPermission("positionteller.command.togglepos.other")) { $name = $args[0]; $target = $this->getPlugin()->getServer()->getPlayer($name); if ($target instanceof Player) { if ($this->getPlugin()->isActive($target)) { $this->getPlugin()->removeActive($target); $sender->sendMessage(str_replace("@reciver", $target->getName(), Main::translateColors($this->getPlugin()->getConfigValue("messages.togglepos.other.succeed.de-activate.sender")))); $target->sendMessage(str_replace("@sender", $sender->getName(), Main::translateColors($this->getPlugin()->getConfigValue("messages.togglepos.other.succeed.de-activate.reciver")))); return true; } else { $this->getPlugin()->addActive($target); $sender->sendMessage(str_replace("@reciver", $target->getName(), Main::translateColors($this->getPlugin()->getConfigValue("messages.togglepos.other.succeed.activate.sender")))); $target->sendMessage(str_replace("@sender", $sender->getName(), Main::translateColors($this->getPlugin()->getConfigValue("messages.togglepos.other.succeed.activate.reciver")))); return true; } } else { $sender->sendMessage(str_replace("@reciver", $name, Main::translateColors($this->getPlugin()->getConfigValue("messages.togglepos.other.fail.default")))); return true; } } else { $sender->sendMessage(Main::translateColors($this->getPlugin()->getConfigValue("messages.togglepos.other.fail.permisson"))); return true; } } else { if ($sender instanceof Player) { if ($sender->hasPermission("positionteller.command.togglepos.self")) { if ($this->getPlugin()->isActive($sender)) { $this->getPlugin()->removeActive($sender); $sender->sendMessage(Main::translateColors($this->getPlugin()->getConfigValue("messages.togglepos.self.succeed.de-activate"))); return true; } else { $this->getPlugin()->addActive($sender); $sender->sendMessage(Main::translateColors($this->getPlugin()->getConfigValue("messages.togglepos.self.succeed.activate"))); return true; } } else { $sender->sendMessage(Main::translateColors($this->getPlugin()->getConfigValue("messages.togglepos.self.fail.permission"))); return true; } } else { $sender->sendMessage(Main::translateColors($this->getPlugin()->getConfigValue("messages.togglepos.self.fail.game"))); return true; } } } }
public function onRun($tick) { foreach ($this->getPlugin()->active as $player) { $player->sendPopup(str_replace(array("@x", "@y", "@z"), array(round($player->getX(), 1), round($player->getY(), 2), round($player->getY(), 1)), Main::translateColors($this->getPlugin()->getConfigValue("messages.showpos.format")))); } }