/** * @param CommandSender $sender * @param string $commandLabel * @param string[] $args * * @return mixed */ public function execute(CommandSender $sender, $commandLabel, array $args) { if ($sender->hasPermission(SimpleWarpPermissions::OPEN_WARP_COMMAND)) { if (isset($args[0])) { if (isset($this->api->getWarpManager()[$args[0]])) { /** @var Warp $warp */ $warp = $this->api->getWarpManager()[$args[0]]; $ev = new WarpOpenEvent($sender, $warp); $this->getPlugin()->getServer()->getPluginManager()->callEvent($ev); if (!$ev->isCancelled()) { $warp->setPublic(true); $this->api->getWarpManager()[$args[0]] = $warp; $sender->sendMessage($this->api->executeTranslationItem("opened-warp-1", $args[0])); $sender->sendMessage($this->api->executeTranslationItem("opened-warp-2")); } else { $sender->sendMessage($this->api->executeTranslationItem("openwarp-event-cancelled")); } } else { $sender->sendMessage($this->api->executeTranslationItem("warp-doesnt-exist", $args[0])); } } else { $sender->sendMessage($this->getUsage()); Version::sendVersionMessage($sender); } } else { $sender->sendMessage($this->api->executeTranslationItem("openwarp-noperm")); } }
/** * @param CommandSender $sender * @param string $commandLabel * @param string[] $args * * @return mixed */ public function execute(CommandSender $sender, $commandLabel, array $args) { if ($sender->hasPermission(SimpleWarpPermissions::WARP_COMMAND)) { if (isset($args[0])) { if (isset($this->api->getWarpManager()[$args[0]])) { if (isset($args[1])) { if ($sender->hasPermission(SimpleWarpPermissions::WARP_OTHER_COMMAND)) { if (($player = $this->api->getSimpleWarp()->getServer()->getPlayer($args[1])) instanceof Player) { /** @var Warp $warp */ $warp = $this->api->getWarpManager()[$args[0]]; if ($warp->canUse($sender)) { $this->displaySmoke($player); $player->sendPopup($this->api->executeTranslationItem("warping-popup", $args[0])); $warp->teleport($player); $sender->sendMessage($this->api->executeTranslationItem("other-player-warped", $player->getName(), $args[0])); } else { $sender->sendMessage($this->api->executeTranslationItem("no-permission-warp")); } } else { $sender->sendMessage($this->api->executeTranslationItem("player-not-loaded")); } } else { $sender->sendMessage($this->api->executeTranslationItem("no-permission-warp-other")); } } elseif ($sender instanceof Player) { /** @var Warp $warp */ $warp = $this->api->getWarpManager()[$args[0]]; if ($warp->canUse($sender)) { $this->displaySmoke($sender); $sender->sendPopup($this->api->executeTranslationItem("warping-popup", $args[0])); $warp->teleport($sender); $sender->sendMessage($this->api->executeTranslationItem("warp-done")); } else { $sender->sendMessage($this->api->executeTranslationItem("no-permission-warp")); } } else { $sender->sendMessage($this->getUsage()); } } else { $sender->sendMessage($this->api->executeTranslationItem("warp-doesnt-exist")); } } else { $sender->sendMessage($this->getUsage()); Version::sendVersionMessage($sender); } } else { $sender->sendMessage($this->api->executeTranslationItem("warp-noperm")); } }
public function execute(CommandSender $sender, $commandLabel, array $args) { if (isset($args[0])) { $ess = $this->getPlugin()->getServer()->getPluginManager()->getPlugin("EssentialsPE"); if (isset($this->api->getWarpManager()[$args[0]])) { parent::execute($sender, $commandLabel, $args); if ($ess instanceof Loader && $ess->warpExists($args[0]) && $sender->hasPermission("simplewarp.essentials.notice")) { $sender->sendMessage($this->api->executeTranslationItem("ess-warp-conflict", $args[0])); } } elseif ($ess instanceof Loader && ($name = $this->getEssWarpName($ess, $args[0])) !== null) { $args[0] = $name; $this->getEssCommand()->execute($sender, $commandLabel, $args); } else { $sender->sendMessage($this->api->executeTranslationItem("ess-warp-doesnt-exist")); } } else { $sender->sendMessage($this->getUsage()); Version::sendVersionMessage($sender); } }
/** * @param CommandSender $sender * @param string $commandLabel * @param string[] $args * * @return mixed */ public function execute(CommandSender $sender, $commandLabel, array $args) { if ($sender->hasPermission(SimpleWarpPermissions::DEL_WARP_COMMAND)) { if (isset($args[0])) { if (isset($this->api->getWarpManager()[$args[0]])) { $ev = new WarpDeleteEvent($sender, $this->api->getWarpManager()[$args[0]]); $this->getPlugin()->getServer()->getPluginManager()->callEvent($ev); if (!$ev->isCancelled()) { unset($this->api->getWarpManager()[$args[0]]); $sender->sendMessage($this->api->executeTranslationItem("warp-deleted", $args[0])); } else { $sender->sendMessage($this->api->executeTranslationItem("delwarp-event-cancelled")); } } else { $sender->sendMessage($this->api->executeTranslationItem("warp-doesnt-exist", $args[0])); } } else { $sender->sendMessage($this->getUsage()); Version::sendVersionMessage($sender); } } else { $sender->sendMessage($this->api->executeTranslationItem("delwarp-noperm")); } }
/** * @param CommandSender $sender * @param string $commandLabel * @param string[] $args * * @return mixed */ public function execute(CommandSender $sender, $commandLabel, array $args) { if ($sender->hasPermission(SimpleWarpPermissions::ADD_WARP_COMMAND)) { if (isset($args[0])) { if (!isset($this->api->getWarpManager()[$args[0]])) { if (substr($args[0], 0, 4) === "ess:" && $this->api->getConfigItem("essentials-support") && $sender->hasPermission("simplewarp.essentials.notice")) { $sender->sendMessage($this->api->executeTranslationItem("addwarp-ess-prefix-warning")); } if (isset($args[4])) { $level = $this->api->getSimpleWarp()->getServer()->getLevelByName($args[4]); if ($level instanceof Level) { $dest = new Destination(new WeakPosition($args[1], $args[2], $args[3], $args[4])); $warp = new Warp($args[0], $dest); $ev = new WarpAddEvent($sender, $warp); $this->getPlugin()->getServer()->getPluginManager()->callEvent($ev); if (!$ev->isCancelled()) { $this->api->getWarpManager()[$args[0]] = $warp; $sender->sendMessage($this->api->executeTranslationItem("warp-added-xyz", $args[0], $dest->toString())); } else { $sender->sendMessage($this->api->executeTranslationItem("addwarp-event-cancelled")); } } else { $sender->sendMessage($this->api->executeTranslationItem("level-not-loaded")); } } elseif (isset($args[2])) { $dest = new Destination($args[1], $args[2]); $warp = new Warp($args[0], $dest); $ev = new WarpAddEvent($sender, $warp); $this->getPlugin()->getServer()->getPluginManager()->callEvent($ev); if (!$ev->isCancelled()) { $this->api->getWarpManager()[$args[0]] = $warp; $sender->sendMessage($this->api->executeTranslationItem("warp-added-server", $args[0], $dest->toString())); if (!$this->api->isFastTransferLoaded()) { $sender->sendMessage($this->api->executeTranslationItem("needs-fast-transfer")); } } else { $sender->sendMessage($this->api->executeTranslationItem("addwarp-event-cancelled")); } } elseif (isset($args[1])) { if (($player = $this->api->getSimpleWarp()->getServer()->getPlayer($args[1])) instanceof Player) { $dest = new Destination(new Position($player->getX(), $player->getY(), $player->getZ(), $player->getLevel())); $warp = new Warp($args[0], $dest); $ev = new WarpAddEvent($sender, $warp); $this->getPlugin()->getServer()->getPluginManager()->callEvent($ev); if (!$ev->isCancelled()) { $this->api->getWarpManager()[$args[0]] = $warp; $sender->sendMessage($this->api->executeTranslationItem("warp-added-player", $args[0], $dest->toString())); } else { $sender->sendMessage($this->api->executeTranslationItem("addwarp-event-cancelled")); } } else { $sender->sendMessage($this->api->executeTranslationItem("player-not-loaded")); } } else { if ($sender instanceof Player) { $dest = new Destination(new Position($sender->getX(), $sender->getY(), $sender->getZ(), $sender->getLevel())); $warp = new Warp($args[0], $dest); $ev = new WarpAddEvent($sender, $warp); $this->getPlugin()->getServer()->getPluginManager()->callEvent($ev); if (!$ev->isCancelled()) { $this->api->getWarpManager()[$args[0]] = $warp; $sender->sendMessage($this->api->executeTranslationItem("warp-added-self", $args[0], $dest->toString())); } else { $sender->sendMessage($this->api->executeTranslationItem("addwarp-event-cancelled")); } } else { $sender->sendMessage($this->getUsage()); } } } else { $sender->sendMessage($this->api->executeTranslationItem("bad-warp-name")); } } else { $sender->sendMessage($this->getUsage()); Version::sendVersionMessage($sender); } } else { $sender->sendMessage($this->api->executeTranslationItem("addwarp-no-perm")); } }