getServer() public méthode

public getServer ( ) : Server
Résultat pocketmine\Server
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (strtolower($cmd->getName('cratekey'))) {
         if (count($args) == 0) {
             $sender->sendMessage(TextFormat::RED . "/cratekey <give/giveall>");
         }
         if (count($args) == 1) {
             if ($args[0] == "giveall") {
                 if ($sender->hasPermission("mysterycrates.command.cratekey.giveall")) {
                     $this->plugin->giveCratekeyAll();
                     $sender->sendMessage(TextFormat::GOLD . "You have given a cratekey to everyone on the server!");
                     $sender->getServer()->broadcastMessage(TextFormat::BOLD . TextFormat::BLUE . "[MysteryCrates]" . TextFormat::GREEN . TextFormat::RESET . " Everyone has been given a cratekey by " . TextFormat::GOLD . $sender->getName() . "! ");
                 }
             }
         }
         if (count($args) == 2) {
             if ($args[0] == "give") {
                 if ($sender->hasPermission("mysterycrates.command.cratekey.give")) {
                     $player = $sender->getServer()->getPlayer($args[1]);
                     if ($player instanceof Player) {
                         $player->sendMessage(TextFormat::GREEN . "You have been given a cratekey by " . TextFormat::GOLD . $sender->getName());
                         $sender->sendMessage(TextFormat::GOLD . "Given a cratekey to " . TextFormat::GOLD . $player->getName());
                         $this->plugin->giveCratekey($player);
                     } else {
                         $sender->sendMessage(TextFormat::RED . "That player cannot be found");
                     }
                 }
             }
         }
     }
 }
 private function processIPBan($ip, CommandSender $sender, $reason)
 {
     $sender->getServer()->getIPBans()->addBan($ip, $reason, null, $sender->getName());
     foreach ($sender->getServer()->getOnlinePlayers() as $player) {
         if ($player->getAddress() === $ip) {
             $player->kick("You have been IP banned.");
         }
     }
     Command::broadcastCommandMessage($sender, "Banned IP Address " . $ip);
 }
 private function processIPBan($ip, CommandSender $sender, $reason)
 {
     $sender->getServer()->getIPBans()->addBan($ip, $reason, \null, $sender->getName());
     foreach ($sender->getServer()->getOnlinePlayers() as $player) {
         if ($player->getAddress() === $ip) {
             $player->kick($reason !== "" ? $reason : "IP banned.");
         }
     }
     $sender->getServer()->getNetwork()->blockAddress($ip, -1);
 }
 public function execute(CommandSender $sender, $commandLabel, array $args)
 {
     $dist = 0;
     if (count($args) === 0) {
         $sender->sendMessage("Usage: /dtp [from] <to>[-<distance behind <to>>]");
         return;
     } elseif (count($args) === 1) {
         if (!($from = $sender) instanceof Player) {
             $sender->sendMessage("Please run this command in-game.");
             return;
         }
         $toName = $args[0];
         $pos = strpos($toName, "-");
         if ($pos !== false) {
             $dist = (int) substr($toName, $pos + 1);
             $toName = substr($toName, 0, $pos);
         }
         $to = $sender->getServer()->getPlayer($toName);
         if (!$to instanceof Player) {
             $sender->sendMessage("{$toName} isn't online!");
             return;
         }
     } else {
         $from = $sender->getServer()->getPlayer($args[0]);
         if (!$from instanceof Player) {
             $sender->sendMessage("{$args['0']} isn't online!");
             return;
         }
         $toName = $args[1];
         $pos = strpos($toName, "-");
         if ($pos !== false) {
             $dist = (int) substr($toName, $pos + 1);
             $toName = substr($toName, 0, $pos);
         }
         $to = $sender->getServer()->getPlayer($toName);
         if (!$to instanceof Player) {
             $sender->sendMessage("{$toName} isn't online!");
             return;
         }
     }
     $l = $to->getLevel();
     $v3 = $to->subtract($to->getDirectionVector()->multiply($dist))->floor();
     for ($i = $v3->y; $i < 128; $v3->y = ++$i) {
         $b = $l->getBlock($v3);
         $id = $b->getId();
         if ($id === 0 or 8 <= $id and $id <= 11) {
             break;
         }
     }
     $from->teleport(Position::fromObject($v3, $l));
     $from->sendMessage("Teleported to {$to->getName()}");
 }
 public function execute(CommandSender $sender, array $args)
 {
     if (!empty($args)) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notinplot"));
         return true;
     }
     if ($plot->owner !== $sender->getName() and !$sender->hasPermission("myplot.admin.reset")) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
         return true;
     }
     $economy = $this->getPlugin()->getEconomyProvider();
     $price = $this->getPlugin()->getLevelSettings($plot->levelName)->resetPrice;
     if ($economy !== null and !$economy->reduceMoney($player, $price)) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("reset.nomoney"));
         return true;
     }
     if ($this->getPlugin()->resetPlot($plot)) {
         $sender->sendMessage($this->translateString("reset.success"));
     } else {
         $sender->sendMessage(TextFormat::RED . $this->translateString("error"));
     }
     return true;
 }
 public function execute(CommandSender $sender, array $args)
 {
     if (!empty($args)) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . "You are not standing on an island");
         return true;
     }
     if ($plot->owner !== $sender->getName() and !$sender->hasPermission("skyblock.admin.clear")) {
         $sender->sendMessage(TextFormat::RED . "You are not the owner of this island");
         return true;
     }
     $economy = $this->getPlugin()->getEconomyProvider();
     $price = $this->getPlugin()->getLevelSettings($plot->levelName)->clearPrice;
     if ($economy !== null and !$economy->reduceMoney($player, $price)) {
         $sender->sendMessage(TextFormat::RED . "You don't have enough money to clear this island");
         return true;
     }
     if ($this->getPlugin()->clearPlot($plot, $player)) {
         $sender->sendMessage("Island is being cleared...");
     } else {
         $sender->sendMessage(TextFormat::RED . "Could not clear this island");
     }
     return true;
 }
Exemple #7
0
 public function execute(CommandSender $sender, array $args)
 {
     if (!empty($args)) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $levelName = $player->getLevel()->getName();
     $plots = $this->getPlugin()->getProvider()->getPlotsByOwner($sender->getName());
     if (empty($plots)) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("homes.noplots"));
         return true;
     }
     $sender->sendMessage(TextFormat::DARK_GREEN . $this->translateString("homes.header"));
     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;
     });
     for ($i = 0; $i < count($plots); $i++) {
         $plot = $plots[$i];
         $message = TextFormat::DARK_GREEN . ($i + 1) . ") ";
         $message .= TextFormat::WHITE . $levelName . " " . $plot;
         if ($plot->name !== "") {
             $message .= " = " . $plot->name;
         }
         $sender->sendMessage($message);
     }
     return true;
 }
 public function execute(CommandSender $sender, array $args)
 {
     if (count($args) !== 1) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $biome = strtoupper($args[0]);
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . "You are not standing on an island");
         return true;
     }
     if ($plot->owner !== $sender->getName()) {
         $sender->sendMessage(TextFormat::RED . "You are not the owner of this island");
         return true;
     }
     if (!isset($this->biomes[$biome])) {
         $sender->sendMessage(TextFormat::RED . "That biome doesn't exist");
         $biomes = implode(", ", array_keys($this->biomes));
         $sender->sendMessage(TextFormat::RED . "The possible biomes are: {$biomes}");
         return true;
     }
     $biome = Biome::getBiome($this->biomes[$biome]);
     if ($this->getPlugin()->setPlotBiome($plot, $biome)) {
         $sender->sendMessage(TextFormat::GREEN . "Changed the island biome");
     } else {
         $sender->sendMessage(TextFormat::RED . "Could not change the island biome");
     }
     return true;
 }
Exemple #9
0
 public function execute(CommandSender $sender, array $args)
 {
     if (count($args) != 1) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $levelName = $player->getLevel()->getName();
     if (!$this->getPlugin()->isLevelLoaded($levelName)) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("warp.notinplotworld"));
         return true;
     }
     $plotIdArray = explode(";", $args[0]);
     if (count($plotIdArray) != 2 or !is_numeric($plotIdArray[0]) or !is_numeric($plotIdArray[1])) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("warp.wrongid"));
         return true;
     }
     $plot = $this->getPlugin()->getProvider()->getPlot($levelName, $plotIdArray[0], $plotIdArray[1]);
     if ($plot->owner == "" and !$sender->hasPermission("myplot.admin.warp")) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("warp.unclaimed"));
         return true;
     }
     $this->getPlugin()->teleportPlayerToPlot($player, $plot);
     $plot = TextFormat::GREEN . $plot . TextFormat::WHITE;
     $sender->sendMessage($this->translateString("warp.success", [$plot]));
     return true;
 }
Exemple #10
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;
 }
 public function execute(CommandSender $sender, array $args)
 {
     if (!empty($args)) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $levelName = $player->getLevel()->getName();
     if (!$this->getPlugin()->isLevelLoaded($levelName)) {
         $sender->sendMessage(TextFormat::RED . "You are not inside a plot world");
         return true;
     }
     $sender->sendMessage(TextFormat::RED . "Finding a free plot for you");
     if ($this->getPlugin()->getProvider() instanceof \MyPlot\provider\MYSQLDataProvider) {
         $plot = $this->getPlugin()->getPlotByPosition($sender->getPosition());
         $plot = $this->getPlugin()->getProvider()->getNextFreePlot($levelName, 20, $plot->X, $plot->Z);
     } else {
         $plot = $this->getPlugin()->getProvider()->getNextFreePlot($levelName);
     }
     if ($plot !== null) {
         $this->getPlugin()->teleportPlayerToPlot($player, $plot);
         $sender->sendMessage(TextFormat::GREEN . "Teleported to " . TextFormat::WHITE . $plot);
         $sender->sendMessage(TextFormat::GREEN . "If you dont like this plot use the /p auto command again to find another.");
     } else {
         $sender->sendMessage(TextFormat::RED . "No free plots found in this world");
     }
     return true;
 }
Exemple #12
0
 public function execute(CommandSender $sender, array $args)
 {
     $confirm = (count($args) == 1 and $args[0] == $this->translateString("confirm"));
     if (count($args) != 0 and !$confirm) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notinplot"));
         return true;
     }
     if ($plot->owner !== $sender->getName() and !$sender->hasPermission("myplot.admin.reset")) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
         return true;
     }
     if ($confirm) {
         $economy = $this->getPlugin()->getEconomyProvider();
         $price = $this->getPlugin()->getLevelSettings($plot->levelName)->resetPrice;
         if ($economy !== null and !$economy->reduceMoney($player, $price)) {
             $sender->sendMessage(TextFormat::RED . $this->translateString("reset.nomoney"));
             return true;
         }
         $maxBlocksPerTick = $this->getPlugin()->getConfig()->get("ClearBlocksPerTick", 256);
         if ($this->getPlugin()->resetPlot($plot, $maxBlocksPerTick)) {
             $sender->sendMessage($this->translateString("reset.success"));
         } else {
             $sender->sendMessage(TextFormat::RED . $this->translateString("error"));
         }
     } else {
         $plotId = TextFormat::GREEN . $plot . TextFormat::WHITE;
         $sender->sendMessage($this->translateString("reset.confirm", [$plotId]));
     }
     return true;
 }
 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;
 }
 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 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 . $this->translateString("notinplot"));
         return true;
     }
     if ($plot->owner !== $sender->getName() and !$sender->hasPermission("myplot.admin.removehelper")) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
         return true;
     }
     if (!$plot->removeHelper($helper)) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("removehelper.notone", [$helper]));
         return true;
     }
     if ($this->getPlugin()->getProvider()->savePlot($plot)) {
         $sender->sendMessage($this->translateString("removehelper.success", [$helper]));
     } else {
         $sender->sendMessage(TextFormat::RED . $this->translateString("error"));
     }
     return true;
 }
Exemple #16
0
 public function execute(CommandSender $sender, array $args)
 {
     if (!empty($args)) {
         return false;
     }
     $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;
     }
     $economy = $this->getPlugin()->getEconomyProvider();
     $price = $this->getPlugin()->getLevelSettings($plot->levelName)->resetPrice;
     if ($economy !== null and !$economy->reduceMoney($player, $price)) {
         $sender->sendMessage(TextFormat::RED . "You don't have enough money to reset this plot");
         return true;
     }
     if ($this->getPlugin()->resetPlot($plot)) {
         $sender->sendMessage(TextFormat::GREEN . "Plot reset");
     } else {
         $sender->sendMessage(TextFormat::RED . "Could not reset this plot");
     }
     return true;
 }
Exemple #17
0
 public function execute(CommandSender $sender, array $args)
 {
     if (!empty($args)) {
         return false;
     }
     $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 ($args == "reset") {
         if ($this->getPlugin()->resetPlot($plot)) {
             $sender->sendMessage(TextFormat::GREEN . "Plot reset");
         } else {
             $sender->sendMessage(TextFormat::RED . "Could not reset this plot");
         }
     }
     if ($args == "help") {
         $sender->sendMessage(TextFormat::YELLOW . "===[MyPlot Admin]===");
         $sender->sendMessage(TextFormat::AQUA . "/p admin reset : " . TextFormat::WHITE . "Reset your plot");
         $sender->sendMessage(TextFormat::AQUA . "/p admin help : " . TextFormat::WHITE . "Pull up this help menu");
     }
     return true;
 }
 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(TextFormat::RED . "An internal error occurred while attempting to perform this command");
                 $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;
 }
Exemple #19
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if ($label === "server") {
         if (count($args) < 2 or count($args) > 3 or count($args) === 2 and !$sender instanceof Player) {
             $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$command->getUsage()]));
             return true;
         }
         /** @var Player $target */
         $target = $sender;
         if (count($args) === 3) {
             $target = $sender->getServer()->getPlayer($args[0]);
             $address = $args[1];
             $port = (int) $args[2];
         } else {
             $address = $args[0];
             $port = (int) $args[1];
         }
         if ($target === null) {
             $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.player.notFound"));
             return true;
         }
         $sender->sendMessage("[Knot] Working...\n[Knot] Done!");
         if (!$this->transferPlayer($target, $address, $port)) {
             $sender->sendMessage("[Knot] Working...\n[Knot] ERR: Unknown");
         }
         return true;
     }
     return false;
 }
Exemple #20
0
 public function execute(CommandSender $sender, array $args)
 {
     if (count($args) === 0) {
         $biomes = TextFormat::WHITE . implode(", ", array_keys($this->biomes));
         $sender->sendMessage($this->translateString("biome.possible", [$biomes]));
         return true;
     } elseif (count($args) !== 1) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $biome = strtoupper($args[0]);
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notinplot"));
         return true;
     }
     if ($plot->owner !== $sender->getName()) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
         return true;
     }
     if (!isset($this->biomes[$biome])) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("biome.invalid"));
         $biomes = implode(", ", array_keys($this->biomes));
         $sender->sendMessage(TextFormat::RED . $this->translateString("biome.possible", [$biomes]));
         return true;
     }
     $biome = Biome::getBiome($this->biomes[$biome]);
     if ($this->getPlugin()->setPlotBiome($plot, $biome)) {
         $sender->sendMessage($this->translateString("biome.success", [$biome->getName()]));
     } else {
         $sender->sendMessage(TextFormat::RED . $this->translateString("error"));
     }
     return true;
 }
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch (strtolower($command->getName())) {
         case "tban":
             if (!isset($args[1])) {
                 return false;
             }
             $name = array_shift($args);
             $time = array_shift($args);
             $dateTime = $this->getDateTime($time);
             $reason = implode(" ", $args);
             Server::getInstance()->getNameBans()->addBan($name, $reason, $dateTime, $sender->getName());
             if (($player = $sender->getServer()->getPlayerExact($name)) instanceof Player) {
                 $player->kick($reason !== "" ? "Banned by admin for " . $time . " minutes Reason: " . $reason : "", true);
             }
             $sender->sendMessage("[TBan] " . $name . "さんを" . $time . "分間Banしました。");
             return true;
             break;
         case "tban-ip":
             if (!isset($args[1])) {
                 return false;
             }
             $value = array_shift($args);
             $time = array_shift($args);
             $dateTime = $this->getDateTime($time);
             $reason = implode(" ", $args);
             $ip = $value;
             $isIp = false;
             if (!preg_match("/^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\$/", $value)) {
                 if (($player = Server::getInstance()->getPlayer($value)) instanceof Player) {
                     $ip = $player->getAddress();
                 } else {
                     $sender->sendMessage("[TBan] " . $value . "さんはサーバーに接続していません。");
                     return true;
                 }
             } else {
                 $isIp = true;
             }
             Server::getInstance()->getIPBans()->addBan($ip, $reason, $dateTime, $sender->getName());
             foreach (Server::getInstance()->getOnlinePlayers() as $player) {
                 if ($player->getAddress() === $ip) {
                     $player->kick($reason !== "" ? $reason : "IP Banned for " . $time . " minutes.", true);
                 }
             }
             Server::getInstance()->getNetwork()->blockAddress($ip, $time * 60);
             if ($isIp) {
                 $sender->sendMessage("[TBan] IPアドレス " . $value . " を" . $time . "分間IPBanしました。");
             } else {
                 $sender->sendMessage("[TBan] " . $value . "さんを" . $time . "分間IPBanしました。");
             }
             return true;
             break;
     }
     return false;
 }
Exemple #22
0
 private function sendPluginList(CommandSender $sender)
 {
     $list = "";
     foreach ($plugins = $sender->getServer()->getPluginManager()->getPlugins() as $plugin) {
         if (strlen($list) > 0) {
             $list .= TextFormat::WHITE . ", ";
         }
         $list .= $plugin->isEnabled() ? TextFormat::GREEN : TextFormat::RED;
         $list .= $plugin->getDescription()->getFullName();
     }
     $sender->sendMessage(new TranslationContainer("pocketmine.command.plugins.success", [count($plugins), $list]));
 }
 private function getPluginList(CommandSender $sender)
 {
     $list = "";
     foreach ($plugins = $sender->getServer()->getPluginManager()->getPlugins() as $plugin) {
         if (\strlen($list) > 0) {
             $list .= TextFormat::WHITE . ", ";
         }
         $list .= $plugin->isEnabled() ? TextFormat::GREEN : TextFormat::RED;
         $list .= $plugin->getDescription()->getFullName();
     }
     return "(" . \count($plugins) . "): {$list}";
 }
Exemple #24
0
 public function execute(CommandSender $sender, array $args)
 {
     $confirm = (count($args) == 2 and $args[1] == $this->translateString("confirm"));
     if (count($args) != 1 and !$confirm) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notinplot"));
         return true;
     }
     if ($plot->owner !== $sender->getName()) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
         return true;
     }
     $newOwner = $this->getPlugin()->getServer()->getPlayer($args[0]);
     if (!$newOwner instanceof Player) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("give.notonline"));
         return true;
     } elseif ($newOwner === $player) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("give.toself"));
         return true;
     }
     $maxPlotsGlobal = $this->getPlugin()->getConfig()->get("MaxPlotsPerPlayer");
     $maxPlotsInLevel = $this->getPlugin()->getLevelSettings($plot->levelName)->maxPlotsPerPlayer;
     $plotsGlobal = count($this->getPlugin()->getProvider()->getPlotsByOwner($newOwner->getName()));
     $plotsInLevel = count($this->getPlugin()->getProvider()->getPlotsByOwner($newOwner->getName(), $plot->levelName));
     if ($maxPlotsGlobal <= $plotsGlobal or $maxPlotsInLevel <= $plotsInLevel) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("give.maxedout"));
         return true;
     }
     if ($confirm) {
         $plot->owner = $newOwner->getName();
         if ($this->getPlugin()->getProvider()->savePlot($plot)) {
             $plotId = TextFormat::GREEN . $plot . TextFormat::WHITE;
             $oldOwnerName = TextFormat::GREEN . $sender->getName() . TextFormat::WHITE;
             $newOwnerName = TextFormat::GREEN . $newOwner->getName() . TextFormat::WHITE;
             $sender->sendMessage($this->translateString("give.success", [$newOwnerName]));
             $newOwner->sendMessage($this->translateString("give.received", [$oldOwnerName, $plotId]));
         } else {
             $sender->sendMessage(TextFormat::RED . $this->translateString("error"));
         }
     } else {
         $plotId = TextFormat::GREEN . $plot . TextFormat::WHITE;
         $newOwnerName = TextFormat::GREEN . $newOwner->getName() . TextFormat::WHITE;
         $sender->sendMessage($this->translateString("give.confirm", [$plotId, $newOwnerName]));
     }
     return true;
 }
Exemple #25
0
 public function execute(CommandSender $sender, array $args)
 {
     if (count($args) > 1) {
         return false;
     }
     $name = "";
     if (isset($args[0])) {
         $name = $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 != "") {
         if ($plot->owner === $sender->getName()) {
             $sender->sendMessage(TextFormat::RED . "You already own this plot");
         } else {
             $sender->sendMessage(TextFormat::RED . "This plot is already claimed by " . $plot->owner);
         }
         return true;
     }
     $plotLevel = $this->getPlugin()->getLevelSettings($plot->levelName);
     $maxPlotsInLevel = $plotLevel->maxPlotsPerPlayer;
     $maxPlots = $this->getPlugin()->getConfig()->get("MaxPlotsPerPlayer");
     $plotsOfPlayer = $this->getPlugin()->getProvider()->getPlotsByOwner($player->getName());
     if ($maxPlotsInLevel >= 0 and count($plotsOfPlayer) >= $maxPlotsInLevel) {
         $sender->sendMessage(TextFormat::RED . "You reached the limit of {$maxPlotsInLevel} plots per player in this world");
         return true;
     } elseif ($maxPlots >= 0 and count($plotsOfPlayer) >= $maxPlots) {
         $sender->sendMessage(TextFormat::RED . "You reached the limit of {$maxPlots} plots per player");
         return true;
     }
     $economy = $this->getPlugin()->getEconomyProvider();
     if ($economy !== null and !$economy->reduceMoney($player, $plotLevel->claimPrice)) {
         $sender->sendMessage(TextFormat::RED . "You don't have enough money to claim this plot");
         return true;
     }
     $plot->owner = $sender->getName();
     $plot->name = $name;
     if ($this->getPlugin()->getProvider()->savePlot($plot)) {
         $sender->sendMessage(TextFormat::GREEN . "You are now the owner of " . TextFormat::WHITE . $plot);
     } else {
         $sender->sendMessage(TextFormat::RED . "Something went wrong");
     }
     return true;
 }
 public function execute(CommandSender $sender, array $args)
 {
     if (count($args) > 1) {
         return false;
     }
     $name = "";
     if (isset($args[0])) {
         $name = $args[0];
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notinplot"));
         return true;
     }
     if ($plot->owner != "") {
         if ($plot->owner === $sender->getName()) {
             $sender->sendMessage(TextFormat::RED . $this->translateString("claim.yourplot"));
         } else {
             $sender->sendMessage(TextFormat::RED . $this->translateString("claim.alreadyclaimed", [$plot->owner]));
         }
         return true;
     }
     $plotLevel = $this->getPlugin()->getLevelSettings($plot->levelName);
     $maxPlotsInLevel = $plotLevel->maxPlotsPerPlayer;
     $maxPlots = $this->getPlugin()->getConfig()->get("MaxPlotsPerPlayer");
     $plotsOfPlayer = $this->getPlugin()->getProvider()->getPlotsByOwner($player->getName());
     if ($maxPlots >= 0 and count($plotsOfPlayer) >= $maxPlots) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("claim.maxperplayer", [$maxPlots]));
         return true;
     } elseif ($maxPlotsInLevel >= 0 and count($plotsOfPlayer) >= $maxPlotsInLevel) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("claim.maxperworld", [$maxPlotsInLevel]));
         return true;
     }
     $economy = $this->getPlugin()->getEconomyProvider();
     if ($economy !== null and !$economy->reduceMoney($player, $plotLevel->claimPrice)) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("claim.nomoney"));
         return true;
     }
     $plot->owner = $sender->getName();
     $plot->name = $name;
     if ($this->getPlugin()->getProvider()->savePlot($plot)) {
         $sender->sendMessage($this->translateString("claim.success"));
     } else {
         $sender->sendMessage(TextFormat::RED . $this->translateString("error"));
     }
     return true;
 }
 public function execute(CommandSender $sender, array $args)
 {
     $argString = strtolower(implode(" ", $args));
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     $senderIsAdmin = $sender->hasPermission("myplot.admin.clear");
     $senderIsPlotOwner = $plot->owner == $sender->getName();
     $clearCommandParm = "yes i really want to clear this";
     $adminClearCommandParm = "confirm";
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . "You are not standing inside a plot");
         return true;
     }
     if (!$senderIsPlotOwner and !$senderIsAdmin) {
         $sender->sendMessage(TextFormat::RED . "You are not the owner of this plot");
         return true;
     }
     $economy = $this->getPlugin()->getEconomyProvider();
     $price = $this->getPlugin()->getLevelSettings($plot->levelName)->clearPrice;
     if ($economy !== null and !$economy->reduceMoney($player, $price)) {
         $sender->sendMessage(TextFormat::RED . "You don't have enough money to clear this plot");
         return true;
     }
     if ($argString != $clearCommandParm and !$senderIsAdmin) {
         $msg = TextFormat::GREEN . "This command will completley ";
         $msg .= TextFormat::RED . "WIPE YOUR PLOT";
         $msg .= TextFormat::GREEN . " and surrounding road. ";
         $msg .= TextFormat::WHITE . "If you really want to do this type ";
         $msg .= TextFormat::DARK_PURPLE . "/p clear " . $clearCommandParm;
         $sender->sendMessage($msg);
         return true;
     } elseif ($argString != $adminClearCommandParm and $senderIsAdmin) {
         $msg = TextFormat::GREEN . "This command will completley ";
         $msg .= TextFormat::RED . "WIPE THE PLOT";
         $msg .= TextFormat::GREEN . " beloning to " . $plot->owner . ". ";
         $msg .= TextFormat::WHITE . "If you really want to do this type ";
         $msg .= TextFormat::DARK_PURPLE . "/p clear " . $adminClearCommandParm;
         $sender->sendMessage($msg);
         return true;
     }
     if ($this->getPlugin()->clearPlot($plot, $player)) {
         $sender->sendMessage("Plot is being cleared...");
     } else {
         $sender->sendMessage(TextFormat::RED . "Could not clear this plot");
     }
     return true;
 }
Exemple #28
0
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (count($args) < 1) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return false;
     }
     if ($sender instanceof Player) {
         $wea = (int) $args[0];
         if ($wea >= 0 and $wea <= 3) {
             if (WeatherManager::isRegistered($sender->getLevel())) {
                 $sender->getLevel()->getWeather()->setWeather($wea);
                 $sender->sendMessage(TextFormat::GREEN . "天气设置成功!");
                 return true;
             } else {
                 $sender->sendMessage(TextFormat::RED . "这个世界没有注册到天气管理器!");
                 return false;
             }
         } else {
             $sender->sendMessage(TextFormat::RED . "无效的天气!");
             return false;
         }
     }
     if (count($args) < 2) {
         $sender->sendMessage(TextFormat::RED . "缺少参数!");
         return false;
     }
     $level = $sender->getServer()->getLevelByName($args[0]);
     if (!$level instanceof Level) {
         $sender->sendMessage(TextFormat::RED . "错误的地图名!");
         return false;
     }
     $wea = (int) $args[1];
     if ($wea >= 0 and $wea <= 3) {
         if (WeatherManager::isRegistered($level)) {
             $level->getWeather()->setWeather($wea);
             $sender->sendMessage(TextFormat::GREEN . "天气设置成功!");
             return true;
         } else {
             $sender->sendMessage(TextFormat::RED . "这个世界没有注册到天气管理器!");
             return false;
         }
     } else {
         $sender->sendMessage(TextFormat::RED . "无效的天气!");
         return false;
     }
     return true;
 }
 public function execute(CommandSender $sender, array $args)
 {
     if (count($args) !== 1) {
         return false;
     }
     $levelName = $args[0];
     if ($sender->getServer()->isLevelGenerated($levelName)) {
         $sender->sendMessage(TextFormat::RED . "A world with that name already exists");
         return true;
     }
     if ($this->getPlugin()->generateLevel($levelName)) {
         $sender->sendMessage(TextFormat::GREEN . "Successfully generated a new SkyBlock world " . TextFormat::WHITE . $levelName);
     } else {
         $sender->sendMessage(TextFormat::RED . "The world could not be generated");
     }
     return true;
 }
Exemple #30
-1
 /**
  * Chat a message as a given player
  *
  * @param Player|CommandSender $sender - Entity to impersonate
  * @param str[]|str $msg - messages to send
  */
 public static function chat($sender, $msgs)
 {
     if (!is_array($msgs)) {
         $msgs = [$msg];
     }
     foreach ($msgs as $msg) {
         $sender->getServer()->getPluginManager()->callEvent($ev = new PlayerChatEvent($sender, $msg));
         if ($ev->isCancelled()) {
             continue;
         }
         if (MPMU::apiVersion("1.12.0")) {
             $s = $sender->getServer();
             $s->broadcastMessage($s->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients());
         } else {
             $sender->getServer()->broadcastMessage(sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
         }
     }
 }