當前位置: 首頁>>代碼示例>>PHP>>正文


PHP event\TextContainer類代碼示例

本文整理匯總了PHP中pocketmine\event\TextContainer的典型用法代碼示例。如果您正苦於以下問題:PHP TextContainer類的具體用法?PHP TextContainer怎麽用?PHP TextContainer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TextContainer類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: translate

 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;
 }
開發者ID:orlando092,項目名稱:ImagicalMine,代碼行數:13,代碼來源:BaseLang.php

示例2: sendMessage

 /**
  * 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);
         }
     }
 }
開發者ID:NewDelion,項目名稱:PocketMine-0.13.x,代碼行數:24,代碼來源:Player.php

示例3: sendMessage

 /**
  * Sends a direct chat message to a player
  *
  * @param string|TextContainer $message
  * @return bool
  */
 public function sendMessage($message)
 {
     if ($message instanceof TextContainer) {
         if ($message instanceof TranslationContainer) {
             $this->sendTranslation($message->getText(), $message->getParameters());
             return false;
         }
         $message = $message->getText();
     }
     $mes = explode("\n", $this->server->getLanguage()->translateString($message));
     foreach ($mes as $m) {
         if ($m !== "") {
             $this->server->getPluginManager()->callEvent($ev = new PlayerTextPreSendEvent($this, $m, PlayerTextPreSendEvent::MESSAGE));
             if (!$ev->isCancelled()) {
                 $pk = new TextPacket();
                 $pk->type = TextPacket::TYPE_RAW;
                 $pk->message = $ev->getMessage();
                 $this->dataPacket($pk);
             }
         }
     }
     return true;
 }
開發者ID:PepbookPvP,項目名稱:Genisys,代碼行數:29,代碼來源:Player.php


注:本文中的pocketmine\event\TextContainer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。