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


PHP PlayerChatEvent::setRecipients方法代码示例

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


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

示例1: onPlayerChat

 public function onPlayerChat(PlayerChatEvent $event)
 {
     $chat = $this->chat;
     $p = $event->getPlayer();
     $n = $p->getName();
     if (!isset($chat[$n])) {
         $chat[$n] = true;
     }
     if (!$chat[$n]) {
         $p->sendMessage("[ChatSwitch] " . ($this->isKorean() ? "당신은 채팅을 받지않습니다." : "You are not receive the chat"));
         $event->setCancelled();
         return;
     }
     $recipients = $event->getRecipients();
     foreach ($recipients as $k => $v) {
         $n = $v->getName();
         if (!isset($chat[$n])) {
             $chat[$n] = true;
         }
         if (!$chat[$n]) {
             unset($recipients[$k]);
         }
     }
     if ($this->chat !== $chat) {
         $this->chat = $chat;
         $this->saveYml();
     }
     $event->setRecipients($recipients);
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:29,代码来源:ChatSwitch.php

示例2: onChat

 public function onChat(PlayerChatEvent $event)
 {
     $this->plugin->event = $event;
     $extensions = $this->getAllExtensions();
     foreach ($extensions as $get) {
         if ($this->plugin->getServer()->getPluginManager()->getPlugin($get) && method_exists($this->plugin->getServer()->getPluginManager()->getPlugin($get), "onRegisterPrefix")) {
             $this->plugin->getServer()->getPluginManager()->getPlugin($get)->onRegisterPrefix();
         }
     }
     // ===========
     //	Format
     // ===========
     $this->plugin->replaceTag("{WORLD}", $event->getPlayer()->getLevel()->getName());
     //Level Tag
     $this->plugin->replaceTag("{PLAYER}", $event->getPlayer()->getName());
     //Player Tag
     $this->plugin->replaceTag("{PREFIX}", $this->plugin->getConfig()->get("prefix"));
     //Prefix Tag
     $this->plugin->replaceTag("{SUFFIX}", $this->plugin->getConfig()->get("suffix"));
     //Suffix Tag
     $this->plugin->replaceTag("{MESSAGE}", $event->getMessage());
     //Message Tag
     //Custom tags
     $tags = new Config($this->plugin->getDataFolder() . "tags.yml", Config::YAML);
     foreach ($tags->getAll() as $tag => $value) {
         $this->plugin->replaceTag("{" . strtoupper($tag) . "}", $value);
     }
     $event->setFormat($this->getFormattedMessage($this->plugin->getConfig()->get("chat-format")));
     // ===========
     //	Player Mute
     // ===========
     $mhut = $event->getRecipients();
     for ($lol = 0; $i < count($mhut); $lol++) {
         if (isset($this->leave[$mhut[$lol]->getName()])) {
             unset($mhut[$lol]);
         }
     }
     $event->setRecipients($mhut);
     $allowChat = $this->plugin->getConfig()->get("disablechat");
     if ($allowChat) {
         $event->setCancelled(true);
         return;
     }
     if (!$allowChat || $allowChat == null) {
         $player = $event->getPlayer();
         $perm = "chatmute";
         if ($player->isPermissionSet($perm)) {
             $event->setCancelled(true);
             return;
         }
         $format = $this->getFormattedMessage($player, $event->getMessage());
         $config_node = $this->plugin->getConfig()->get("enable-formatter");
         if (isset($config_node) and $config_node === true) {
             $event->setFormat($format);
         }
         return;
     }
 }
开发者ID:AndreyNazarchuk,项目名称:Collection-Plugins-PocketMine-Prax,代码行数:58,代码来源:EventListener.php

示例3: onPlayerChat

 public function onPlayerChat(PlayerChatEvent $event)
 {
     $recipients = $event->getRecipients();
     $p = $event->getPlayer();
     foreach ($recipients as $k => $v) {
         if ($v instanceof Player && !$v->hasPermission("debe.localchat.hear")) {
             if ($p->getLevel() !== $v->getLevel() || $p->distance($v) > $this->distanceChat->get("Local")) {
                 unset($recipients[$k]);
             }
         }
     }
     $event->setRecipients($recipients);
 }
开发者ID:stoastye85,项目名称:Plugins,代码行数:13,代码来源:LocalChat.php

示例4: onPlayerChat

 public function onPlayerChat(PlayerChatEvent $event)
 {
     $recipients = $event->getRecipients();
     foreach ($recipients as $k => $v) {
         $n = $v->getName();
         if (!isset($this->chat[$n])) {
             $this->chat[$n] = true;
         }
         if (!$this->chat[$n]) {
             unset($recipients[$k]);
         }
     }
     $event->setRecipients($recipients);
 }
开发者ID:stoastye85,项目名称:Plugins,代码行数:14,代码来源:ChatSwitch.php

示例5: onChat

 /**
  * @param PlayerChatEvent $event
  *
  * @priority        HIGH
  * @ignoreCancelled true
  */
 public function onChat(PlayerChatEvent $event)
 {
     $gamer = $this->hub->getGamerForPlayer($event->getPlayer());
     if ($gamer !== null) {
         $module = $gamer->getModule();
         if ($module === null) {
             $event->setCancelled();
             $gamer->getPlayer()->sendMessage("You cannot chat until your account is loaded!");
             // TODO translate
             return;
         }
         $event->setRecipients(array_filter($event->getRecipients(), function (Player $player) use($module) {
             $gamer = $this->hub->getGamerForPlayer($player);
             return $gamer instanceof Gamer and $gamer->getModule() === $module;
         }));
     }
 }
开发者ID:gitter-badger,项目名称:DynamicHub,代码行数:23,代码来源:StandardListener.php

示例6: onPlayerChat

 public function onPlayerChat(PlayerChatEvent $ev)
 {
     $p = $ev->getPlayer();
     $recipients = $ev->getRecipients();
     $array = [];
     foreach ($recipients as $m => $t) {
         if ($t instanceof Player) {
             if ($p->getLevel() !== $t->getLevel()) {
                 $array[] = $m;
                 foreach ($array as $messages) {
                     unset($recipients[$m]);
                     $ev->setRecipients(array_values($recipients));
                 }
             }
         }
     }
 }
开发者ID:ChiefArtz,项目名称:LevelChat,代码行数:17,代码来源:LevelChat.php

示例7: onChat

 public function onChat(PlayerChatEvent $event)
 {
     if ($this->getPlugin()->enabled === false) {
         return;
     }
     $player = $event->getPlayer();
     $recipients = [];
     $radius = $this->getPlugin()->getRadiusForPlayer($player);
     if ($radius === false) {
         return;
     }
     foreach ($player->getLevel()->getPlayers() as $target) {
         if ($this->getPlugin()->isWithinRadius($player, $target, $radius)) {
             $recipients[] = $target;
         }
     }
     $event->setRecipients($recipients);
 }
开发者ID:PrimusLV,项目名称:RealTalk,代码行数:18,代码来源:EventListener.php

示例8: onChat

 public function onChat(PlayerChatEvent $event)
 {
     $player = $event->getPlayer();
     if ($this->isMute() and !$player->isOp()) {
         $event->setCancelled();
         $player->sendMessage(TextFormat::RED . "현재 채팅을 할 수 없습니다.");
     }
     $recipients = [new ConsoleCommandSender()];
     if ($player->isOp()) {
         $recipients = $this->getServer()->getOnlinePlayers();
         array_push($recipients, new ConsoleCommandSender());
     } else {
         foreach ($this->getServer()->getOnlinePlayers() as $target) {
             if ($player->distance($target) <= $this->config['chat-distance'] and $player->getLevel() === $target->getLevel() or $target->isOp()) {
                 array_push($recipients, $target);
             }
         }
     }
     $event->setRecipients($recipients);
 }
开发者ID:organization,项目名称:NearChat,代码行数:20,代码来源:NearChat.php

示例9: onPlayerChat

 public function onPlayerChat(PlayerChatEvent $event)
 {
     $player = $event->getPlayer();
     $message = $event->getMessage();
     if ($this->getBadWordBlocker()->contains($message, $this->getBadWordBlocker()->getList())) {
         $player->sendMessage($this->getBadWordBlocker()->getConfig()->get("blockmessage"));
         $event->setCancelled(true);
         return;
     }
     if (isset($player->lastwritten)) {
         if ($player->lastwritten == $message) {
             $player->sendMessage($this->getBadWordBlocker()->getConfig()->get("lastwritten"));
             $event->setCancelled(true);
             return;
         }
     }
     if (isset($player->timewritten)) {
         if ($player->timewritten > new \DateTime()) {
             $player->sendMessage($this->getBadWordBlocker()->getConfig()->get("timewritten"));
             $event->setCancelled(true);
             return;
         }
     }
     if (ctype_upper($message)) {
         $player->sendMessage($this->getBadWordBlocker()->getConfig()->get("caps"));
         $event->setCancelled(true);
         return;
     }
     $player->timewritten = new \DateTime();
     $player->timewritten = $player->timewritten->add(new \DateInterval("PT" . $this->getBadWordBlocker()->getConfig()->get("waitingtime") . "S"));
     $player->lastwritten = $message;
     $recipients = $event->getRecipients();
     $newrecipients = array();
     foreach ($recipients as $recipient) {
         if (!isset($recipient->nochat)) {
             $newrecipients[] = $recipient;
         }
     }
     $event->setRecipients($newrecipients);
 }
开发者ID:jjplaying,项目名称:BadWordBlocker,代码行数:40,代码来源:EventListener.php

示例10: onPlayerChat

 public function onPlayerChat(PlayerChatEvent $event)
 {
     if ($this->plugin->getConfig()->getAll()["block-chat"]) {
         if (!ServerAuth::getAPI()->isPlayerRegistered($event->getPlayer()->getName()) || !ServerAuth::getAPI()->isPlayerAuthenticated($event->getPlayer())) {
             $event->setCancelled(true);
             //Cancel message
         }
         $recipients = $event->getRecipients();
         for ($i = 0; $i < count($recipients); $i++) {
             $player = $recipients[$i];
             if ($player instanceof Player) {
                 if (!ServerAuth::getAPI()->isPlayerAuthenticated($player)) {
                     $message[] = $i;
                     foreach ($message as $messages) {
                         unset($recipients[$i]);
                         $event->setRecipients(array_values($recipients));
                     }
                 }
             }
         }
     }
 }
开发者ID:RedstoneAlmeida,项目名称:SliceAuth,代码行数:22,代码来源:EventListener.php

示例11: onChat

 public function onChat(PlayerChatEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $player = $ev->getPlayer();
     if (!$this->cfg["settings"]["chat"]) {
         $ev->setCancelled();
         $player->sendMessage(TextFormat::RED . "[YouChat] Chat has been disabled!");
         return;
     }
     $n = trim(strtolower($player->getName()));
     $prefix = $this->cfg["settings"]["prefix"];
     if (isset($this->players[$n])) {
         if ($this->players[$n]["prefix"]) {
             $prefix = $this->players[$n]["prefix"];
         }
         if ($this->players[$n]["mute"]) {
             $ev->setCancelled();
             $player->sendMessage(TextFormat::RED . "[YouChat] You have been muted from chat!");
             return;
         }
         if ($this->players[$n]["pause"]) {
             $ev->setCancelled();
             $player->sendMessage(TextFormat::RED . "[YouChat] You have paused chat!");
             return;
         }
     }
     $recvr = [];
     foreach ($ev->getRecipients() as $to) {
         $m = strtolower($to->getName());
         if (isset($this->players[$m])) {
             if ($this->players[$m]["pause"]) {
                 continue;
             }
         }
         $recvr[] = $to;
     }
     $ev->setRecipients($recvr);
     $vars = ["{YouChat}" => $this->getDescription()->getFullName(), "{player}" => $player->getName(), "{displayname}" => "{%0}", "{nick}" => $player->getDisplayName(), "{world}" => $player->getLevel()->getName(), "{message}" => "{%1}", "{prefix}" => $prefix, "{BLACK}" => TextFormat::BLACK, "{DARK_BLUE}" => TextFormat::DARK_BLUE, "{DARK_GREEN}" => TextFormat::DARK_GREEN, "{DARK_AQUA}" => TextFormat::DARK_AQUA, "{DARK_RED}" => TextFormat::DARK_RED, "{DARK_PURPLE}" => TextFormat::DARK_PURPLE, "{GOLD}" => TextFormat::GOLD, "{GRAY}" => TextFormat::GRAY, "{DARK_GRAY}" => TextFormat::DARK_GRAY, "{BLUE}" => TextFormat::BLUE, "{GREEN}" => TextFormat::GREEN, "{AQUA}" => TextFormat::AQUA, "{RED}" => TextFormat::RED, "{LIGHT_PURPLE}" => TextFormat::LIGHT_PURPLE, "{YELLOW}" => TextFormat::YELLOW, "{WHITE}" => TextFormat::WHITE, "{OBFUSCATED}" => TextFormat::OBFUSCATED, "{BOLD}" => TextFormat::BOLD, "{STRIKETHROUGH}" => TextFormat::STRIKETHROUGH, "{UNDERLINE}" => TextFormat::UNDERLINE, "{ITALIC}" => TextFormat::ITALIC, "{RESET}" => TextFormat::RESET];
     if (($kr = $this->getServer()->getPluginManager()->getPlugin("KillRate")) !== null) {
         $vars["{kills}"] = $kr->getScore($player, "player");
         $vars["{points}"] = $kr->getScore($player, "points");
     }
     $ev->setFormat(strtr($this->cfg["settings"]["chat-format"], $vars));
 }
开发者ID:applqpak,项目名称:plugin-remakes,代码行数:46,代码来源:Main.php

示例12: onChat

 /**
  * @param PlayerChatEvent $e
  *
  * @priority LOW
  */
 public function onChat(PlayerChatEvent $e)
 {
     $p = $e->getPlayer();
     if ($this->inArena($p)) {
         $e->setMessage(str_replace(["%PLAYER", "%MESSAGE"], [$p->getDisplayName(), $e->getMessage()], SurvivalGames::$cfg["chat_format"]));
         $e->setRecipients($this->getPlayers());
     } else {
         $e->setRecipients(array_diff($this->getPlayers(), $e->getRecipients()));
     }
 }
开发者ID:ChiefArtz,项目名称:SurvivalGames,代码行数:15,代码来源:Arena.php

示例13: onPlayerChat

 public function onPlayerChat(PlayerChatEvent $event)
 {
     $playerInGame = false;
     $InGamePlayers = [];
     $msg = $event->getMessage();
     $player = $event->getPlayer();
     //$this->plugin->log ( " handlePlayerInGameChat - | " . $player->getName () . "| msg: " . $msg );
     if (!empty($player) && !empty($msg)) {
         foreach ($this->plugin->gameLevelManager->levels as &$lv) {
             if ($lv instanceof GameLevelModel) {
                 if (isset($lv->joinedPlayers[$player->getName()])) {
                     $message = TextFormat::GRAY . "[HG-" . TextFormat::RED . $lv->type . TextFormat::GRAY . "]" . TextFormat::YELLOW . " > " . TextFormat::WHITE . $msg;
                     $event->setMessage($message);
                     $event->setRecipients($lv->joinedPlayers);
                     $playerInGame = true;
                     $this->plugin->log(" handlePlayerInGameChat - in-game-message " . $msg . " send to " . count($lv->joinedPlayers));
                 }
                 if (count($lv->joinedPlayers) > 0) {
                     $InGamePlayers = array_merge($lv->joinedPlayers, $InGamePlayers);
                     $this->plugin->log(" handlePlayerInGameChat - merged " . $lv->name . " players " . count($lv->joinedPlayers));
                 }
             }
         }
         if (!$playerInGame) {
             $filteredplayers = array_diff($this->plugin->getServer()->getOnlinePlayers(), $InGamePlayers);
             $this->plugin->log(" handlePlayerInGameChat - not-in-game-message " . $msg . " send to " . count($filteredplayers));
             $event->setRecipients($filteredplayers);
         }
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:30,代码来源:GameLevelListener.php

示例14: onPlayerChat

 public function onPlayerChat(PlayerChatEvent $event)
 {
     if ($this->plugin->getConfig()->getAll()["block-chat"]) {
         if (!ServerAuth::getAPI()->isPlayerAuthenticated($event->getPlayer())) {
             $event->setCancelled(true);
             //Cancel message
         }
         $recipients = $event->getRecipients();
         foreach ($recipients as $key => $recipient) {
             if ($recipient instanceof Player) {
                 if (!ServerAuth::getAPI()->isPlayerAuthenticated($recipient)) {
                     unset($recipients[$key]);
                 }
             }
         }
         $event->setRecipients($recipients);
     }
 }
开发者ID:majovec,项目名称:ServerAuth,代码行数:18,代码来源:EventListener.php

示例15: onChat

 public function onChat(PlayerChatEvent $ev)
 {
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $p = $ev->getPlayer();
     if ($p->hasPermission("gb.cmd.togglechat.excempt")) {
         return;
     }
     // Can always chat!
     if (!$this->chat) {
         $p->sendMessage(mc::_("Chat has been globally disabled!"));
         $ev->setCancelled();
         return;
     }
     if ($this->getState($p, false)) {
         $p->sendMessage(mc::_("You have chat disabled!  Use /chat-on"));
         $ev->setCancelled();
         return;
     }
     $recvr = [];
     foreach ($ev->getRecipients() as $to) {
         if ($this->getState($to, false)) {
             continue;
         }
         $recvr[] = $to;
     }
     $ev->setRecipients($recvr);
 }
开发者ID:0-DevMatthew-0,项目名称:pocketmine-plugins,代码行数:30,代码来源:CmdChatMgr.php


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