public function sendMessage($messageId, $to = null, $parameters = [])
    {
        $message = $messageId;

        if (is_string($to)) {
            $player = $this->playerStorage->getPlayerInfo($to);
            $message = $this->translations->getTranslation($messageId, $parameters, strtolower($player->getLanguage()));
        }

        if (is_array($to)) {
            $to = implode(",", $to);
            $message = $this->translations->getTranslations($messageId, $parameters);
        }

        if ($to instanceof Group) {
            $to = implode(",", $to->getLogins());
            $message = $this->translations->getTranslations($messageId, $parameters);
        }

        if ($to === null || $to instanceof Group) {
            $message = $this->translations->getTranslations($messageId, $parameters);
            $this->console->writeln(end($message)['Text']);
        }

        try {
            $this->factory->getConnection()->chatSendServerMessage($message, $to);
        } catch (UnknownPlayerException $e) {
            $this->logger->info("can't send chat message: $message", ["to" => $to, "exception" => $e]);
            // Nothing to do, it happens.
        } catch (InvalidArgumentException $ex) {
            // Nothing to do
        }
    }
public function sendMessage($messageId, $to = null, $parameters = [])
    {
        $message = $messageId;

        if (is_string($to)) {
            $player = $this->playerStorage->getPlayerInfo($to);
            $message = $this->translations->getTranslation($messageId, $parameters, strtolower($player->getLanguage()));
        }

        if (is_array($to)) {
            $to = implode(",", $to);
            $message = $this->translations->getTranslations($messageId, $parameters);
        }

        if ($to instanceof Group) {
            $to = implode(",", $to->getLogins());
            $message = $this->translations->getTranslations($messageId, $parameters);
        }

        if ($to === null || $to instanceof Group) {
            $message = $this->translations->getTranslations($messageId, $parameters);
            $this->console->writeln(end($message)['Text']);
        }

        try {
            $this->factory->getConnection()->chatSendServerMessage($message, $to);
        } catch (UnknownPlayerException $e) {
            $this->logger->info("can't send chat message: $message", ["to" => $to, "exception" => $e]);
            // Nothing to do, it happens.
        } catch (InvalidArgumentException $ex) {
            // Nothing to do
        }
    }
public function sendMessage ( $ messageId , $ to = null , $ parameters = [ ] ) { $ message = $ messageId ; if ( is_string ( $ to ) ) { $ player = $ this -> playerStorage -> getPlayerInfo ( $ to ) ; $ message = $ this -> translations -> getTranslation ( $ messageId , $ parameters , strtolower ( $ player -> getLanguage ( ) ) ) ; } if ( is_array ( $ to ) ) { $ to = implode ( "," , $ to ) ; $ message = $ this -> translations -> getTranslations ( $ messageId , $ parameters ) ; } if ( $ to instanceof Group ) { $ to = implode ( "," , $ to -> getLogins ( ) ) ; $ message = $ this -> translations -> getTranslations ( $ messageId , $ parameters ) ; } if ( $ to === null || $ to instanceof Group ) { $ message = $ this -> translations -> getTranslations ( $ messageId , $ parameters ) ; $ this -> console -> writeln ( end ( $ message ) [ 'Text' ] ) ; } try { $ this -> factory -> getConnection ( ) -> chatSendServerMessage ( $ message , $ to ) ; } catch ( UnknownPlayerException $ e ) { $ this -> logger -> info ( "can't send chat message: $message" , [ "to" => $ to , "exception" => $ e ] ) ; // Nothing to do, it happens. } catch ( InvalidArgumentException $ ex ) { // Nothing to do } }
Send message.

@param string                     $messageId
@param string|string[]|Group|null $to
@param string[]                   $parameters
Send message .