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


PHP Command::broadcastCommandMessage方法代码示例

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


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

示例1: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (count($args) < 2) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return true;
     }
     $player = $sender->getServer()->getPlayer($args[0]);
     $item = Item::fromString($args[1]);
     if (!isset($args[2])) {
         $item->setCount($item->getMaxStackSize());
     } else {
         $item->setCount((int) $args[2]);
     }
     if ($player instanceof Player) {
         if ($item->getId() === 0) {
             $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.give.item.notFound", [$args[1]]));
             return true;
         }
         //TODO: overflow
         $player->getInventory()->addItem(clone $item);
     } else {
         $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.player.notFound"));
         return true;
     }
     Command::broadcastCommandMessage($sender, new TranslationContainer("%commands.give.success", [$item->getName() . " (" . $item->getId() . ":" . $item->getDamage() . ")", (string) $item->getCount(), $player->getName()]));
     return true;
 }
开发者ID:mattiasaxelsson,项目名称:PocketMine-MP,代码行数:30,代码来源:GiveCommand.php

示例2: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (count($args) === 0) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return false;
     }
     $name = array_shift($args);
     if (isset($args[0]) and isset($args[1])) {
         $reason = $args[0];
         if ($args[1] != null and is_numeric($args[1])) {
             $until = $args[1] * 86400 + time();
         } else {
             $until = null;
         }
         $sender->getServer()->getNameBans()->addBan($name, $reason, $until, $sender->getName());
     }
     $sender->getServer()->getNameBans()->addBan($name, $reason = implode(" ", $args), null, $sender->getName());
     if (($player = $sender->getServer()->getPlayerExact($name)) instanceof Player) {
         $player->kick($reason !== "" ? "Banned by admin. Reason: " . $reason : "Banned by admin." . "Banned Until:" . date('r'), $until = "Forever");
     }
     Command::broadcastCommandMessage($sender, new TranslationContainer("%commands.ban.success", [$player !== null ? $player->getName() : $name]));
     return true;
 }
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:26,代码来源:BanCommand.php

示例3: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (count($args) !== 1) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return false;
     }
     $difficulty = Server::getDifficultyFromString($args[0]);
     if ($sender->getServer()->isHardcore()) {
         $difficulty = 3;
     }
     if ($difficulty !== -1) {
         $sender->getServer()->setConfigInt("difficulty", $difficulty);
         $pk = new SetDifficultyPacket();
         $pk->difficulty = $sender->getServer()->getDifficulty();
         Server::broadcastPacket($sender->getServer()->getOnlinePlayers(), $pk);
         Command::broadcastCommandMessage($sender, new TranslationContainer("commands.difficulty.success", [$difficulty]));
     } else {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return false;
     }
     return true;
 }
开发者ID:NewDelion,项目名称:PocketMine-0.13.x,代码行数:25,代码来源:DifficultyCommand.php

示例4: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return \true;
     }
     if (\count($args) === 0) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return \false;
     }
     $value = \array_shift($args);
     $reason = \implode(" ", $args);
     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)) {
         $this->processIPBan($value, $sender, $reason);
         Command::broadcastCommandMessage($sender, new TranslationContainer("commands.banip.success", [$value]));
     } else {
         if (($player = $sender->getServer()->getPlayer($value)) instanceof Player) {
             $this->processIPBan($player->getAddress(), $sender, $reason);
             Command::broadcastCommandMessage($sender, new TranslationContainer("commands.banip.success.players", [$player->getAddress(), $player->getName()]));
         } else {
             $sender->sendMessage(new TranslationContainer("commands.banip.invalid"));
             return \false;
         }
     }
     return \true;
 }
开发者ID:xpyctum,项目名称:PocketMinePlusPlus,代码行数:25,代码来源:BanIpCommand.php

示例5: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return \true;
     }
     if (\count($args) < 2) {
         $sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage);
         return \false;
     }
     $player = $sender->getServer()->getPlayer($args[0]);
     $item = Item::fromString($args[1]);
     if (!isset($args[2])) {
         $item->setCount($item->getMaxStackSize());
     } else {
         $item->setCount((int) $args[2]);
     }
     if ($player instanceof Player) {
         if (($player->getGamemode() & 0x1) === 0x1) {
             $sender->sendMessage(TextFormat::RED . "Player is in creative mode");
             return \true;
         }
         if ($item->getId() == 0) {
             $sender->sendMessage(TextFormat::RED . "There is no item called " . $args[1] . ".");
             return \true;
         }
         //TODO: overflow
         $player->getInventory()->addItem(clone $item);
     } else {
         $sender->sendMessage(TextFormat::RED . "Can't find player " . $args[0]);
         return \true;
     }
     Command::broadcastCommandMessage($sender, "Gave " . $player->getName() . " " . $item->getCount() . " of " . $item->getName() . " (" . $item->getId() . ":" . $item->getDamage() . ")");
     return \true;
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:34,代码来源:GiveCommand.php

示例6: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (count($args) === 0 or count($args) > 2) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return true;
     }
     if (count($args) === 1) {
         if ($this->badPerm($sender, strtolower($args[0]))) {
             return false;
         }
         switch (strtolower($args[0])) {
             case "reload":
                 $sender->getServer()->reloadWhitelist();
                 Command::broadcastCommandMessage($sender, new TranslationContainer("commands.whitelist.reloaded"));
                 return true;
             case "on":
                 $sender->getServer()->setConfigBool("white-list", true);
                 Command::broadcastCommandMessage($sender, new TranslationContainer("commands.whitelist.enabled"));
                 return true;
             case "off":
                 $sender->getServer()->setConfigBool("white-list", false);
                 Command::broadcastCommandMessage($sender, new TranslationContainer("commands.whitelist.disabled"));
                 return true;
             case "list":
                 $result = "";
                 $count = 0;
                 foreach ($sender->getServer()->getWhitelisted()->getAll(true) as $player) {
                     $result .= $player . ", ";
                     ++$count;
                 }
                 $sender->sendMessage(new TranslationContainer("commands.whitelist.list", [$count, $count]));
                 $sender->sendMessage(substr($result, 0, -2));
                 return true;
             case "add":
                 $sender->sendMessage(new TranslationContainer("commands.generic.usage", ["%commands.whitelist.add.usage"]));
                 return true;
             case "remove":
                 $sender->sendMessage(new TranslationContainer("commands.generic.usage", ["%commands.whitelist.remove.usage"]));
                 return true;
         }
     } elseif (count($args) === 2) {
         if ($this->badPerm($sender, strtolower($args[0]))) {
             return false;
         }
         switch (strtolower($args[0])) {
             case "add":
                 $sender->getServer()->getOfflinePlayer($args[1])->setWhitelisted(true);
                 Command::broadcastCommandMessage($sender, new TranslationContainer("commands.whitelist.add.success", [$args[1]]));
                 return true;
             case "remove":
                 $sender->getServer()->getOfflinePlayer($args[1])->setWhitelisted(false);
                 Command::broadcastCommandMessage($sender, new TranslationContainer("commands.whitelist.remove.success", [$args[1]]));
                 return true;
         }
     }
     return true;
 }
开发者ID:TexusDark,项目名称:Ananas-MP,代码行数:60,代码来源:WhitelistCommand.php

示例7: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     Command::broadcastCommandMessage($sender, "Dumping server memory");
     $sender->getServer()->getMemoryManager()->dumpServerMemory(isset($args[0]) ? $args[0] : $sender->getServer()->getDataPath() . "/memory_dumps/memoryDump_" . date("D_M_j-H.i.s-T_Y", time()), 48, 80);
     return true;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:9,代码来源:DumpMemoryCommand.php

示例8: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return \true;
     }
     $sender->getServer()->setAutoSave(\true);
     Command::broadcastCommandMessage($sender, "Enabled level saving");
     return \true;
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:9,代码来源:SaveOnCommand.php

示例9: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     $sender->getServer()->setAutoSave(false);
     Command::broadcastCommandMessage($sender, new TranslationContainer("commands.save.disabled"));
     return true;
 }
开发者ID:xHFx,项目名称:ImagicalMine,代码行数:9,代码来源:SaveOffCommand.php

示例10: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     Command::broadcastCommandMessage($sender, new TranslationContainer("commands.stop.start"));
     $sender->getServer()->shutdown();
     return true;
 }
开发者ID:TexusDark,项目名称:Ananas-MP,代码行数:9,代码来源:StopCommand.php

示例11: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return \true;
     }
     if (\count($args) < 1 or \count($args) > 4) {
         $sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage);
         return \true;
     }
     $target = \null;
     $origin = $sender;
     if (\count($args) === 1 or \count($args) === 3) {
         if ($sender instanceof Player) {
             $target = $sender;
         } else {
             $sender->sendMessage(TextFormat::RED . "Please provide a player!");
             return \true;
         }
         if (\count($args) === 1) {
             $target = $sender->getServer()->getPlayer($args[0]);
             if ($target === \null) {
                 $sender->sendMessage(TextFormat::RED . "Can't find player " . $args[0]);
                 return \true;
             }
         }
     } else {
         $target = $sender->getServer()->getPlayer($args[0]);
         if ($target === \null) {
             $sender->sendMessage(TextFormat::RED . "Can't find player " . $args[0]);
             return \true;
         }
         if (\count($args) === 2) {
             $origin = $target;
             $target = $sender->getServer()->getPlayer($args[1]);
             if ($target === \null) {
                 $sender->sendMessage(TextFormat::RED . "Can't find player " . $args[1]);
                 return \true;
             }
         }
     }
     if (\count($args) < 3) {
         $origin->teleport($target);
         Command::broadcastCommandMessage($sender, "Teleported " . $origin->getDisplayName() . " to " . $target->getDisplayName());
         return \true;
     } elseif ($target->getLevel() !== \null) {
         $pos = \count($args) === 4 ? 1 : 0;
         $x = $this->getRelativeDouble($target->x, $sender, $args[$pos++]);
         $y = $this->getRelativeDouble($target->y, $sender, $args[$pos++], 0, 128);
         $z = $this->getRelativeDouble($target->z, $sender, $args[$pos]);
         $target->teleport(new Vector3($x, $y, $z));
         Command::broadcastCommandMessage($sender, "Teleported " . $target->getDisplayName() . " to " . \round($x, 2) . ", " . \round($y, 2) . ", " . \round($z, 2));
         return \true;
     }
     $sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage);
     return \true;
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:56,代码来源:TeleportCommand.php

示例12: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (count($args) > 2 || count($args) === 0) {
         $sender->sendMessage(new TranslationContainer("commands.weather.usage", [$this->usageMessage]));
         return false;
     }
     if (count($args) > 1) {
         $seconds = (int) $args[1];
     } else {
         $seconds = 600 * 20;
     }
     if ($sender instanceof Player) {
         $level = $sender->getLevel();
     } else {
         $level = $sender->getServer()->getDefaultLevel();
     }
     if ($args[0] === "clear") {
         if (!$sender->hasPermission("pocketmine.command.weather.clear")) {
             $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission"));
             return true;
         }
         $level->setWeather(Level::WEATHER_CLEARSKY);
         Command::broadcastCommandMessage($sender, new TranslationContainer("commands.weather.clear"));
         return true;
     } elseif ($args[0] === "rain") {
         if (!$sender->hasPermission("pocketmine.command.weather.rain")) {
             $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission"));
             return true;
         }
         if (isset($args[1]) and is_numeric($args[1]) and $args[1] > 0) {
             $time = $args[1];
         } else {
             $time = 120;
         }
         $level->setWeather(Level::WEATHER_RAIN, $time);
         Command::broadcastCommandMessage($sender, new TranslationContainer("commands.weather.rain"));
         return true;
     } elseif ($args[0] === "thunder") {
         if (!$sender->hasPermission("pocketmine.command.weather.thunder")) {
             $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission"));
             return true;
         }
         //WEATHER TODO : THUNDER
         //$level->setThundering(true);
         //$level->setRainTime($seconds * 20);
         //$level->setThunderTime($seconds * 20);
         Command::broadcastCommandMessage($sender, "WIP");
         return true;
     } else {
         $sender->sendMessage(new TranslationContainer("commands.weather.usage", [$this->usageMessage]));
         return false;
     }
 }
开发者ID:MCSou,项目名称:ClearSky,代码行数:56,代码来源:WeatherCommand.php

示例13: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     Command::broadcastCommandMessage($sender, new TranslationContainer(TextFormat::YELLOW . "%pocketmine.command.reload.reloading"));
     $sender->getServer()->reload();
     Command::broadcastCommandMessage($sender, new TranslationContainer(TextFormat::YELLOW . "%pocketmine.command.reload.reloaded"));
     return true;
 }
开发者ID:TexusDark,项目名称:Ananas-MP,代码行数:10,代码来源:ReloadCommand.php

示例14: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     Command::broadcastCommandMessage($sender, TextFormat::YELLOW . "Reloading server...");
     $sender->getServer()->reload();
     Command::broadcastCommandMessage($sender, TextFormat::GOLD . "Reload complete.");
     return true;
 }
开发者ID:TylerAndrew,项目名称:Steadfast2,代码行数:10,代码来源:ReloadCommand.php

示例15: processIPBan

 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);
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:10,代码来源:BanIpCommand.php


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