Esempio n. 1
0
 public function translate(TextContainer $c)
 {
     if ($c instanceof TranslationContainer) {
         $baseText = $this->internalGet($c->getText());
         $baseText = $this->parseTranslation($baseText !== null ? $baseText : $c->getText());
         foreach ($c->getParameters() as $i => $p) {
             $baseText = str_replace("{%{$i}}", $this->parseTranslation($p), $baseText);
         }
     } else {
         $baseText = $this->parseTranslation($c->getText());
     }
     return $baseText;
 }
Esempio n. 2
0
 /**
  * Sends a direct chat message to a player
  *
  * @param string|TextContainer $message
  */
 public function sendMessage($message)
 {
     if ($message instanceof TextContainer) {
         if ($message instanceof TranslationContainer) {
             $this->sendTranslation($message->getText(), $message->getParameters());
             return;
         }
         $message = $message->getText();
     }
     $mes = explode("\n", $this->server->getLanguage()->translateString($message));
     foreach ($mes as $m) {
         if ($m !== "") {
             $pk = new TextPacket();
             $pk->type = TextPacket::TYPE_RAW;
             $pk->message = $m;
             $this->dataPacket($pk);
         }
     }
 }