pocketmine\event\player\PlayerChatEvent::setRecipients PHP Method

setRecipients() public method

public setRecipients ( array $recipients )
$recipients array
    public function setRecipients(array $recipients)
    {
        $this->recipients = $recipients;
    }

Usage Example

Example #1
0
 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);
 }
All Usage Examples Of pocketmine\event\player\PlayerChatEvent::setRecipients