sendMessage() public method

public sendMessage ( string $message )
$message string
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if ($sender instanceof Player) {
         if (count($args) == 0) {
             $sender->sendMessage(TextFormat::RED . "Not enough arguments.");
             return;
         }
         if (count($args) == 1) {
             if ($this->getServer()->getPlayer($args[0])) {
                 $location = $this->getServer()->getPlayer($args[0])->getLocation();
                 $sender->teleport($location);
                 $sender->sendMessage(TextFormat::BLUE . "[Server] You have teleported to {$args['0']}");
                 return;
             } else {
                 $sender->sendMessage(TextFormat::RED . "[Server] That player isn't online!");
                 return;
             }
         }
         if (count($args) == 2) {
             if ($this->getServer()->getPlayer($args[0]) & getLocation() && $this->getServer()->getPlayer($args[1])) {
                 $location2 = $this->getServer()->getPlayer($args[1])->getLocation();
                 $player1 = $this->getServer()->getPlayer($args[0]);
                 $player2 = $this->getServer()->getPlayer($args[1]);
                 $player1->teleport($location2);
                 $player1->sendMessage(TextFormat::BLUE . "[Server] You have teleported to {$args['1']}");
                 return;
             }
         }
     }
 }
Esempio n. 2
0
 public function execute(CommandSender $sender, array $args)
 {
     if (!$sender instanceof Player) {
         $sender->sendMessage($this->getMessage("error.in-game"));
         return true;
     }
     if (!isset($args[0])) {
         $sender->sendMessage($this->getMessage("commands.spectate.valid"));
     }
     if (!isset($this->getMain()->arenas[strtolower($args[0])])) {
         $sender->sendMessage($this->getMessage("commands.spectate.exists", ["ARENA" => $args[0]]));
         return true;
     }
     foreach ($this->getMain()->arenas as $arena) {
         if ($arena->getPlayerManager()->isPlaying($sender)) {
             $sender->sendMessage($this->getMessage("commands.spectate.in-game"));
             return true;
         }
     }
     if ($this->getMain()->arenas[strtolower($args[0])]->getPlayerManager()->isInArena($sender)) {
         $sender->sendMessage($this->getMessage("commands.spectate.already"));
         return true;
     }
     $this->getMain()->arenas[strtolower($args[0])]->getPlayerHandler()->spectatePlayer($sender);
     return true;
 }
 public function onCommand(CommandSender $sender, Command $command, $label, array $params)
 {
     switch ($command->getName()) {
         case "secure":
             $player = array_shift($params);
             $ip = implode(" ", $params);
             if (!empty($player) && !empty($ip)) {
                 $this->getConfig()->set(strtolower($player), $ip);
                 $this->getConfig()->save();
                 $sender->sendMessage("Now this account is secured!");
             } else {
                 $sender->sendMessage("Write nickname and IP!");
             }
             break;
         case "unsecure":
             $player = array_shift($params);
             if (!empty($player)) {
                 if (!empty($this->getConfig()->get(strtolower($player)))) {
                     $this->getConfig()->remove(strtolower($player));
                     $this->getConfig()->save();
                     $sender->sendMessage("Now this account is unsecured!");
                 } else {
                     $sender->sendMessage("Account not found in list of secure!");
                 }
             } else {
                 $sender->sendMessage("Write nickname!");
             }
             break;
     }
     return true;
 }
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if ($player->hasPermission("signstats.commands.stats")) {
         switch ($command->getName()) {
             case 'sethouse':
                 $this->config->player[$sender->getName()]['house']['x'] = $sender->x;
                 $this->config->player[$sender->getName()]['house']['y'] = $sender->y;
                 $this->config->player[$sender->getName()]['house']['z'] = $sender->z;
                 $sender->sendMessage(TextFormat::GREEN . '[EasyHouse] House set.');
                 break;
             case 'delhouse':
                 unset($this->config->player[$sender->getName()]['house']);
                 $sender->sendMessage(TextFormat::RED . '[EasyHouse] house Deleted');
                 break;
             case 'house':
                 if (isset($this->config->player[$sender->getName()]['house'])) {
                     $this->viellePosition[$sender->getName()] = array($sender->x, $sender->y, $sender->z);
                     $sender->teleport(new Vector3($this->config->player[$sender->getName()]['house']['x'], $this->config->player[$sender->getName()]['house']['y'], $this->config->player[$sender->getName()]['house']['z']));
                     $sender->sendMessage(TextFormat::GREEN . '[EasyHouse] Teleported.');
                 } else {
                     $sender->sendMessage(TextFormat::RED . 'House is not set.');
                 }
                 break;
         }
     } else {
         $player->sendMessage(TextFormat::RED . "[EasyHouse] You don't have permissions!");
     }
 }
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (strtolower($cmd->getName()) === "stats") {
         if (isset($args[0])) {
             $name = $args[0];
             if ($sender->hasPermission("pvp-stats.command.other")) {
                 if ($this->plugin->getData($name) !== null) {
                     if ($this->plugin->getData($name)["kills"] >= 1 and $this->plugin->getData($name)["deaths"] >= 1) {
                         $sender->sendMessage($this->plugin->translateColors(str_replace(array("@player", "@kills", "@deaths", "@kdratio"), array($name, $this->plugin->getData($name)["kills"], $this->plugin->getData($name)["deaths"], round($this->plugin->getData($name)["kills"] / $this->plugin->getData($name)["deaths"], 3)), (new Config($this->plugin->getDataFolder() . "Settings.yml"))->getAll()["other-command-format"])));
                     } else {
                         $sender->sendMessage($this->plugin->translateColors(str_replace(array("@player", "@kills", "@deaths", "@kdratio"), array($name, $this->plugin->getData($name)["kills"], $this->plugin->getData($name)["deaths"], "&r&cN&r&7/&r&cA&r"), (new Config($this->plugin->getDataFolder() . "Settings.yml"))->getAll()["other-command-format"])));
                     }
                 } else {
                     $sender->sendMessage(TextFormat::RED . "Sorry, stats for " . $name . " don't exist.");
                 }
             } else {
                 $sender->sendMessage(TextFormat::RED . "You don't have permissions to use this command.");
             }
         } else {
             if ($sender instanceof Player) {
                 if ($sender->hasPermission("pvp-stats.command.self")) {
                     if ($this->plugin->getPlayer($sender)["kills"] >= 1 and $this->plugin->getPlayer($sender)["deaths"] >= 1) {
                         $sender->sendMessage($this->plugin->translateColors(str_replace(array("@kills", "@deaths", "@kdratio"), array($this->plugin->getPlayer($sender)["kills"], $this->plugin->getPlayer($sender)["deaths"], round($this->plugin->getPlayer($sender)["kills"] / $this->plugin->getPlayer($sender)["deaths"], 3)), (new Config($this->plugin->getDataFolder() . "Settings.yml"))->getAll()["self-command-format"])));
                     } else {
                         $sender->sendMessage($this->plugin->translateColors(str_replace(array("@kills", "@deaths", "@kdratio"), array($this->plugin->getPlayer($sender)["kills"], $this->plugin->getPlayer($sender)["deaths"], "&r&cN&r&7/&r&cA&r"), (new Config($this->plugin->getDataFolder() . "Settings.yml"))->getAll()["self-command-format"])));
                     }
                 } else {
                     $sender->sendMessage(TextFormat::RED . "You don't have permissions to use this command.");
                 }
             } else {
                 $sender->sendMessage(TextFormat::RED . "Please run this command in-game!");
             }
         }
     }
 }
Esempio n. 6
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub)
 {
     $mm = "[TeleportView] ";
     if ($sender->getName() == "CONSOLE") {
         $sender->sendMessage($mm . ($this->isKorean() ? "게임내에서만 사용가능합니다." : "Please run this command in-game"));
         return true;
     }
     $yaw = $sender->getYaw();
     $pitch = $sender->getPitch();
     $yawS = -sin($yaw / 180 * M_PI);
     $yawC = cos($yaw / 180 * M_PI);
     $pitchS = -sin($pitch / 180 * M_PI);
     $pitchC = cos($pitch / 180 * M_PI);
     $x = $sender->x;
     $y = $sender->y + $sender->getEyeHeight();
     $z = $sender->z;
     $l = $sender->getLevel();
     $ps = $this->getServer()->getOnlinePlayers();
     for ($f = 0; $f < 50; ++$f) {
         $x += $yawS * $pitchC;
         $y += $pitchS;
         $z += $yawC * $pitchC;
         $b = $l->getBlock(new Position($x, $y, $z, $l));
         if ($b->isSolid()) {
             break;
         }
         if ($f >= 50) {
             $sender->sendMessage($mm . ($this->isKorean() ? "타겟 블럭이 너무 멉니다." : "TargetBlock is too far"));
             return true;
         }
     }
     $sender->teleport(new Position($x, $y, $z, $sender->getLevel()));
     return true;
 }
Esempio n. 7
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     $fcmd = strtolower($cmd->getName());
     switch ($fcmd) {
         case "mute":
             if ($sender->hasPermission("chatcensor.command.mute")) {
                 if (isset($args[0])) {
                     $args[0] = strtolower($args[0]);
                     //Check if player exists
                     if ($this->plugin->getServer()->getPlayer($args[0]) != null) {
                         $player = $args[0];
                         //Check if player is already muted
                         if ($this->plugin->mutePlayer($player)) {
                             $sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&aYou muted &b" . $player));
                         } else {
                             $sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&cPlayer " . $player . " is already muted!"));
                         }
                     } else {
                         $sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&cPlayer not found!"));
                     }
                 } else {
                     $sender->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&cUsage: /mute <player>"));
                 }
             } else {
                 $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command"));
                 break;
             }
     }
 }
 public function execute(CommandSender $sender, $commandLabel, array $args)
 {
     $commands = [];
     $result = false;
     foreach ($this->formatStrings as $formatString) {
         try {
             $commands[] = $this->buildCommand($formatString, $args);
         } catch (\Exception $e) {
             if ($e instanceof \InvalidArgumentException) {
                 $sender->sendMessage(TextFormat::RED . $e->getMessage());
             } else {
                 $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.exception"));
                 $logger = $sender->getServer()->getLogger();
                 if ($logger instanceof MainLogger) {
                     $logger->logException($e);
                 }
             }
             return false;
         }
     }
     foreach ($commands as $command) {
         $result |= Server::getInstance()->dispatchCommand($sender, $command);
     }
     return (bool) $result;
 }
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "servicemode") {
         return false;
     }
     if (count($args) == 0) {
         if ($this->mode !== false) {
             $sender->sendMessage(TextFormat::RED . mc::_("In Service Mode: %1%", $this->mode));
         } else {
             $sender->sendMessage(TextFormat::GREEN . mc::_("In Normal operating mode"));
         }
         return true;
     }
     if (in_array(strtolower(array_shift($args)), ["on", "up", "true", 1])) {
         $msg = implode(" ", $args);
         if (!$msg) {
             $msg = mc::_("Scheduled maintenance");
         }
         $this->owner->getServer()->broadcastMessage(TextFormat::RED . mc::_("ATTENTION: Entering service mode"));
         $this->owner->getServer()->broadcastMessage(TextFormat::YELLOW . " - " . $msg);
     } else {
         $msg = false;
         $this->owner->getServer()->broadcastMessage(TextFormat::GREEN . mc::_("ATTENTION: Leaving service mode"));
     }
     $this->mode = $msg;
     return true;
 }
Esempio n. 10
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if ($sender instanceof Player) {
         $name = $sender->getName();
         if (strtolower($command->getName()) == 'heal') {
             if (count($args) > 0) {
                 $player = $args[0];
                 if ($this->getServer()->getPlayer($player)) {
                     $player = $this->getServer()->getPlayer($player);
                     $player->setHealth(20);
                     $sender->sendMessage(TextFormat::BLUE . "[Server] Player " . $player->getName() . " has been healed!");
                     $player->sendMessage(TextFormat::RED . "You have been healed!");
                     return;
                 } else {
                     $sender->sendMessage(TextFormat::BLUE . "[Server] {$player} isn't online at the moment. Please try again when he returns!");
                     return;
                 }
             } else {
                 $sender->setHealth(20);
                 $sender->sendMessage(TextFormat::RED . "You have been healed!");
                 return;
             }
         }
     }
 }
Esempio n. 11
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     switch ($cmd->getName()) {
         case "banhammer":
             if ($args[0] == "edit") {
                 if ($args[1] == "type") {
                     if ($args[2] == "banip") {
                     } elseif ($args[2] == "ban") {
                     } elseif ($args[2] == "kick") {
                     } else {
                         $sender->sendMessage("Usage: /banhammer edit <type> <banip|ban|kick>");
                     }
                 }
             } elseif ($args[0] == "get") {
                 if ($sender->isOP) {
                     //I'll figure our the real way to do that later
                     //TODO Give BanHammer
                     return true;
                 } else {
                     $sender->sendMessage("[BanHammer] You do not have permission to obtain the BanHammer!");
                     return false;
                 }
             } elseif ($args[0] == "allow") {
                 //TODO Add $args[1] to a config
             } else {
                 $sender->sendMessage("Usage: /banhammer <get|edit|allow> [player]");
             }
             break;
     }
 }
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if (strtolower($command->getName()) === "buyworld") {
         if (count($args) < 1 || count($args) > 4) {
             return false;
         }
         if (EconomyAPI::getInstance()->myMoney($sender->getName()) < 10000) {
             $sender->sendMessage(TextFormat::RED . "[HyperPlot] You don't have enought money. It cost \$10000");
             return true;
         }
         $world = array_shift($args);
         if (strlen($world) < 3) {
             $sender->sendMessage(TextFormat::RED . "[HyperPlot] Small World name");
             return true;
         }
         if ($this->getServer()->isLevelGenerated($world)) {
             $sender->sendMessage(TextFormat::RED . "[HyperPlot] A world named " . $world . " already exists");
             return true;
         }
         EconomyAPI::getInstance()->reduceMoney($sender->getName(), 10000);
         $this->getServer()->broadcastMessage($sender->sendMessage(TextFormat::RED . "[HyperPlot]  Creating level " . $sender->getName() . "-" . $world . "..."));
         $generator = Generator::getGenerator("ownworld");
         $this->getServer()->generateLevel($sender->getName() . "-" . $world, null, $generator, []);
         $this->getServer()->loadLevel($sender->getName() . "-" . $world);
         return true;
     }
     return false;
 }
Esempio n. 13
0
 /**
  * @param CommandSender $sender
  * @param Command $command
  * @param string $commandAlias
  * @param array $args
  *
  * @return bool
  */
 public function onCommand(CommandSender $sender, Command $command, $commandAlias, array $args)
 {
     if (strToLower($command) === $this->plugin->getDatabase()->get("command-name")) {
         // TODO: 명령어만 친 경우
         if (!isset($args[0])) {
             $sender->sendMessage($this->plugin->getDatabase()->get("help-message"));
             return true;
         }
         switch (strToLower($args[0])) {
             //TODO: '/예제 어쩌구'
             case $this->plugin->getDatabase()->get("hello-world"):
                 $sender->sendMessage($this->plugin->getDatabase()->get("hello-world-result"));
                 break;
                 // TODO: '/예제 저쩌구'
             // TODO: '/예제 저쩌구'
             case $this->plugin->getDatabase()->get("dlrow-olleh"):
                 $sender->sendMessage($this->plugin->getDatabase()->get("dlrow-olleh-result"));
                 break;
                 // TODO: 잘못된 명령어를 입력한 경우
             // TODO: 잘못된 명령어를 입력한 경우
             default:
                 $sender->sendMessage($this->plugin->getDatabase()->get("wrong-command"));
                 break;
         }
     }
     return true;
 }
Esempio n. 14
0
 public function execute(CommandSender $sender, array $args)
 {
     if (!$sender instanceof Player) {
         $sender->sendMessage(TextFormat::YELLOW . "Please run this command in game!");
         return true;
     }
     if (!isset($args[0])) {
         $sender->sendMessage(TextFormat::RED . "Please specify a valid arena name!");
         return true;
     }
     if (!isset($this->getMain()->arenas[strtolower($args[0])])) {
         $sender->sendMessage(TextFormat::RED . "The arena " . $args[0] . " does not exist");
         return true;
     }
     $inGame = false;
     foreach ($this->getMain()->arenas as $arena) {
         if ($arena->getPlayerManager()->isPlaying($sender)) {
             $inGame = true;
             break;
         }
     }
     if ($inGame) {
         $sender->sendMessage(TextFormat::RED . "Please quit/finish this game first");
         return true;
     }
     if ($this->getMain()->arenas[strtolower($args[0])]->getPlayerManager()->isPlaying($sender)) {
         $sender->sendMessage(TextFormat::RED . "You are already playing in that arena");
         return true;
     }
     $this->getMain()->arenas[strtolower($args[0])]->getPlayerHandler()->spawnPlayer($sender);
     return true;
 }
Esempio n. 15
0
 public function onSCommand(CommandSender $c, Command $cc, $scmd, $world, array $args)
 {
     if ($scmd != "max") {
         return false;
     }
     if (count($args) == 0) {
         $count = $this->owner->getCfg($world, "max-players", null);
         if ($count == null) {
             $c->sendMessage(mc::_("[WP] Max players in %1% is un-limited", $world));
         } else {
             $c->sendMessage(mc::_("[WP] Players allowed in %1%: %2%", $world, $count));
         }
         return true;
     }
     if (count($args) != 1) {
         return false;
     }
     $count = intval($args[0]);
     if ($count <= 0) {
         $this->owner->unsetCfg($world, "max-players");
         $this->owner->getServer()->broadcastMessage(mc::_("[WP] Player limit in %1% removed", $world));
     } else {
         $this->owner->setCfg($world, "max-players", $count);
         $this->owner->getServer()->broadcastMessage(mc::_("[WP] Player limit for %1% set to %2%", $world, $count));
     }
     return true;
 }
Esempio n. 16
0
 public function exec(CommandSender $sender, array $params)
 {
     $player = array_shift($params);
     $amount = array_shift($params);
     if (trim($player) === "" or trim($amount) === "" or !is_numeric($amount)) {
         $sender->sendMessage("Usage: " . $this->getUsage());
         return true;
     }
     $server = Server::getInstance();
     $p = $server->getPlayer($player);
     if ($p instanceof Player) {
         $player = $p->getName();
     }
     if ($player === $sender->getName()) {
         $sender->sendMessage($this->getPlugin()->getMessage("pay-failed"));
         return true;
     }
     $result = $this->getPlugin()->reduceMoney($sender, $amount, false, "payment");
     if ($result !== EconomyAPI::RET_SUCCESS) {
         $sender->sendMessage($this->getPlugin()->getMessage("pay-failed", $sender));
         return true;
     }
     $result = $this->getPlugin()->addMoney($player, $amount, false, "payment");
     if ($result !== EconomyAPI::RET_SUCCESS) {
         $sender->sendMessage($this->getPlugin()->getMessage("request-cancelled", $sender));
         $this->getPlugin()->addMoney($sender, $amount, true, "payment-rollback");
         return true;
     }
     $this->getPlugin()->getServer()->getPluginManager()->callEvent(new PayMoneyEvent($this->getPlugin(), $sender->getName(), $player, $amount));
     $sender->sendMessage($this->getPlugin()->getMessage("pay-success", $sender, [$amount, $player, "%3", "%4"]));
     if ($p instanceof Player) {
         $p->sendMessage($this->getPlugin()->getMessage("money-paid", $p, [$sender->getName(), $amount, "%3", "%4"]));
     }
     return true;
 }
Esempio n. 17
0
 public function execute(CommandSender $sender, array $args)
 {
     if (count($args) !== 1) {
         return false;
     }
     $helper = $args[0];
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . "You are not standing inside a plot");
         return true;
     }
     if ($plot->owner !== $sender->getName() and !$sender->hasPermission("myplot.admin.addhelper")) {
         $sender->sendMessage(TextFormat::RED . "You are not the owner of this plot");
         return true;
     }
     if (!$plot->addHelper($helper)) {
         $sender->sendMessage($helper . " was already a helper of this plot");
         return true;
     }
     if ($this->getPlugin()->getProvider()->savePlot($plot)) {
         $sender->sendMessage(TextFormat::GREEN . $helper . " is now a helper of this plot");
     } else {
         $sender->sendMessage(TextFormat::RED . "Helper could not be added");
     }
     return true;
 }
Esempio n. 18
0
 public function execute(CommandSender $sender, array $args)
 {
     if (empty($args)) {
         $plotNumber = 1;
     } elseif (count($args) === 1 and is_numeric($args[0])) {
         $plotNumber = (int) $args[0];
     } else {
         return false;
     }
     $plots = $this->getPlugin()->getProvider()->getPlotsByOwner($sender->getName());
     if (empty($plots)) {
         $sender->sendMessage(TextFormat::RED . "You don't have any plots");
         return true;
     }
     if (!isset($plots[$plotNumber - 1])) {
         $sender->sendMessage(TextFormat::RED . "You don't have a plot with home number {$plotNumber}");
         return true;
     }
     $player = $this->getPlugin()->getServer()->getPlayer($sender->getName());
     $plot = $plots[$plotNumber - 1];
     if ($this->getPlugin()->teleportPlayerToPlot($player, $plot)) {
         $sender->sendMessage(TextFormat::GREEN . "Teleported to " . TextFormat::WHITE . $plot);
     } else {
         $sender->sendMessage(TextFormat::GREEN . "Could not teleport because plot world " . $plot->levelName . " is not loaded");
     }
     return true;
 }
Esempio n. 19
0
 public function onCommand(CommandSender $sender, Command $command, $commandAlias, array $args)
 {
     if (!$this->isEnabled() or !$sender->hasPermission("PMSocket.commands")) {
         return false;
     }
     if (!isset($args[0])) {
         $sender->sendMessage(TextFormat::GOLD . "/pmsocket password <password>");
         return true;
     }
     switch (strToLower($args[0])) {
         case "password":
             if (!isset($args[1])) {
                 $sender->sendMessage(TextFormat::GOLD . "[PMSocket] /pmsocket password <password>");
                 return true;
             }
             array_shift($args);
             $this->db["password"] = implode(" ", $args);
             $sender->sendMessage(TextFormat::GOLD . "[PMSocket] The password has been registered!");
             if ($this->resender == null) {
                 $this->registerAttachment();
             }
             break;
     }
     return true;
 }
Esempio n. 20
0
 public function execute(CommandSender $sender, array $args)
 {
     if (empty($args)) {
         $plotNumber = 1;
     } elseif (count($args) === 1 and is_numeric($args[0])) {
         $plotNumber = (int) $args[0];
     } else {
         return false;
     }
     $plots = $this->getPlugin()->getProvider()->getPlotsByOwner($sender->getName());
     if (empty($plots)) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("home.noplots"));
         return true;
     }
     if (!isset($plots[$plotNumber - 1])) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("home.notexist", [$plotNumber]));
         return true;
     }
     usort($plots, function ($plot1, $plot2) {
         /** @var $plot1 Plot */
         /** @var $plot2 Plot */
         if ($plot1->levelName == $plot2->levelName) {
             return 0;
         }
         return $plot1->levelName < $plot2->levelName ? -1 : 1;
     });
     $player = $this->getPlugin()->getServer()->getPlayer($sender->getName());
     $plot = $plots[$plotNumber - 1];
     if ($this->getPlugin()->teleportPlayerToPlot($player, $plot)) {
         $sender->sendMessage($this->translateString("home.success", [$plot]));
     } else {
         $sender->sendMessage(TextFormat::RED . $this->translateString("home.error"));
     }
     return true;
 }
Esempio n. 21
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     $cmd = strtolower($command->getName());
     if ($cmd === "helper") {
         $line1 = $this->getConfig()->get("line1");
         $line2 = $this->getConfig()->get("line2");
         $line3 = $this->getConfig()->get("line3");
         $line4 = $this->getConfig()->get("line4");
         $line5 = $this->getConfig()->get("line5");
         $line6 = $this->getConfig()->get("line6");
         $line7 = $this->getConfig()->get("line7");
         $line8 = $this->getConfig()->get("line8");
         $line9 = $this->getConfig()->get("line9");
         $line10 = $this->getConfig()->get("line10");
         $sender->sendMessage("{$line1}");
         $sender->sendMessage("{$line2}");
         $sender->sendMessage("{$line3}");
         $sender->sendMessage("{$line4}");
         $sender->sendMessage("{$line5}");
         $sender->sendMessage("{$line6}");
         $sender->sendMessage("{$line7}");
         $sender->sendMessage("{$line8}");
         $sender->sendMessage("{$line9}");
         $sender->sendMessage("{$line10}");
         return true;
     }
 }
Esempio n. 22
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if ($command->getName() === "boom") {
         if (count($args)) {
             if (!isset($args[1])) {
                 $sender->sendMessage("Usage: /boom <radius> true|false");
                 return false;
             }
             if (is_numeric($args[0])) {
                 $sender->sendMessage(TextFormat::YELLOW . "Boom!");
                 $e = new Explosion($sender, $args[0]);
                 switch ($args[1]) {
                     case "true":
                         $e->explodeA();
                         $e->explodeB();
                         break;
                     case "false":
                         $e->explodeB();
                         break;
                 }
             } else {
                 $sender->sendMessage(TextFormat::RED . "Select radius in numeric value!");
                 return;
             }
         }
     }
 }
 public function onSCommand(CommandSender $c, Command $cc, $scmd, $world, array $args)
 {
     if ($scmd != "border") {
         return false;
     }
     if (count($args) == 0) {
         $limits = $this->owner->getCfg($world, "border", null);
         if ($limits == null) {
             $c->sendMessage(mc::_("[WP] %1% has no borders", $world));
         } else {
             list($x1, $z1, $x2, $z2) = $limits;
             $c->sendMessage(mc::_("[WP] Border for %1% is (%2%,%3%)-(%4%,%5%)", $world, $x1, $z1, $x2, $z2));
         }
         return true;
     }
     if (count($args) == 1) {
         $range = intval($args[0]);
         if ($range == 0) {
             $this->owner->unsetCfg($world, "border");
             $this->owner->getServer()->broadcastMessage(mc::_("[WP] Border for %1% removed", $world));
             return true;
         }
         if (!$this->owner->getServer()->isLevelLoaded($world)) {
             if (!$this->owner->getServer()->loadLevel($world)) {
                 $c->sendMessage(mc::_("Error loading level %1%", $world));
                 return true;
             }
             $unload = true;
         } else {
             $unload = false;
         }
         $l = $this->owner->getServer()->getLevelByName($world);
         if (!$l) {
             $c->sendMessage(mc::_("Unable to find level %1%", $world));
             return true;
         }
         $pos = $l->getSpawnLocation();
         if ($unload) {
             $this->owner->getServer()->unloadLevel($l);
         }
         $args = [$pos->getX() - $range, $pos->getZ() - $range, $pos->getX() + $range, $pos->getZ() + $range];
     }
     if (count($args) == 4) {
         list($x1, $z1, $x2, $z2) = $args;
         if (!is_numeric($x1) || !is_numeric($z1) || !is_numeric($x2) || !is_numeric($z2)) {
             $c->sendMessage(mc::_("[WP] Invalid border specification"));
             return false;
         }
         if ($x1 > $x2) {
             list($x1, $x2) = [$x2, $x1];
         }
         if ($z1 > $z2) {
             list($z1, $z2) = [$z2, $z1];
         }
         $this->owner->setCfg($world, "border", [$x1, $z1, $x2, $z2]);
         $this->owner->getServer()->broadcastMessage(mc::_("[WP] Border for %1% set to (%2%,%3%)-(%4%,%5%)", $world, $x1, $z1, $x2, $z2));
         return true;
     }
     return false;
 }
Esempio n. 24
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $params)
 {
     $username = strtolower($sender->getName());
     $player = $this->getServer()->getPlayer($username);
     if (!$player instanceof Player) {
         $sender->sendMessage("Use this command in-game!");
         return true;
     }
     switch ($command->getName()) {
         case "pvppon":
             $this->getConfig()->set(strtolower($sender->getName()), true);
             $this->getConfig()->save();
             $sender->sendMessage("PvP enabled for you.\nUse '/pvppoff' for disable.");
             break;
         case "pvppoff":
             $this->getConfig()->set(strtolower($sender->getName()), false);
             $this->getConfig()->save();
             $sender->sendMessage("PvP disabled for you.\nUse '/pvppon' for enable.");
             break;
         case "pvpp":
             if ($this->getConfig()->get(strtolower($sender->getName()))) {
                 $sender->sendMessage("How PvP enabled for you.\nUse '/pvppoff' for disable.");
             } else {
                 $sender->sendMessage("How PvP disabled for you.\nUse '/pvppon' for enable.");
             }
             break;
     }
     return true;
 }
Esempio n. 25
0
 public function onSCommand(CommandSender $c, Command $cc, $scmd, $world, array $args)
 {
     if ($scmd != "gm") {
         return false;
     }
     if (count($args) == 0) {
         $gm = $this->owner->getCfg($world, "gamemode", null);
         if ($gm === null) {
             $c->sendMessage(mc::_("[WP] No gamemode for %1%", $world));
         } else {
             $c->sendMessage(mc::_("[WP] %1% Gamemode: %2%", $world, MPMU::gamemodeStr($gm)));
         }
         return true;
     }
     if (count($args) != 1) {
         return false;
     }
     $newmode = $this->owner->getServer()->getGamemodeFromString($args[0]);
     if ($newmode === -1) {
         $this->owner->unsetCfg($world, "gamemode");
         $this->owner->getServer()->broadcastMessage(mc::_("[WP] %1% gamemode removed", $world));
     } else {
         $this->owner->setCfg($world, "gamemode", $newmode);
         $this->owner->getServer()->broadcastMessage(mc::_("[WP] %1% gamemode set to %2%", $world, MPMU::gamemodeStr($newmode)));
     }
     return true;
 }
Esempio n. 26
0
 public function onCommand(CommandSender $issuer, Command $cmd, $label, array $args)
 {
     switch ($cmd->getName()) {
         case "unjail":
             if ($issuer->hasPermission("jail.command") !== true && $issuer->hasPermission("jail.command.unjail") !== true) {
                 $issuer->sendMessage($this->plugin->colourMessage("&cYou don't have permission for this!"));
                 return true;
             }
             if (!isset($args[0])) {
                 return false;
             }
             $target = $this->plugin->getServer()->getPlayer($args[0]);
             if ($target === null) {
                 $issuer->sendMessage($this->plugin->colourMessage("&cInvalid target!"));
                 return true;
             }
             if ($this->plugin->isJailed($target) !== true) {
                 $issuer->sendMessage($this->plugin->colourMessage("&cTarget is not jailed!"));
                 return true;
             }
             $this->plugin->unjail($target);
             $issuer->sendMessage($this->plugin->colourMessage("&6You unjailed &e" . $target->getName() . " &6!"));
             $target->sendMessage($this->plugin->colourMessage("&6You have been unjailed!"));
             return true;
             break;
     }
 }
Esempio n. 27
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (strtolower($cmd->getName()) === "warn") {
         if (!(isset($args[0]) and isset($args[1]))) {
             $sender->sendMessage(TF::RED . "Error: not enough args. Usage: /warn <player> < reason >");
             return true;
         } else {
             $name = $args[0];
             $player = $this->getServer()->getPlayer($name);
             $player_name = $player->getName();
             $sender_name = $sender->getName();
             $sender_display_name = $sender->getDisplayName();
             unset($args[0]);
             $reason = implode(" ", $args);
             if ($player === null) {
                 $sender->sendMessage(TF::RED . "Player " . $name . " could not be found.");
                 return true;
             } else {
                 $player->sendMessage(TF::RED . "You have been warned by " . $sender_name . " for " . $reason);
                 $sender->sendMessage(TF::GREEN . "You have warned " . $player_name . " for " . $reason);
                 $this->getServer()->broadcastMessage(TF::YELLOW . $player_name . " has been warned by " . $sender_name . " for " . $reason);
                 return true;
             }
         }
     }
 }
Esempio n. 28
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub)
 {
     $mm = "[TeleportView] ";
     if ($sender->getName() == "CONSOLE") {
         $sender->sendMessage($mm . ($this->isKorean() ? "게임내에서만 사용가능합니다." : "Please run this command in-game"));
         return true;
     }
     $yaw = $sender->getYaw();
     $ptch = $sender->getPitch();
     $yawS = -sin($yaw / 180 * M_PI);
     $yawC = cos($yaw / 180 * M_PI);
     $ptchS = -sin($ptch / 180 * M_PI);
     $ptchC = cos($ptch / 180 * M_PI);
     $x = $sender->getX();
     $y = $sender->getY() + $sender->getEyeHeight();
     $z = $sender->getZ();
     $l = $sender->getLevel();
     for ($f = 0; $f < 50; ++$f) {
         $x += $yawS * $ptchC;
         $y += $ptchS;
         $z += $yawC * $ptchC;
         $b = $l->getBlock(new Position($x, $y, $z, $l));
         if ($b->isSolid) {
             $sender->teleport(new Position($x - $yawS * $ptchC, $y - $ptchS + 0.1, $z - $yawC * $ptchC, $l));
             $f = true;
         }
     }
     if (!isset($f)) {
         $sender->sendMessage($mm . ($this->isKorean() ? "타겟 블럭이 너무 멉니다." : "TargetBlock is too far"));
     }
     return true;
 }
Esempio n. 29
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if (strtolower($command->getName()) == "nf") {
         if (!($sender->hasPermission("notify") || $sender->hasPermission("notify.command") || $sender->hasPermission("notify.command.nf"))) {
             $sender->sendMessage(TextFormat::RED . "You don't have permission to use that command!");
             return true;
         } else {
             if (!isset($args[0])) {
                 return false;
             } else {
                 if ($args[0] == "on") {
                     if ($this->enabled[0] == "on") {
                         $sender->sendMessage("NotifySounds are already enabled!");
                         return true;
                     } else {
                         $this->enabled[0] = "on";
                         $sender->sendMessage("NotifySounds enabled!");
                         return true;
                     }
                 } elseif ($args[0] == "off") {
                     if ($this->enabled[0] == "off") {
                         $sender->sendMessage("NotifySounds are already disabled!");
                         return true;
                     } else {
                         $this->enabled[0] = "off";
                         $sender->sendMessage("NotifySounds disabled");
                     }
                 } else {
                     return false;
                 }
             }
         }
     }
 }
Esempio n. 30
0
 public function execute(CommandSender $sender, array $args)
 {
     if (count($args) !== 1) {
         return false;
     }
     $helper = $args[0];
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . "You are not standing inside a plot");
         return true;
     }
     if ($plot->owner !== $sender->getName()) {
         $sender->sendMessage(TextFormat::RED . "You are not the owner of this plot");
         return true;
     }
     if (!$plot->removeHelper($helper)) {
         $sender->sendMessage($helper . " was never a helper of this plot.");
         return true;
     }
     if ($this->getPlugin()->getProvider()->savePlot($plot)) {
         $sender->sendMessage(TextFormat::GREEN . $helper . " has been removed.");
     } else {
         $sender->sendMessage(TextFormat::RED . "Could not remove that player.");
     }
     return true;
 }