当前位置: 首页>>代码示例>>PHP>>正文


PHP command\Command类代码示例

本文整理汇总了PHP中pocketmine\command\Command的典型用法代码示例。如果您正苦于以下问题:PHP Command类的具体用法?PHP Command怎么用?PHP Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Command类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch ($command->getName()) {
         case "sgw":
             if (count($args) != 2) {
                 return false;
             }
             if (!isset(self::$games[$args[0]])) {
                 $sender->sendMessage(TextFormat::RED . self::getTranslation("UNKNOWN_GAME"));
                 return true;
             }
             if ($this->getServer()->getLevelByName($args[1]) === null) {
                 $sender->sendMessage(TextFormat::RED . self::getTranslation("UNKNOWN_LEVEL"));
                 return true;
             }
             if (isset(self::$worlds[$args[1]])) {
                 $sender->sendMessage(TextFormat::RED . self::getTranslation("WORLD_ALREADY_OCCUPIED"));
                 return true;
             }
             $worlds = json_decode($this->getDataFolder() . "worlds.json", true);
             if (!isset($worlds[$args[0]])) {
                 $worlds[$args[0]] = [];
             }
             $worlds[$args[0]][$args[1]] = ["config" => self::$games[$args[0]]->getStaticPropertyValue("defaultConfigs")];
             file_put_contents($this->getDataFolder() . "worlds.json", json_encode($worlds));
             $sender->sendMessage(TextFormat::AQUA . self::getTranslation("PLEASE_RESTART_SERVER"));
     }
     return true;
 }
开发者ID:organization,项目名称:XcelNgien,代码行数:29,代码来源:XcelNgien.php

示例2: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "motd") {
         return false;
     }
     if ($sender instanceof Player) {
         $world = $sender->getLevel()->getName();
     } else {
         $level = $this->owner->getServer()->getDefaultLevel();
         if ($level) {
             $world = $level->getName();
         } else {
             $world = null;
         }
     }
     if (isset($args[0]) && $this->owner->getServer()->isLevelGenerated($args[0])) {
         $world = array_shift($args);
     }
     if ($world === null) {
         $sender->sendMessage(mc::_("[WP] Must specify a world"));
         return false;
     }
     if (count($args) != 0) {
         return false;
     }
     $this->showMotd($sender, $world);
     return true;
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:28,代码来源:WpMotdMgr.php

示例3: onCommand

 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;
                 }
             }
         }
     }
 }
开发者ID:Blubberboy333,项目名称:NotifySounds,代码行数:34,代码来源:Main.php

示例4: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "near") {
         return false;
     }
     if (!MPMU::inGame($sender)) {
         return true;
     }
     switch (count($args)) {
         case 0:
             $radius = 64 * 64;
             break;
         case 1:
             $radius = (int) $args[0] * (int) $args[0];
             break;
         default:
             return false;
     }
     $players = [];
     foreach ($sender->getLevel()->getPlayers() as $pl) {
         $dist = $pl->distanceSquared($players);
         if ($dist < $radius) {
             $players[] = $pl->getDisplayName();
         }
     }
     if (count($players) == 0) {
         $sender->sendMessage(mc::_("No near by players found!"));
     } else {
         $sender->sendMessage(mc::_("Neighbors(%1%): %2%", count($players), implode(", ", $players)));
     }
     return true;
 }
开发者ID:edwinyoo44,项目名称:pocketmine-plugins,代码行数:32,代码来源:CmdNear.php

示例5: onCommand

 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;
             }
         }
     }
 }
开发者ID:applqpak,项目名称:WarnPlayer,代码行数:26,代码来源:Main.php

示例6: onCommand

 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;
             }
     }
 }
开发者ID:sarhatabaot,项目名称:ChatCensor,代码行数:29,代码来源:Mute.php

示例7: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "players") {
         return false;
     }
     $tab = [[mc::_("Player"), mc::_("World"), mc::_("Pos"), mc::_("Health"), mc::_("Mode")]];
     $cnt = 0;
     foreach ($this->owner->getServer()->getOnlinePlayers() as $player) {
         if (!$player->isOnline() || $sender instanceof Player && !$sender->canSee($player)) {
             continue;
         }
         $pos = $player->getPosition();
         $j = count($tab);
         $mode = substr(MPMU::gamemodeStr($player->getGamemode()), 0, 4);
         $tab[] = [$player->getName(), $player->getLevel()->getName(), $pos->getFloorX() . "," . $pos->getFloorY() . "," . $pos->getFloorZ(), intval($player->getHealth()) . '/' . intval($player->getMaxHealth()), $mode];
         ++$cnt;
     }
     if (!$cnt) {
         $sender->sendMessage(TextFormat::RED . mc::_("Nobody is on-line at the moment"));
         return true;
     }
     $tab[0][0] = mc::_("Players: %1%", $cnt);
     $pageNumber = $this->getPageNumber($args);
     return $this->paginateTable($sender, $pageNumber, $tab);
 }
开发者ID:Gabriel865,项目名称:pocketmine-plugins,代码行数:25,代码来源:CmdPlayers.php

示例8: onCommand

 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;
             }
         }
     }
 }
开发者ID:0-DevMatthew-0,项目名称:RandomCommandsPlugin,代码行数:25,代码来源:heal.php

示例9: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch ($command->getName()) {
         case "consoleclients":
             if (!$sender->hasPermission("pocketdockconsole.command.consoleclients")) {
                 $sender->sendMessage(TextFormat::RED . "[PDC] Get some permissions...");
                 return true;
             }
             $authedclients = explode(";", $this->thread->connectedips);
             if (count($authedclients) < 2) {
                 $sender->sendMessage("[PDC] There are no connected clients");
                 return true;
             }
             $sender->sendMessage("[PDC] Connected client(s) are: " . implode("; ", $authedclients));
             return true;
         case "killclient":
             if (!$sender->hasPermission("pocketdockconsole.command.killclient")) {
                 $sender->sendMessage(TextFormat::RED . "[PDC] Get some permissions...");
                 return true;
             }
             if (!isset($args[0])) {
                 $sender->sendMessage($command->getUsage());
                 return true;
             }
             $sender->sendMessage("[PDC] Killing client: " . $args[0]);
             $this->thread->clienttokill = $args[0];
             return true;
         default:
             return false;
     }
 }
开发者ID:brandon15811,项目名称:PocketDockConsole,代码行数:31,代码来源:Main.php

示例10: onCommand

 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;
     }
 }
开发者ID:craftyoyo,项目名称:BanHammer,代码行数:30,代码来源:Main.php

示例11: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if (strtolower($command->getName()) === "tz") {
         $sender->sendMessage($this->colorlist[strtolower($this->getConfig()->get("color"))] . $this->getTime());
         return true;
     }
 }
开发者ID:HotFireyDeath,项目名称:PM-Plugins,代码行数:7,代码来源:TimeZones.php

示例12: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     $cmd = strtolower($command->getName());
     switch ($cmd) {
         case "social":
             if (!$sender instanceof Player) {
                 $sender->sendMessage(TEXTFORMAT::BLUE . "- " . $this->getConfig()->get("name"));
                 $sender->sendMessage(TEXTFORMAT::GOLD . "-  Our Website!");
                 $sender->sendMessage(TEXTFORMAT::GREEN . "-  Use /website");
                 $sender->sendMessage(TEXTFORMAT::GOLD . "-  Our Facebook!");
                 $sender->sendMessage(TEXTFORMAT::GREEN . "-  Use /facebook");
                 $sender->sendMessage(TEXTFORMAT::GOLD . "-  Our YouTube!");
                 $sender->sendMessage(TEXTFORMAT::GREEN . "-  Use /youtube");
                 $sender->sendMessage(TEXTFORMAT::GOLD . "-  Our GitHub!");
                 $sender->sendMessage(TEXTFORMAT::GREEN . "-  Use /github");
                 return true;
             }
             $player = $this->getServer()->getPlayer($sender->getName());
             if ($player->hasPermission("gamecraftpe.social")) {
                 $sender->sendMessage("§3 " . $this->getConfig->get("name"));
                 $sender->sendMessage("§2-  Our Website!");
                 $sender->sendMessage("§a-  Use /website");
                 $sender->sendMessage("§2-  Our Facebook!");
                 $sender->sendMessage("§a-  Use /facebook");
                 $sender->sendMessage("§2-  Our YouTube!");
                 $sender->sendMessage("§a-  Use /youtube");
                 $sender->sendMessage("§2-  Our GitHub!");
                 $sender->sendMessage("§a-  Use /github");
                 return true;
             }
             break;
     }
 }
开发者ID:xHFx,项目名称:GCPESocial,代码行数:33,代码来源:Main.php

示例13: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "entities") {
         return false;
     }
     if (count($args) == 0) {
         $args = ["ls"];
     }
     $scmd = strtolower(array_shift($args));
     switch ($scmd) {
         case "count":
             return $this->cmdCount($sender);
         case "nuke":
             return $this->cmdNuke($sender, $args);
         case "ls":
             return $this->cmdEtList($sender, $args);
         case "tiles":
         case "tile":
             return $this->cmdTileList($sender, $args);
         case "info":
         case "nbt":
             return $this->cmdEtInfo($sender, $args);
         case "rm":
             return $this->cmdEtRm($sender, $args);
         case "sign1":
         case "sign2":
         case "sign3":
         case "sign4":
             return $this->cmdEtSign($sender, $scmd, $args);
     }
     return false;
 }
开发者ID:kam187,项目名称:pocketmine-plugins,代码行数:32,代码来源:CmdEntities.php

示例14: onCommand

 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;
 }
开发者ID:Gumbrat,项目名称:Pocketmine-Plugins,代码行数:28,代码来源:HyperPlotWorld.php

示例15: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (!isset($args[0])) {
         return false;
     }
     if ($cmd->getName() == "gift") {
         if (($receiver = $this->owner->getServer()->getPlayer($args[0])) == null) {
             if (!MPMU::inGame($sender)) {
                 return true;
             }
             $receiver = $sender;
         } else {
             array_shift($args);
         }
     } else {
         if (!MPMU::inGame($sender)) {
             return true;
         }
         $receiver = $sender;
     }
     if ($receiver->isCreative()) {
         if ($receiver === $sender) {
             $receiver->sendMessage(mc::_("You are in creative mode"));
         } else {
             $sender->sendMessage(mc::_("%1% is in creative mode", $receiver->getDisplayName()));
         }
         return true;
     }
     if (count($args) > 1 && is_numeric($args[count($args) - 1])) {
         $amt = (int) array_pop($args);
     } else {
         $amt = -1;
     }
     $args = strtolower(implode("_", $args));
     if ($args == "more") {
         $item = clone $receiver->getInventory()->getItemInHand();
         if ($item->getId() == 0) {
             $sender->sendMessage(TextFormat::RED . mc::_("Must be holding something"));
             return true;
         }
     } else {
         $item = Item::fromString($args);
         if ($item->getId() == 0) {
             $sender->sendMessage(TextFormat::RED . mc::_("There is no item called %1%", $args));
             return true;
         }
     }
     if ($amt != -1) {
         $item->setCount($amt);
     } else {
         if (isset(self::$stacks[$item->getId()])) {
             $item->setCount(self::$stacks[$item->getId()]);
         } else {
             $item->setCount($item->getMaxStackSize());
         }
     }
     $receiver->getInventory()->addItem(clone $item);
     $this->owner->getServer()->broadcastMessage(mc::_("%1% got %2% of %3% (%4%:%5%)", $receiver->getDisplayName(), $item->getCount(), ItemName::str($item), $item->getId(), $item->getDamage()));
     return true;
 }
开发者ID:kam187,项目名称:pocketmine-plugins,代码行数:60,代码来源:CmdGet.php


注:本文中的pocketmine\command\Command类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。