作者:orlando09
项目:ImagicalMin
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;
}
作者:NewDelio
项目:PocketMine-0.13.
/**
* 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);
}
}
}
作者:PepbookPv
项目:Genisy
/**
* 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;
}