當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。