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


PHP PlayerChatEvent::getRscipients方法代码示例

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


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

示例1: eazyCommand

 public function eazyCommand($event)
 {
     if ($event->isCancelled()) {
         return false;
     }
     if ($event instanceof PlayerCommandPreprocessEvent || $event instanceof PlayerChatEvent) {
         $cmd = $event instanceof PlayerChatEvent ? $event->getMessage() : substr($event->getMessage(), 1);
         $sender = $event->getPlayer();
         $ip = true;
     } else {
         $cmd = $event->getCommand();
         $sender = $event->getSender();
         $ip = false;
     }
     if (!$sender->hasPermission("mineblock.eazycommand.use")) {
         return false;
     }
     $arr = explode(" ", $cmd);
     $scl = [];
     $ps = $this->getServer()->getOnlinePlayers();
     foreach ($arr as $k => $v) {
         if (strpos($v, "@") === 0) {
             switch (substr($v, 1)) {
                 case "player":
                 case "p":
                     $arr[$k] = $sender->getName();
                     break;
                 case "x":
                     if ($ip) {
                         $arr[$k] = $sender->x;
                     }
                     break;
                 case "y":
                     if ($ip) {
                         $arr[$k] = $sender->y;
                     }
                     break;
                 case "z":
                     if ($ip) {
                         $arr[$k] = $sender->z;
                     }
                     break;
                 case "world":
                 case "w":
                     if ($ip) {
                         $arr[$k] = $sender->getLevel()->getName();
                     }
                     break;
                 case "all":
                 case "a":
                     if ($sender->isOp() && count($ps) > 0) {
                         $scl[] = $k;
                     }
                     break;
                 case "random":
                 case "r":
                     $arr[$k] = count($ps) < 1 ? "" : $ps[array_rand($ps)]->getName();
                     break;
                 case "server":
                 case "s":
                     $arr[$k] = $this->getServer()->getServerName();
                     break;
                 case "version":
                 case "v":
                     $arr[$k] = $this->getServer()->getApiVersion();
                     break;
                 case "mineblock":
                 case "d":
                     $arr[$k] = ["데베", "MineBlock", "데베플러그인", "MineBlock"][rand(0, 3)];
                     break;
             }
         }
     }
     foreach ($arr as $k => $v) {
         $arr[$k] = str_replace([".@", "_@", "-@"], ["@", "@", "@"], $v);
     }
     if (count($scl) !== 0) {
         $event->setCancelled();
         foreach ($ps as $p) {
             foreach ($scl as $v) {
                 $arr[$v] = $p->getName();
             }
             $cmd = implode(" ", $arr);
             $ep = false;
             if ($event instanceof PlayerCommandPreprocessEvent) {
                 $ev = new PlayerCommandPreprocessEvent($sender, "/" . $cmd);
                 $ep = true;
             } elseif ($event instanceof PlayerChatEvent) {
                 $this->getServer()->getPluginManager()->callEvent($ev = new PlayerChatEvent($sender, $cmd));
                 if (!$ev->isCancelled()) {
                     $this->getServer()->broadcastMessage(sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRscipients());
                 }
                 return false;
             } else {
                 $ev = new ServerCommandEvent($sender, $cmd);
             }
             $this->getServer()->getPluginManager()->callEvent($ev);
             if (!$ev->isCancelled()) {
                 $this->getServer()->dispatchCommand($sender, $ep ? substr($ev->getMessage(), 1) : $ev->getCommand());
             }
//.........这里部分代码省略.........
开发者ID:Skull3x,项目名称:MineBlock,代码行数:101,代码来源:ShortCut.php


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