Added KnownTranslationFactory and use it in as many places as possible

this makes translation usage much more statically analysable.
The only places this isn't used are:
- places that prefix translations with colours (those are still a problem)
- places where server/client translations don't match (e.g. gameMode.changed accepts different parameters in vanilla than in PM)
This commit is contained in:
Dylan K. Taylor
2021-08-10 14:50:40 +01:00
parent d39080c45a
commit 2293bd948d
52 changed files with 2185 additions and 372 deletions

View File

@@ -27,6 +27,7 @@ use pocketmine\command\CommandSender;
use pocketmine\command\utils\InvalidCommandSyntaxException;
use pocketmine\item\enchantment\EnchantmentInstance;
use pocketmine\item\enchantment\VanillaEnchantments;
use pocketmine\lang\KnownTranslationFactory;
use pocketmine\lang\KnownTranslationKeys;
use pocketmine\lang\TranslationContainer;
use pocketmine\permission\DefaultPermissionNames;
@@ -63,14 +64,14 @@ class EnchantCommand extends VanillaCommand{
$item = $player->getInventory()->getItemInHand();
if($item->isNull()){
$sender->sendMessage(new TranslationContainer(KnownTranslationKeys::COMMANDS_ENCHANT_NOITEM));
$sender->sendMessage(KnownTranslationFactory::commands_enchant_noItem());
return true;
}
try{
$enchantment = VanillaEnchantments::fromString($args[1]);
}catch(\InvalidArgumentException $e){
$sender->sendMessage(new TranslationContainer(KnownTranslationKeys::COMMANDS_ENCHANT_NOTFOUND, [$args[1]]));
$sender->sendMessage(KnownTranslationFactory::commands_enchant_notFound($args[1]));
return true;
}