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/color": "^0.2.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-pthreads": "^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",
"This file is @generated automatically"
],
"content-hash": "4f8e023ae390414fb40b77857c16ebee",
"content-hash": "7787453a7902c21ea0d15aee34b12019",
"packages": [
{
"name": "adhocore/json-comment",
@ -533,16 +533,16 @@
},
{
"name": "pocketmine/locale-data",
"version": "1.1.6",
"version": "2.0.16",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Language.git",
"reference": "216b49b87e20332f0b39d1717e1e2012a40074cc"
"reference": "8bd74825ac685446f67ea20999ce756a2acd5a30"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Language/zipball/216b49b87e20332f0b39d1717e1e2012a40074cc",
"reference": "216b49b87e20332f0b39d1717e1e2012a40074cc",
"url": "https://api.github.com/repos/pmmp/Language/zipball/8bd74825ac685446f67ea20999ce756a2acd5a30",
"reference": "8bd74825ac685446f67ea20999ce756a2acd5a30",
"shasum": ""
},
"type": "library",
@ -550,9 +550,9 @@
"description": "Language resources used by PocketMine-MP",
"support": {
"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",

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, [
0 => $param0,
1 => $param1,
2 => $param2,
]);
}
@ -1689,10 +1690,11 @@ final class KnownTranslationFactory{
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, [
0 => $param0,
1 => $param1,
2 => $param2,
]);
}

View File

@ -164,7 +164,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{
foreach($this->getDescription()->getCommands() as $key => $data){
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;
}
@ -180,7 +180,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{
$aliasList = [];
foreach($data->getAliases() as $alias){
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;
}
$aliasList[] = $alias;