本文整理汇总了PHP中pocketmine\Server::getLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::getLanguage方法的具体用法?PHP Server::getLanguage怎么用?PHP Server::getLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Server
的用法示例。
在下文中一共展示了Server::getLanguage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerServerAliases
/**
* @return void
*/
public function registerServerAliases()
{
$values = $this->server->getCommandAliases();
foreach ($values as $alias => $commandStrings) {
if (strpos($alias, ":") !== false or strpos($alias, " ") !== false) {
$this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.command.alias.illegal", [$alias]));
continue;
}
$targets = [];
$bad = "";
foreach ($commandStrings as $commandString) {
$args = explode(" ", $commandString);
$command = $this->getCommand($args[0]);
if ($command === null) {
if (strlen($bad) > 0) {
$bad .= ", ";
}
$bad .= $commandString;
} else {
$targets[] = $commandString;
}
}
if (strlen($bad) > 0) {
$this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.command.alias.notFound", [$alias, $bad]));
continue;
}
//These registered commands have absolute priority
if (count($targets) > 0) {
$this->knownCommands[strtolower($alias)] = new FormattedCommandAlias(strtolower($alias), $targets);
} else {
unset($this->knownCommands[strtolower($alias)]);
}
}
}
示例2: disablePlugin
/**
* @param Plugin $plugin
*/
public function disablePlugin(Plugin $plugin)
{
if ($plugin instanceof PluginBase and $plugin->isEnabled()) {
$this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.plugin.disable", [$plugin->getDescription()->getFullName()]));
$this->server->getPluginManager()->callEvent(new PluginDisableEvent($plugin));
$plugin->setEnabled(false);
}
}
示例3: processInterfaces
public function processInterfaces()
{
foreach ($this->interfaces as $interface) {
try {
$interface->process();
} catch (\Throwable $e) {
$logger = $this->server->getLogger();
if (\pocketmine\DEBUG > 1) {
if ($logger instanceof MainLogger) {
$logger->logException($e);
}
}
$interface->emergencyShutdown();
$this->unregisterInterface($interface);
$logger->critical($this->server->getLanguage()->translateString("pocketmine.server.networkError", [get_class($interface), $e->getMessage()]));
}
}
}
示例4: registerEvents
/**
* Registers all the events in the given Listener class
*
* @param Listener $listener
* @param Plugin $plugin
*
* @throws PluginException
*/
public function registerEvents(Listener $listener, Plugin $plugin)
{
if (!$plugin->isEnabled()) {
throw new PluginException("Plugin attempted to register " . get_class($listener) . " while not enabled");
}
$reflection = new \ReflectionClass(get_class($listener));
foreach ($reflection->getMethods() as $method) {
if (!$method->isStatic()) {
$priority = EventPriority::NORMAL;
$ignoreCancelled = false;
if (preg_match("/^[\t ]*\\* @priority[\t ]{1,}([a-zA-Z]{1,})/m", (string) $method->getDocComment(), $matches) > 0) {
$matches[1] = strtoupper($matches[1]);
if (defined(EventPriority::class . "::" . $matches[1])) {
$priority = constant(EventPriority::class . "::" . $matches[1]);
}
}
if (preg_match("/^[\t ]*\\* @ignoreCancelled[\t ]{1,}([a-zA-Z]{1,})/m", (string) $method->getDocComment(), $matches) > 0) {
$matches[1] = strtolower($matches[1]);
if ($matches[1] === "false") {
$ignoreCancelled = false;
} elseif ($matches[1] === "true") {
$ignoreCancelled = true;
}
}
$parameters = $method->getParameters();
if (count($parameters) === 1 and $parameters[0]->getClass() instanceof \ReflectionClass and is_subclass_of($parameters[0]->getClass()->getName(), Event::class)) {
$class = $parameters[0]->getClass()->getName();
$reflection = new \ReflectionClass($class);
if (strpos((string) $reflection->getDocComment(), "@deprecated") !== false and $this->server->getProperty("settings.deprecated-verbose", true)) {
$this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.plugin.deprecatedEvent", [$plugin->getName(), $class, get_class($listener) . "->" . $method->getName() . "()"]));
}
$this->registerEvent($class, $listener, $priority, new MethodEventExecutor($method->getName()), $plugin, $ignoreCancelled);
}
}
}
}
示例5: unloadChunk
public function unloadChunk($x, $z, $safe = true, $trySave = true)
{
if ($safe === true and $this->isChunkInUse($x, $z)) {
return false;
}
if (!$this->isChunkLoaded($x, $z)) {
return true;
}
$this->timings->doChunkUnload->startTiming();
$index = Level::chunkHash($x, $z);
$chunk = $this->getChunk($x, $z);
if ($chunk !== null and $chunk->getProvider() !== null) {
$this->server->getPluginManager()->callEvent($ev = new ChunkUnloadEvent($chunk));
if ($ev->isCancelled()) {
$this->timings->doChunkUnload->stopTiming();
return false;
}
}
try {
if ($chunk !== null) {
if ($trySave and $this->getAutoSave()) {
$entities = 0;
foreach ($chunk->getEntities() as $e) {
if ($e instanceof Player) {
continue;
}
++$entities;
}
if ($chunk->hasChanged() or count($chunk->getTiles()) > 0 or $entities > 0) {
$this->provider->setChunk($x, $z, $chunk);
$this->provider->saveChunk($x, $z);
}
}
foreach ($this->getChunkLoaders($x, $z) as $loader) {
$loader->onChunkUnloaded($chunk);
}
}
$this->provider->unloadChunk($x, $z, $safe);
} catch (\Exception $e) {
$logger = $this->server->getLogger();
$logger->error($this->server->getLanguage()->translateString("pocketmine.level.chunkUnloadError", [$e->getMessage()]));
if ($logger instanceof MainLogger) {
$logger->logException($e);
}
}
unset($this->chunks[$index]);
unset($this->chunkTickList[$index]);
unset($this->chunkCache[$index]);
$this->timings->doChunkUnload->stopTiming();
return true;
}