diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 6c9ae2e96..017cdf993 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1104,7 +1104,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ if(!$revert and !$this->isSleeping()){ if($diff > 0.0625){ $revert = true; - $this->server->getLogger()->warning($this->getName()." moved wrongly!"); + $this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidMove", [$this->getName()])); } } }elseif($diff > 0){ @@ -1533,7 +1533,16 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $pk->difficulty = $this->server->getDifficulty(); $this->dataPacket($pk); - $this->server->getLogger()->info(TextFormat::AQUA . $this->username . TextFormat::WHITE . "[/" . $this->ip . ":" . $this->port . "] logged in with entity id " . $this->id . " at (" . $this->level->getName() . ", " . round($this->x, 4) . ", " . round($this->y, 4) . ", " . round($this->z, 4) . ")"); + $this->server->getLogger()->info($this->getServer()->getLanguage()->translateString("pocketmine.player.logIn", [ + TextFormat::AQUA . $this->username . TextFormat::WHITE, + $this->ip, + $this->port, + $this->id, + $this->level->getName(), + round($this->x, 4), + round($this->y, 4), + round($this->z, 4) + ])); $this->orderChunks(); @@ -1968,7 +1977,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ if($target instanceof Entity and $this->getGamemode() !== Player::VIEW and $this->dead !== true and $target->dead !== true){ if($target instanceof DroppedItem or $target instanceof Arrow){ $this->kick("Attempting to attack an invalid entity"); - $this->server->getLogger()->warning("Player " . $this->getName() . " tried to attack an invalid entity"); + $this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidEntity", [$this->getName()])); return; } @@ -2507,7 +2516,12 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this); $this->spawned = false; - $this->server->getLogger()->info(TextFormat::AQUA . $this->getName() . TextFormat::WHITE . "[/" . $this->ip . ":" . $this->port . "] logged out due to " . str_replace(["\n", "\r"], [" ", ""], $this->getServer()->getLanguage()->translateString($reason))); + $this->server->getLogger()->info($this->getServer()->getLanguage()->translateString("pocketmine.player.logOut", [ + TextFormat::AQUA . $this->getName() . TextFormat::WHITE, + $this->ip, + $this->port, + $this->getServer()->getLanguage()->translateString($reason) + ])); $this->windows = new \SplObjectStorage(); $this->windowIndex = []; $this->usedChunks = []; diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 8cc1cd999..e03b5ad25 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -695,10 +695,10 @@ class Server{ return $nbt->getData(); }catch(\Exception $e){ //zlib decode error / corrupt data rename($path . "$name.dat", $path . "$name.dat.bak"); - $this->logger->warning("Corrupted data found for \"" . $name . "\", creating new profile"); + $this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerCorrupted", [$name])); } }else{ - $this->logger->notice("Player data not found for \"" . $name . "\", creating new profile"); + $this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerNotFound", [$name])); } $spawn = $this->getDefaultLevel()->getSafeSpawn(); $nbt = new Compound(false, [ @@ -750,7 +750,7 @@ class Server{ $nbt["SpawnX"] = (int) $data->get("spawn")["x"]; $nbt["SpawnY"] = (int) $data->get("spawn")["y"]; $nbt["SpawnZ"] = (int) $data->get("spawn")["z"]; - $this->logger->notice("Old Player data found for \"" . $name . "\", upgrading profile"); + $this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerOld", [$name])); foreach($data->get("inventory") as $slot => $item){ if(count($item) === 3){ $nbt->Inventory[$slot + 9] = new Compound(false, [ @@ -805,7 +805,7 @@ class Server{ $nbt->setData($nbtTag); file_put_contents($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed()); }catch(\Exception $e){ - $this->logger->critical("Could not save player " . $name . ": " . $e->getMessage()); + $this->logger->critical($this->getLanguage()->translateString("pocketmine.data.saveError", [$name, $e->getMessage()])); if(\pocketmine\DEBUG > 1 and $this->logger instanceof MainLogger){ $this->logger->logException($e); } @@ -982,7 +982,7 @@ class Server{ if($this->isLevelLoaded($name)){ return true; }elseif(!$this->isLevelGenerated($name)){ - $this->logger->notice("Level \"" . $name . "\" not found"); + $this->logger->notice($this->getLanguage()->translateString("pocketmine.level.notFound", [$name])); return false; } @@ -992,7 +992,7 @@ class Server{ $provider = LevelProviderManager::getProvider($path); if($provider === null){ - $this->logger->error("Could not load level \"" . $name . "\": Unknown provider"); + $this->logger->error($this->getLanguage()->translateString("pocketmine.level.loadError", [$name, "Unknown provider"])); return false; } @@ -1004,7 +1004,8 @@ class Server{ try{ $level = new Level($this, $name, $path, $provider); }catch(\Exception $e){ - $this->logger->error("Could not load level \"" . $name . "\": " . $e->getMessage()); + + $this->logger->error($this->getLanguage()->translateString("pocketmine.level.loadError", [$name, $e->getMessage()])); if($this->logger instanceof MainLogger){ $this->logger->logException($e); } @@ -1152,7 +1153,7 @@ class Server{ $level->initLevel(); }catch(\Exception $e){ - $this->logger->error("Could not generate level \"" . $name . "\": " . $e->getMessage()); + $this->logger->error($this->getLanguage()->translateString("pocketmine.level.generateError", [$name, $e->getMessage()])); if($this->logger instanceof MainLogger){ $this->logger->logException($e); } @@ -1163,7 +1164,7 @@ class Server{ $this->getPluginManager()->callEvent(new LevelLoadEvent($level)); - $this->getLogger()->notice("Spawn terrain for level \"$name\" is being generated in the background"); + $this->getLogger()->notice($this->getLanguage()->translateString("pocketmine.level.backgroundGeneration", [$name])); $centerX = $level->getSpawnLocation()->getX() >> 4; $centerZ = $level->getSpawnLocation()->getZ() >> 4; @@ -1477,7 +1478,6 @@ class Server{ $this->console = new CommandReader(); $version = new VersionString($this->getPocketMineVersion()); - $this->logger->info("Starting Minecraft: PE server version " . TextFormat::AQUA . $this->getVersion()); $this->logger->info("Loading pocketmine.yml..."); if(!file_exists($this->dataPath . "pocketmine.yml")){ @@ -1516,6 +1516,8 @@ class Server{ ]); $this->baseLang = new BaseLang($this->getProperty("settings.settings.language", "en")); + + $this->logger->info($this->getLanguage()->translateString("pocketmine.server.start", [TextFormat::AQUA . $this->getVersion()])); ServerScheduler::$WORKERS = $this->getProperty("settings.async-workers", ServerScheduler::$WORKERS); @@ -1576,7 +1578,7 @@ class Server{ @cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion()); } - $this->logger->info("Starting Minecraft PE server on " . ($this->getIp() === "" ? "*" : $this->getIp()) . ":" . $this->getPort()); + $this->logger->info($this->getLanguage()->translateString("pocketmine.server.networkStart", [$this->getIp() === "" ? "*" : $this->getIp(), $this->getPort()])); define("BOOTUP_RANDOM", @Utils::getRandomBytes(16)); $this->serverID = Binary::readLong(substr(Utils::getUniqueID(true, $this->getIp() . $this->getPort()), 0, 8)); @@ -1585,8 +1587,13 @@ class Server{ $this->network->registerInterface(new RakLibInterface($this)); - $this->logger->info("This server is running " . $this->getName() . " version " . ($version->isDev() ? TextFormat::YELLOW : "") . $version->get(true) . TextFormat::WHITE . " \"" . $this->getCodename() . "\" (API " . $this->getApiVersion() . ")"); - $this->logger->info($this->getName() . " is distributed under the LGPL License"); + $this->logger->info($this->getLanguage()->translateString("pocketmine.server.info", [ + $this->getName(), + ($version->isDev() ? TextFormat::YELLOW : "") . $version->get(true) . TextFormat::WHITE, + $this->getCodename(), + $this->getApiVersion() + ])); + $this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()])); PluginManager::$pluginParentTimer = new TimingsHandler("** Plugins"); Timings::init(); @@ -1623,7 +1630,7 @@ class Server{ LevelProviderManager::addProvider($this, Anvil::class); LevelProviderManager::addProvider($this, McRegion::class); if(extension_loaded("leveldb")){ - $this->logger->debug("Enabling LevelDB support"); + $this->logger->debug($this->getLanguage()->translateString("pocketmine.debug.enable")); LevelProviderManager::addProvider($this, LevelDB::class); } @@ -1668,7 +1675,7 @@ class Server{ $this->properties->save(); if(!($this->getDefaultLevel() instanceof Level)){ - $this->getLogger()->emergency("No default level has been loaded"); + $this->getLogger()->emergency($this->getLanguage()->translateString("pocketmine.level.defaultError")); $this->forceShutdown(); return; @@ -2007,9 +2014,9 @@ class Server{ $this->getScheduler()->scheduleRepeatingTask(new CallbackTask([$this, "checkTicks"]), 20 * 5); - $this->logger->info("Default game type: " . $this->getLanguage()->get(self::getGamemodeString($this->getGamemode()))); + $this->logger->info($this->getLanguage()->translateString("pocketmine.server.defaultGameMode", [self::getGamemodeString($this->getGamemode())])); - $this->logger->info("Done (" . round(microtime(true) - \pocketmine\START_TIME, 3) . 's)! For help, type "help" or "?"'); + $this->logger->info($this->getLanguage()->translateString("pocketmine.server.startFinished", [round(microtime(true) - \pocketmine\START_TIME, 3)])); $this->tickProcessor(); $this->forceShutdown(); @@ -2025,7 +2032,7 @@ class Server{ public function checkTicks(){ if($this->getTicksPerSecond() < 12){ - $this->logger->warning("Can't keep up! Is the server overloaded?"); + $this->logger->warning($this->getLanguage()->translateString("pocketmine.server.tickOverload")); } } @@ -2079,15 +2086,15 @@ class Server{ ini_set("error_reporting", 0); ini_set("memory_limit", -1); //Fix error dump not dumped on memory problems - $this->logger->emergency("An unrecoverable error has occurred and the server has crashed. Creating a crash dump"); + $this->logger->emergency($this->getLanguage()->translateString("pocketmine.crash.create")); try{ $dump = new CrashDump($this); }catch(\Exception $e){ - $this->logger->critical("Could not create Crash Dump: " . $e->getMessage()); + $this->logger->critical($this->getLanguage()->translateString("pocketmine.crash.error", $e->getMessage())); return; } - $this->logger->emergency("Please submit the \"" . $dump->getPath() . "\" file to the Bug Reporting page. Give as much info as you can."); + $this->logger->emergency($this->getLanguage()->translateString("pocketmine.crash.submit", [$dump->getPath()])); if($this->getProperty("auto-report.enabled", true) !== false){ @@ -2116,7 +2123,7 @@ class Server{ if(($data = json_decode($reply)) !== false and isset($data->crashId)){ $reportId = $data->crashId; $reportUrl = $data->crashUrl; - $this->logger->emergency("The crash dump has been automatically submitted to the Crash Archive. You can view it on $reportUrl or use the ID #$reportId."); + $this->logger->emergency($this->getLanguage()->translateString("pocketmine.crash.archive", [$reportUrl, $reportId])); } } } @@ -2170,7 +2177,7 @@ class Server{ } } }catch(\Exception $e){ - $this->logger->critical("Could not tick level " . $level->getName() . ": " . $e->getMessage()); + $this->logger->critical($this->getLanguage()->translateString("pocketmine.level.tickError", [$level->getName(), $e->getMessage()])); if(\pocketmine\DEBUG > 1 and $this->logger instanceof MainLogger){ $this->logger->logException($e); } diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index fab4c0da3..5cb6a4aee 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -289,9 +289,9 @@ abstract class Command{ public static function broadcastCommandMessage(CommandSender $source, $message, $sendToSource = true){ if($message instanceof TextContainer){ $m = clone $message; - $result = "[".$source->getName().": ".$m->getText()."]"; + $result = "[".$source->getName().": ".($source->getServer()->getLanguage()->get($m->getText()) !== $m->getText() ? "%" : "") . $m->getText() ."]"; - $users = Server::getInstance()->getPluginManager()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_ADMINISTRATIVE); + $users = $source->getServer()->getPluginManager()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_ADMINISTRATIVE); $colored = TextFormat::GRAY . TextFormat::ITALIC . $result; $m->setText($result); @@ -299,7 +299,7 @@ abstract class Command{ $m->setText($colored); $colored = clone $m; }else{ - $users = Server::getInstance()->getPluginManager()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_ADMINISTRATIVE); + $users = $source->getServer()->getPluginManager()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_ADMINISTRATIVE); $result = new TranslationContainer("chat.type.admin", [$source->getName(), $message]); $colored = new TranslationContainer(TextFormat::GRAY . TextFormat::ITALIC . "%chat.type.admin", [$source->getName(), $message]); } diff --git a/src/pocketmine/command/FormattedCommandAlias.php b/src/pocketmine/command/FormattedCommandAlias.php index 3e35fb9e0..842ab59f6 100644 --- a/src/pocketmine/command/FormattedCommandAlias.php +++ b/src/pocketmine/command/FormattedCommandAlias.php @@ -21,6 +21,7 @@ namespace pocketmine\command; +use pocketmine\event\TranslationContainer; use pocketmine\Server; use pocketmine\utils\MainLogger; use pocketmine\utils\TextFormat; @@ -49,7 +50,7 @@ class FormattedCommandAlias extends Command{ if($e instanceof \InvalidArgumentException){ $sender->sendMessage(TextFormat::RED . $e->getMessage()); }else{ - $sender->sendMessage(TextFormat::RED . "An internal error occurred while attempting to perform this command"); + $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.exception")); $logger = $sender->getServer()->getLogger(); if($logger instanceof MainLogger){ $logger->logException($e); diff --git a/src/pocketmine/command/SimpleCommandMap.php b/src/pocketmine/command/SimpleCommandMap.php index 7217a041c..32fc95f8b 100644 --- a/src/pocketmine/command/SimpleCommandMap.php +++ b/src/pocketmine/command/SimpleCommandMap.php @@ -189,7 +189,7 @@ class SimpleCommandMap implements CommandMap{ $target->execute($sender, $sentCommandLabel, $args); }catch(\Exception $e){ $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.exception")); - $this->server->getLogger()->critical("Unhandled exception executing command '" . $commandLine . "' in " . $target . ": " . $e->getMessage()); + $this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.command.exception", [$commandLine, (string) $target, $e->getMessage()])); $logger = $sender->getServer()->getLogger(); if($logger instanceof MainLogger){ $logger->logException($e); @@ -232,7 +232,7 @@ class SimpleCommandMap implements CommandMap{ foreach($values as $alias => $commandStrings){ if(strpos($alias, ":") !== false or strpos($alias, " ") !== false){ - $this->server->getLogger()->warning("Could not register alias " . $alias . " because it contains illegal characters"); + $this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.command.alias.illegal", [$alias])); continue; } @@ -254,7 +254,7 @@ class SimpleCommandMap implements CommandMap{ } if(strlen($bad) > 0){ - $this->server->getLogger()->warning("Could not register alias " . $alias . " because it contains commands that do not exist: " . $bad); + $this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.command.alias.notFound", [$alias, $bad])); continue; } diff --git a/src/pocketmine/lang/BaseLang.php b/src/pocketmine/lang/BaseLang.php index ab1a8d992..497e85d9c 100644 --- a/src/pocketmine/lang/BaseLang.php +++ b/src/pocketmine/lang/BaseLang.php @@ -89,7 +89,7 @@ class BaseLang{ $baseText = $this->parseTranslation( $baseText !== null ? $baseText : $str); foreach($params as $i => $p){ - $baseText = str_replace("{%$i}", $this->parseTranslation($p), $baseText); + $baseText = str_replace("{%$i}", $this->parseTranslation((string) $p), $baseText); } return $baseText; diff --git a/src/pocketmine/lang/base/en.ini b/src/pocketmine/lang/base/en.ini index 6ccc7c109..a0902bd9f 100644 --- a/src/pocketmine/lang/base/en.ini +++ b/src/pocketmine/lang/base/en.ini @@ -183,3 +183,64 @@ commands.setworldspawn.usage=/setworldspawn [ ] commands.setworldspawn.success=Set the world spawn point to ({%0}, {%1}, {%2}) +# -------------------- PocketMine language files, only for console -------------------- + +pocketmine.data.playerNotFound=Player data not found for "{%0}", creating new profile +pocketmine.data.playerCorrupted=Corrupted data found for "{%0}", creating new profile +pocketmine.data.playerOld=Old Player data found for "{%0}", upgrading profile +pocketmine.data.saveError=Could not save player "{%0}": {%1} + +pocketmine.level.notFound=Level "{%0}" not found +pocketmine.level.loadError=Could not load level "{%0}": {%1} +pocketmine.level.generationError=Could not generate level "{%0}": {%1} +pocketmine.level.tickError=Could not tick level "{%0}": {%1} +pocketmine.level.chunkUnloadError=Error while unloading a chunk: {%0} +pocketmine.level.backgroundGeneration=Spawn terrain for level "{%0}" is being generated in the background +pocketmine.level.defaultError=No default level has been loaded +pocketmine.level.preparing=Preparing level "{%0}" +pocketmine.level.unloading=Unloading level "{%0}" + +pocketmine.server.start=Starting Minecraft: PE server version {%0} +pocketmine.server.networkError=[Network] Stopped interface {%0} due to {%1} +pocketmine.server.networkStart=Opening server on {%0}:{%1} +pocketmine.server.info=This server is running {%0} version {%1} "{%2}" (API {%3}) +pocketmine.server.license={%0} is distributed under the LGPL License +pocketmine.server.tickOverload=Can't keep up! Is the server overloaded? +pocketmine.server.startFinished=Done ({%0}s)! For help, type "help" or "?" +pocketmine.server.defaultGameMode=Default game type: {%0} +pocketmine.server.query.start=Starting GS4 status listener +pocketmine.server.query.info=Setting query port to {%0} +pocketmine.server.query.running=Query running on {%0}:{%1} + +pocketmine.command.alias.illegal=Could not register alias {%0} because it contains illegal characters +pocketmine.command.alias.notFound=Could not register alias {%0} because it contains commands that do not exist: {%1} +pocketmine.command.exception=Unhandled exception executing command '{%0}' in {%1}: {%2} + +pocketmine.crash.create=An unrecoverable error has occurred and the server has crashed. Creating a crash dump +pocketmine.crash.error=Could not create crash dump: {%0} +pocketmine.crash.submit=Please upload the "{%0}" file to the Crash Archive and submit the link to the Bug Reporting page. Give as much info as you can. +pocketmine.crash.archive=The crash dump has been automatically submitted to the Crash Archive. You can view it on {%0} or use the ID #{%1}. + +pocketmine.debug.enable=LevelDB support enabled + +pocketmine.player.invalidMove={%0} moved wrongly! +pocketmine.player.logIn={%0}[/{%1}:{%2}] logged in with entity id {%3} at ({%4}, {%5}, {%6}, {%7}) +pocketmine.player.logOut={%0}[/{%1}:{%2}] logged out due to {%3} +pocketmine.player.invalidEntity={%0} tried to attack an invalid entity + +pocketmine.plugin.load=Loading {%0} +pocketmine.plugin.enable=Enabling {%0} +pocketmine.plugin.disable=Disabling {%0} +pocketmine.plugin.restrictedName=Restricted name +pocketmine.plugin.incompatibleAPI=Incompatible API version +pocketmine.plugin.unknownDependency=Unknown dependency +pocketmine.plugin.circularDependency=Circular dependency detected +pocketmine.plugin.genericLoadError=Could not load plugin '{%0}' +pocketmine.plugin.spacesDiscouraged=Plugin '{%0}' uses spaces in its name, this is discouraged +pocketmine.plugin.loadError=Could not load plugin '{%0}': {%1} +pocketmine.plugin.duplicateError=Could not load plugin '{%0}': plugin exists +pocketmine.plugin.fileError=Could not load '{%0}' in folder '{%1}': {%2} +pocketmine.plugin.commandError=Could not load command {%0} for plugin {%1} +pocketmine.plugin.aliasError=Could not load alias {%0} for plugin {%1} +pocketmine.plugin.deprecatedEvent=Plugin '{%0}' has registered a listener for '{%1}' on method '{%2}', but the event is Deprecated. +pocketmine.plugin.eventError="Could not pass event '{%0}' to '{%1}': {%2} on {%3} diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index f990c3c2b..769a169ba 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -296,7 +296,7 @@ class Level implements ChunkManager, Metadatable{ }else{ throw new LevelException("Provider is not a subclass of LevelProvider"); } - $this->server->getLogger()->info("Preparing level \"" . $this->provider->getName() . "\""); + $this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.level.preparing", [$this->provider->getName()])); $this->generator = Generator::getGenerator($this->provider->getGenerator()); $this->blockOrder = $provider::getProviderOrder(); @@ -439,7 +439,7 @@ class Level implements ChunkManager, Metadatable{ return false; } - $this->server->getLogger()->info("Unloading level \"" . $this->getName() . "\""); + $this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.level.unloading", [$this->getName()])); $defaultLevel = $this->server->getDefaultLevel(); foreach($this->getPlayers() as $player){ if($this === $defaultLevel or $defaultLevel === null){ @@ -2133,7 +2133,7 @@ class Level implements ChunkManager, Metadatable{ $this->provider->unloadChunk($x, $z, $safe); }catch(\Exception $e){ $logger = $this->server->getLogger(); - $logger->error("Error when unloading a chunk: " . $e->getMessage()); + $logger->error($this->server->getLanguage()->translateString("pocketmine.level.chunkUnloadError", [$e->getMessage()])); if($logger instanceof MainLogger){ $logger->logException($e); } diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index 86890343e..ff66f0fb5 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -144,7 +144,7 @@ class Network{ $interface->emergencyShutdown(); $this->unregisterInterface($interface); - $logger->critical("[Network] Stopped interface ". get_class($interface) ." due to ". $e->getMessage()); + $logger->critical($this->server->getLanguage()->translateString("pocketmine.server.networkError", [get_class($interface), $e->getMessage()])); } } } diff --git a/src/pocketmine/network/query/QueryHandler.php b/src/pocketmine/network/query/QueryHandler.php index 750f5e0ca..bd6d0a73c 100644 --- a/src/pocketmine/network/query/QueryHandler.php +++ b/src/pocketmine/network/query/QueryHandler.php @@ -38,10 +38,10 @@ class QueryHandler{ public function __construct(){ $this->server = Server::getInstance(); - $this->server->getLogger()->info("Starting GS4 status listener"); + $this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.server.query.start")); $addr = ($ip = $this->server->getIp()) != "" ? $ip : "0.0.0.0"; $port = $this->server->getPort(); - $this->server->getLogger()->info("Setting query port to $port"); + $this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.server.query.info", [$port])); /* The Query protocol is built on top of the existing Minecraft PE UDP network stack. Because the 0xFE packet does not exist in the MCPE protocol, @@ -54,7 +54,7 @@ class QueryHandler{ $this->regenerateToken(); $this->lastToken = $this->token; $this->regenerateInfo(); - $this->server->getLogger()->info("Query running on $addr:$port"); + $this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.server.query.running", [$addr, $port])); } public function regenerateInfo(){ @@ -86,7 +86,7 @@ class QueryHandler{ $reply .= Binary::writeInt($sessionID); $reply .= self::getTokenString($this->token, $address) . "\x00"; - $this->server->sendPacket($address, $port, $reply); + $this->server->getNetwork()->sendPacket($address, $port, $reply); break; case self::STATISTICS: //Stat $token = Binary::readInt(substr($payload, 0, 4)); @@ -105,7 +105,7 @@ class QueryHandler{ }else{ $reply .= $this->shortData; } - $this->server->sendPacket($address, $port, $reply); + $this->server->getNetwork()->sendPacket($address, $port, $reply); break; } } diff --git a/src/pocketmine/plugin/PharPluginLoader.php b/src/pocketmine/plugin/PharPluginLoader.php index 78d1bfe85..164d1f248 100644 --- a/src/pocketmine/plugin/PharPluginLoader.php +++ b/src/pocketmine/plugin/PharPluginLoader.php @@ -52,7 +52,7 @@ class PharPluginLoader implements PluginLoader{ */ public function loadPlugin($file){ if(($description = $this->getPluginDescription($file)) instanceof PluginDescription){ - $this->server->getLogger()->info("Loading " . $description->getFullName()); + $this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.plugin.load", [$description->getFullName()])); $dataFolder = dirname($file) . DIRECTORY_SEPARATOR . $description->getName(); if(file_exists($dataFolder) and !is_dir($dataFolder)){ throw new \InvalidStateException("Projected dataFolder '" . $dataFolder . "' for " . $description->getName() . " exists and is not a directory"); @@ -118,7 +118,7 @@ class PharPluginLoader implements PluginLoader{ */ public function enablePlugin(Plugin $plugin){ if($plugin instanceof PluginBase and !$plugin->isEnabled()){ - $this->server->getLogger()->info("Enabling " . $plugin->getDescription()->getFullName()); + $this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.plugin.enable", [$plugin->getDescription()->getFullName()])); $plugin->setEnabled(true); @@ -131,7 +131,7 @@ class PharPluginLoader implements PluginLoader{ */ public function disablePlugin(Plugin $plugin){ if($plugin instanceof PluginBase and $plugin->isEnabled()){ - $this->server->getLogger()->info("Disabling " . $plugin->getDescription()->getFullName()); + $this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.plugin.disable", [$plugin->getDescription()->getFullName()])); $this->server->getPluginManager()->callEvent(new PluginDisableEvent($plugin)); diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index 5e7ff091a..168f93d0d 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -201,14 +201,14 @@ class PluginManager{ if($description instanceof PluginDescription){ $name = $description->getName(); if(stripos($name, "pocketmine") !== false or stripos($name, "minecraft") !== false or stripos($name, "mojang") !== false){ - $this->server->getLogger()->error("Could not load plugin '" . $name . "': restricted name"); + $this->server->getLogger()->error($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [$name, "%pocketmine.plugin.restrictedName"])); continue; }elseif(strpos($name, " ") !== false){ - $this->server->getLogger()->warning("Plugin '" . $name . "' uses spaces in its name, this is discouraged"); + $this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.plugin.spacesDiscouraged", [$name])); } if(isset($plugins[$name]) or $this->getPlugin($name) instanceof Plugin){ - $this->server->getLogger()->error("Could not load duplicate plugin '" . $name . "': plugin exists"); + $this->server->getLogger()->error($this->server->getLanguage()->translateString("pocketmine.plugin.duplicateError", [$name])); continue; } @@ -232,7 +232,7 @@ class PluginManager{ } if($compatible === false){ - $this->server->getLogger()->error("Could not load plugin '" . $name . "': API version not compatible"); + $this->server->getLogger()->error($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [$name, "%pocketmine.plugin.incompatibleAPI"])); continue; } @@ -250,7 +250,7 @@ class PluginManager{ } } }catch(\Exception $e){ - $this->server->getLogger()->error("Could not load '" . $file . "' in folder '" . $directory . "': " . $e->getMessage()); + $this->server->getLogger()->error($this->server->getLanguage()->translateString("pocketmine.plugin.fileError", [$file, $directory, $e->getMessage()])); $logger = $this->server->getLogger(); if($logger instanceof MainLogger){ $logger->logException($e); @@ -268,7 +268,7 @@ class PluginManager{ if(isset($loadedPlugins[$dependency]) or $this->getPlugin($dependency) instanceof Plugin){ unset($dependencies[$name][$key]); }elseif(!isset($plugins[$dependency])){ - $this->server->getLogger()->critical("Could not load plugin '" . $name . "': Unknown dependency"); + $this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [$name, "%pocketmine.plugin.unknownDependency"])); break; } } @@ -296,7 +296,7 @@ class PluginManager{ if($plugin = $this->loadPlugin($file, $loaders) and $plugin instanceof Plugin){ $loadedPlugins[$name] = $plugin; }else{ - $this->server->getLogger()->critical("Could not load plugin '" . $name . "'"); + $this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.plugin.genericLoadError", [$name])); } } } @@ -310,7 +310,7 @@ class PluginManager{ if($plugin = $this->loadPlugin($file, $loaders) and $plugin instanceof Plugin){ $loadedPlugins[$name] = $plugin; }else{ - $this->server->getLogger()->critical("Could not load plugin '" . $name . "'"); + $this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.plugin.genericLoadError", [$name])); } } } @@ -318,7 +318,7 @@ class PluginManager{ //No plugins loaded :( if($missingDependency === true){ foreach($plugins as $name => $file){ - $this->server->getLogger()->critical("Could not load plugin '" . $name . "': circular dependency detected"); + $this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [$name, "%pocketmine.plugin.circularDependency"])); } $plugins = []; } @@ -577,7 +577,7 @@ class PluginManager{ foreach($plugin->getDescription()->getCommands() as $key => $data){ if(strpos($key, ":") !== false){ - $this->server->getLogger()->critical("Could not load command " . $key . " for plugin " . $plugin->getDescription()->getName()); + $this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.plugin.commandError", [$key, $plugin->getDescription()->getFullName()])); continue; } if(is_array($data)){ @@ -594,7 +594,7 @@ class PluginManager{ $aliasList = []; foreach($data["aliases"] as $alias){ if(strpos($alias, ":") !== false){ - $this->server->getLogger()->critical("Could not load alias " . $alias . " for plugin " . $plugin->getDescription()->getName()); + $this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.plugin.aliasError", [$alias, $plugin->getDescription()->getFullName()])); continue; } $aliasList[] = $alias; @@ -669,7 +669,13 @@ class PluginManager{ try{ $registration->callEvent($event); }catch(\Exception $e){ - $this->server->getLogger()->critical("Could not pass event " . $event->getEventName() . " to " . $registration->getPlugin()->getDescription()->getFullName() . ": " . $e->getMessage() . " on " . get_class($registration->getListener())); + $this->server->getLogger()->critical( + $this->server->getLanguage()->translateString("pocketmine.plugin.eventError", [ + $event->getEventName(), + $registration->getPlugin()->getDescription()->getFullName(), + $e->getMessage(), + get_class($registration->getListener()) + ])); $logger = $this->server->getLogger(); if($logger instanceof MainLogger){ $logger->logException($e); @@ -716,7 +722,11 @@ class PluginManager{ $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('Plugin ' . $plugin->getName() . ' has registered a listener for ' . $class . ' on method ' . get_class($listener) . '->' . $method->getName() . '(), but the event is Deprecated.'); + $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); }