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

getRecipients() public method

public getRecipients ( )
    public function getRecipients()
    {
        return $this->recipients;
    }

Usage Example

 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;
 }
All Usage Examples Of pocketmine\event\player\PlayerChatEvent::getRecipients