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


PHP PlayerChatEvent::getRecipients方法代码示例

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


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

示例1: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "as") {
         return false;
     }
     if (count($args) < 2) {
         $sender->sendMessage(mc::_("Must specified a player and a command"));
         return false;
     }
     $player = $this->owner->getServer()->getPlayer($n = array_shift($args));
     if (!$player) {
         $sender->sendMessage(mc::_("Player %1% not found", $n));
         return true;
     }
     if ($args[0] == 'chat' || $args[0] == 'say') {
         array_shift($args);
         $chat = implode(" ", $args);
         $this->owner->getServer()->getPluginManager()->callEvent($ev = new PlayerChatEvent($player, $chat));
         if (!$ev->isCancelled()) {
             if (MPMU::apiVersion("1.12.0")) {
                 $s = $this->owner->getServer();
                 $s->broadcastMessage($s->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients());
             } else {
                 $this->owner->getServer()->broadcastMessage(sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
             }
         }
     } else {
         $cmdline = implode(' ', $args);
         $sender->sendMessage(mc::_("Running command as %1%", $n));
         $this->owner->getServer()->dispatchCommand($player, $cmdline);
     }
     return true;
 }
开发者ID:0-DevMatthew-0,项目名称:pocketmine-plugins,代码行数:33,代码来源:CmdAs.php

示例2: execute

 /**
  * @param CommandSender $sender
  * @param string $alias
  * @param array $args
  * @return bool
  */
 public function execute(CommandSender $sender, $alias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return false;
     }
     if (count($args) < 1) {
         $this->sendUsage($sender, $alias);
         return false;
     }
     if (!($player = $this->getAPI()->getPlayer(array_shift($args)))) {
         $sender->sendMessage(TextFormat::RED . "[Error] Player not found");
         return false;
     } elseif ($player->hasPermission("essentials.sudo.exempt")) {
         $sender->sendMessage(TextFormat::RED . "[Error] " . $player->getName() . " cannot be sudo'ed");
         return false;
     }
     $v = implode(" ", $args);
     if (substr($v, 0, 2) === "c:") {
         $sender->sendMessage(TextFormat::GREEN . "Sending message as " . $player->getDisplayName());
         $this->getAPI()->getServer()->getPluginManager()->callEvent($ev = new PlayerChatEvent($player, substr($v, 2)));
         if (!$ev->isCancelled()) {
             $this->getAPI()->getServer()->broadcastMessage(\sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
         }
     } else {
         $sender->sendMessage(TextFormat::AQUA . "Command ran as " . $player->getDisplayName());
         $this->getAPI()->getServer()->dispatchCommand($player, $v);
     }
     return true;
 }
开发者ID:PrimusLV,项目名称:EssentialsPE,代码行数:35,代码来源:Sudo.php

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例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: handleDataPacket


//.........这里部分代码省略.........
                 $this->inventory->sendSlot($slot, $this);
                 break;
             }
             $this->inventory->setItem($slot, Item::get(Item::AIR, null, 0));
             $motion = $this->getDirectionVector()->multiply(0.4);
             $this->level->dropItem($this->add(0, 1.3, 0), $item, $motion, 40);
             $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
             break;
         case ProtocolInfo::TEXT_PACKET:
             if ($this->spawned === false or $this->dead === true) {
                 break;
             }
             $this->craftingType = 0;
             if ($packet->type === TextPacket::TYPE_CHAT) {
                 $packet->message = TextFormat::clean($packet->message, $this->removeFormat);
                 foreach (explode("\n", $packet->message) as $message) {
                     if (trim($message) != "" and strlen($message) <= 255 and $this->messageCounter-- > 0) {
                         $ev = new PlayerCommandPreprocessEvent($this, $message);
                         if (mb_strlen($ev->getMessage(), "UTF-8") > 320) {
                             $ev->setCancelled();
                         }
                         $this->server->getPluginManager()->callEvent($ev);
                         if ($ev->isCancelled()) {
                             break;
                         }
                         if (substr($ev->getMessage(), 0, 1) === "/") {
                             //Command
                             Timings::$playerCommandTimer->startTiming();
                             $this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1));
                             Timings::$playerCommandTimer->stopTiming();
                         } else {
                             $this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage()));
                             if (!$ev->isCancelled()) {
                                 $this->server->broadcastMessage($ev->getPlayer()->getDisplayName() . ": " . $ev->getMessage(), $ev->getRecipients());
                             }
                         }
                         $ev = new PlayerCommandPostprocessEvent($this, $message);
                         $this->server->getPluginManager()->callEvent($ev);
                     }
                 }
             }
             break;
         case ProtocolInfo::CONTAINER_CLOSE_PACKET:
             if ($this->spawned === false or $packet->windowid === 0) {
                 break;
             }
             $this->craftingType = 0;
             $this->currentTransaction = null;
             if (isset($this->windowIndex[$packet->windowid])) {
                 $this->server->getPluginManager()->callEvent(new InventoryCloseEvent($this->windowIndex[$packet->windowid], $this));
                 $this->removeWindow($this->windowIndex[$packet->windowid]);
             } else {
                 unset($this->windowIndex[$packet->windowid]);
             }
             break;
         case ProtocolInfo::CRAFTING_EVENT_PACKET:
             if ($this->spawned === false or $this->dead) {
                 break;
             } elseif (!isset($this->windowIndex[$packet->windowId])) {
                 $this->inventory->sendContents($this);
                 $pk = new ContainerClosePacket();
                 $pk->windowid = $packet->windowId;
                 $this->dataPacket($pk);
                 break;
             }
             $recipe = $this->server->getCraftingManager()->getRecipe($packet->id);
开发者ID:WonderlandPE,项目名称:Steadfast2,代码行数:67,代码来源:Player.php

示例11: asyncProcess

 public function asyncProcess($name, $format, $message, $find, $eventType)
 {
     $player = $this->playerTemp[$name];
     if (!$player instanceof Player) {
         return;
     }
     if ($player->closed) {
         return;
     }
     switch ($eventType) {
         case "chat":
             if ($find == null) {
                 if (isset($this->chatCheck[$name . ">" . $message])) {
                     $this->chatCheck[$name . ">" . $message] = true;
                     $this->getServer()->getPluginManager()->callEvent($event = new PlayerChatEvent($player, $message, $format));
                     if (!$event->isCancelled()) {
                         $this->getServer()->broadcastMessage($this->getServer()->getLanguage()->translateString($event->getFormat(), [$event->getPlayer()->getDisplayName(), $event->getMessage()]), $event->getRecipients());
                     }
                 }
             } else {
                 $player->sendMessage(TextFormat::RED . $this->get("some-badwords-found") . ": " . $message . "( " . $this->get("doubt") . ": " . $find . " ) ");
                 $player->sendMessage(TextFormat::RED . $this->get("be-careful-about-badwords"));
                 $this->cautionNotice($player, $message . "( " . $find . " ) ");
                 return;
             }
             break;
         case "command":
             if ($find == null) {
                 if (isset($this->commandCheck[$player->getName() . ">" . $message])) {
                     $this->commandCheck[$player->getName() . ">" . $message] = true;
                     $this->getServer()->getPluginManager()->callEvent($event = new PlayerCommandPreprocessEvent($player, $message));
                     if (!$event->isCancelled()) {
                         $this->getServer()->dispatchCommand($event->getPlayer(), substr($event->getMessage(), 1));
                     }
                 }
             } else {
                 $player->sendMessage(TextFormat::RED . $this->get("some-badwords-found") . ": " . $message . " ( " . $this->get("doubt") . ": " . $find . " )");
                 $player->sendMessage(TextFormat::RED . $this->get("be-careful-about-badwords"));
                 $this->cautionNotice($player, $message . " ( " . $find . " ) ");
                 return;
             }
             break;
         case "sign":
             if ($find == null) {
                 if (isset($this->signCheck[$player->getName() . ">" . $message])) {
                     $this->signCheck[$player->getName() . ">" . $message] = true;
                     $blockPos = explode(":", $format[2]);
                     $block = Block::get($format[0], $format[1], new Position($blockPos[0], $blockPos[1], $blockPos[2], $player->getLevel()));
                     $lines = explode("\n", $message);
                     $event = new SignChangeEvent($block, $player, [TextFormat::clean($lines[0], $player->getRemoveFormat()), TextFormat::clean($lines[1], $player->getRemoveFormat()), TextFormat::clean($lines[2], $player->getRemoveFormat()), TextFormat::clean($lines[3], $player->getRemoveFormat())]);
                     $this->getServer()->getPluginManager()->callEvent($event);
                     $tile = $player->getLevel()->getTile($block);
                     if (!$tile instanceof Sign) {
                         return;
                     }
                     if (!$event->isCancelled()) {
                         $tile->setText($lines[0], $lines[1], $lines[2], $lines[3]);
                     }
                 }
             } else {
                 $message = explode("\n", $message);
                 $message = implode(" ", $message);
                 $player->sendMessage(TextFormat::RED . $this->get("some-badwords-found") . ": " . $message . " ( " . $this->get("doubt") . ": " . $find . " )");
                 $player->sendMessage(TextFormat::RED . $this->get("be-careful-about-badwords"));
                 $this->cautionNotice($player, $message . " ( " . $find . " ) ");
                 return;
             }
             break;
         case "name":
             if (isset($this->nameCheck[$player->getName()])) {
                 $this->nameCheck[$player->getName()] = true;
                 if (strlen(trim($format)) > 0) {
                     $this->getServer()->broadcastMessage($format);
                 }
             } else {
                 $player->kick($this->get("badwords-nickname"));
                 return;
             }
             break;
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:81,代码来源:Gentleman.php

示例12: specialCommand

 public function specialCommand($event)
 {
     if ($event->isCancelled()) {
         return false;
     }
     if ($event instanceof PlayerCommandPreprocessEvent || $event instanceof PlayerChatEvent) {
         $cmd = str_replace("/", "", $event->getMessage());
         $sender = $event->getPlayer();
     } else {
         $cmd = $event->getCommand();
         $sender = $event->getSender();
     }
     if (!$sender->hasPermission("debe.eazycommand.use")) {
         return false;
     }
     $arr = explode(" ", $cmd);
     $all = [];
     $ps = $this->getServer()->getOnlinePlayers();
     foreach ($arr as $k => $v) {
         if (strpos($v, "@") === 0) {
             switch (strtolower(str_replace("@", "", $v))) {
                 case "username":
                 case "user":
                 case "u":
                 case "player":
                 case "p":
                     $arr[$k] = $sender->getName();
                     break;
                 case "world":
                 case "w":
                     if ($sender->getName() != "CONSOLE") {
                         $arr[$k] = $sender->getLevel()->getName();
                     }
                     break;
                 case "all":
                 case "a":
                     if ($sender->isOp() || count($ps) > 0) {
                         $all[] = $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 "debe":
                 case "d":
                     $arr[$k] = ["데베", "DeBe", "데베플러그인", "DeBePlugins"][rand(0, 3)];
                     break;
             }
         }
     }
     if ($all !== []) {
         $event->setCancelled();
         foreach ($ps as $p) {
             foreach ($all 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->getRecipients());
                 }
                 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());
             }
         }
         return false;
     } else {
         return implode(" ", $arr);
     }
 }
开发者ID:stoastye85,项目名称:Plugins,代码行数:89,代码来源:EazyCommand.php

示例13: handleDataPacket


//.........这里部分代码省略.........
             $this->server->getPluginManager()->callEvent($ev);
             if ($ev->isCancelled()) {
                 $this->inventory->sendContents($this);
                 break;
             }
             $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1), $this);
             $motion = $this->getDirectionVector()->multiply(0.4);
             $this->level->dropItem($this->add(0, 1.3, 0), $item, $motion, 40);
             if ($this->inAction === true) {
                 $this->inAction = false;
                 $this->sendMetadata($this->getViewers());
             }
             break;
         case ProtocolInfo::MESSAGE_PACKET:
             if ($this->spawned === false or $this->dead === true) {
                 break;
             }
             $this->craftingType = 0;
             $packet->message = TextFormat::clean($packet->message);
             if (trim($packet->message) != "" and strlen($packet->message) <= 255) {
                 $message = $packet->message;
                 $this->server->getPluginManager()->callEvent($ev = new PlayerCommandPreprocessEvent($this, $message));
                 if ($ev->isCancelled()) {
                     break;
                 }
                 if (substr($ev->getMessage(), 0, 1) === "/") {
                     //Command
                     Timings::$playerCommandTimer->startTiming();
                     $this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1));
                     Timings::$playerCommandTimer->stopTiming();
                 } else {
                     $this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage()));
                     if (!$ev->isCancelled()) {
                         $this->server->broadcastMessage(sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
                     }
                 }
             }
             break;
         case ProtocolInfo::CONTAINER_CLOSE_PACKET:
             if ($this->spawned === false or $packet->windowid === 0) {
                 break;
             }
             $this->craftingType = 0;
             $this->currentTransaction = null;
             if (isset($this->windowIndex[$packet->windowid])) {
                 $this->server->getPluginManager()->callEvent(new InventoryCloseEvent($this->windowIndex[$packet->windowid], $this));
                 $this->removeWindow($this->windowIndex[$packet->windowid]);
             } else {
                 unset($this->windowIndex[$packet->windowid]);
             }
             break;
         case ProtocolInfo::CONTAINER_SET_SLOT_PACKET:
             if ($this->spawned === false or $this->blocked === true or $this->dead === true) {
                 break;
             }
             if ($packet->slot < 0) {
                 break;
             }
             if ($packet->windowid === 0) {
                 //Our inventory
                 if ($packet->slot >= $this->inventory->getSize()) {
                     break;
                 }
                 if ($this->isCreative()) {
                     if ($this->getCreativeBlock($packet->item) !== -1) {
                         $this->inventory->setItem($packet->slot, $packet->item);
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:67,代码来源:Player.php

示例14: handleDataPacket


//.........这里部分代码省略.........
                  */
                 break;
             }
             if ($this->isCreative() and $this->server->limitedCreative) {
                 break;
             }
             $this->getTransactionQueue()->addTransaction(new DropItemTransaction($packet->item));
             break;
         case ProtocolInfo::TEXT_PACKET:
             if ($this->spawned === false or !$this->isAlive()) {
                 break;
             }
             $this->craftingType = self::CRAFTING_SMALL;
             if ($packet->type === TextPacket::TYPE_CHAT) {
                 $packet->message = TextFormat::clean($packet->message, $this->removeFormat);
                 foreach (explode("\n", $packet->message) as $message) {
                     if (trim($message) != "" and strlen($message) <= 255 and $this->messageCounter-- > 0) {
                         $ev = new PlayerCommandPreprocessEvent($this, $message);
                         if (mb_strlen($ev->getMessage(), "UTF-8") > 320) {
                             $ev->setCancelled();
                         }
                         $this->server->getPluginManager()->callEvent($ev);
                         if ($ev->isCancelled()) {
                             break;
                         }
                         if (substr($ev->getMessage(), 0, 1) === "/") {
                             //Command
                             Timings::$playerCommandTimer->startTiming();
                             $this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1));
                             Timings::$playerCommandTimer->stopTiming();
                         } else {
                             $this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage()));
                             if (!$ev->isCancelled()) {
                                 $this->server->broadcastMessage($this->getServer()->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients());
                             }
                         }
                     }
                 }
             }
             break;
         case ProtocolInfo::CONTAINER_CLOSE_PACKET:
             if ($this->spawned === false or $packet->windowid === 0) {
                 break;
             }
             $this->craftingType = self::CRAFTING_SMALL;
             if (isset($this->windowIndex[$packet->windowid])) {
                 $this->server->getPluginManager()->callEvent(new InventoryCloseEvent($this->windowIndex[$packet->windowid], $this));
                 $this->removeWindow($this->windowIndex[$packet->windowid]);
             }
             /**
              * Drop anything still left in the crafting inventory
              * This will usually never be needed since Windows 10 clients will send DropItemPackets
              * which will cause this to happen anyway, but this is here for when transactions
              * fail and items end up stuck in the crafting inventory.
              */
             foreach ($this->getFloatingInventory()->getContents() as $item) {
                 $this->getTransactionQueue()->addTransaction(new DropItemTransaction($item));
             }
             break;
         case ProtocolInfo::CRAFTING_EVENT_PACKET:
             if ($this->spawned === false or !$this->isAlive()) {
                 break;
             }
             /**
              * For some annoying reason, anvils send window ID 255 when crafting with them instead of the _actual_ anvil window ID
              * The result of this is anvils immediately closing when used. This is highly unusual, especially since the
开发者ID:iTXTech,项目名称:Genisys,代码行数:67,代码来源:Player.php

示例15: 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


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