PluginBase: Improved error messages for commands containing illegal characters

This commit is contained in:
Dylan K. Taylor 2021-11-12 00:16:53 +00:00
parent 3276047497
commit e4754ab029
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
4 changed files with 14 additions and 12 deletions

View File

@ -41,7 +41,7 @@
"pocketmine/classloader": "^0.2.0", "pocketmine/classloader": "^0.2.0",
"pocketmine/color": "^0.2.0", "pocketmine/color": "^0.2.0",
"pocketmine/errorhandler": "^0.3.0", "pocketmine/errorhandler": "^0.3.0",
"pocketmine/locale-data": "^1.1.4", "pocketmine/locale-data": "^2.0.16",
"pocketmine/log": "^0.4.0", "pocketmine/log": "^0.4.0",
"pocketmine/log-pthreads": "^0.4.0", "pocketmine/log-pthreads": "^0.4.0",
"pocketmine/math": "^0.4.0", "pocketmine/math": "^0.4.0",

14
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "4f8e023ae390414fb40b77857c16ebee", "content-hash": "7787453a7902c21ea0d15aee34b12019",
"packages": [ "packages": [
{ {
"name": "adhocore/json-comment", "name": "adhocore/json-comment",
@ -533,16 +533,16 @@
}, },
{ {
"name": "pocketmine/locale-data", "name": "pocketmine/locale-data",
"version": "1.1.6", "version": "2.0.16",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pmmp/Language.git", "url": "https://github.com/pmmp/Language.git",
"reference": "216b49b87e20332f0b39d1717e1e2012a40074cc" "reference": "8bd74825ac685446f67ea20999ce756a2acd5a30"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pmmp/Language/zipball/216b49b87e20332f0b39d1717e1e2012a40074cc", "url": "https://api.github.com/repos/pmmp/Language/zipball/8bd74825ac685446f67ea20999ce756a2acd5a30",
"reference": "216b49b87e20332f0b39d1717e1e2012a40074cc", "reference": "8bd74825ac685446f67ea20999ce756a2acd5a30",
"shasum": "" "shasum": ""
}, },
"type": "library", "type": "library",
@ -550,9 +550,9 @@
"description": "Language resources used by PocketMine-MP", "description": "Language resources used by PocketMine-MP",
"support": { "support": {
"issues": "https://github.com/pmmp/Language/issues", "issues": "https://github.com/pmmp/Language/issues",
"source": "https://github.com/pmmp/Language/tree/1.1.6" "source": "https://github.com/pmmp/Language/tree/2.0.16"
}, },
"time": "2021-11-07T14:30:46+00:00" "time": "2021-11-12T00:10:09+00:00"
}, },
{ {
"name": "pocketmine/log", "name": "pocketmine/log",

View File

@ -1666,10 +1666,11 @@ final class KnownTranslationFactory{
]); ]);
} }
public static function pocketmine_plugin_aliasError(Translatable|string $param0, Translatable|string $param1) : Translatable{ public static function pocketmine_plugin_aliasError(Translatable|string $param0, Translatable|string $param1, Translatable|string $param2) : Translatable{
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_ALIASERROR, [ return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_ALIASERROR, [
0 => $param0, 0 => $param0,
1 => $param1, 1 => $param1,
2 => $param2,
]); ]);
} }
@ -1689,10 +1690,11 @@ final class KnownTranslationFactory{
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_CIRCULARDEPENDENCY, []); return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_CIRCULARDEPENDENCY, []);
} }
public static function pocketmine_plugin_commandError(Translatable|string $param0, Translatable|string $param1) : Translatable{ public static function pocketmine_plugin_commandError(Translatable|string $param0, Translatable|string $param1, Translatable|string $param2) : Translatable{
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_COMMANDERROR, [ return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_COMMANDERROR, [
0 => $param0, 0 => $param0,
1 => $param1, 1 => $param1,
2 => $param2,
]); ]);
} }

View File

@ -164,7 +164,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{
foreach($this->getDescription()->getCommands() as $key => $data){ foreach($this->getDescription()->getCommands() as $key => $data){
if(strpos($key, ":") !== false){ if(strpos($key, ":") !== false){
$this->logger->error($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_commandError($key, $this->getDescription()->getFullName()))); $this->logger->error($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_commandError($key, $this->getDescription()->getFullName(), ":")));
continue; continue;
} }
@ -180,7 +180,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{
$aliasList = []; $aliasList = [];
foreach($data->getAliases() as $alias){ foreach($data->getAliases() as $alias){
if(strpos($alias, ":") !== false){ if(strpos($alias, ":") !== false){
$this->logger->error($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_aliasError($alias, $this->getDescription()->getFullName()))); $this->logger->error($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_aliasError($alias, $this->getDescription()->getFullName(), ":")));
continue; continue;
} }
$aliasList[] = $alias; $aliasList[] = $alias;