mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
Added new dynamic StringToEnchantmentParser
this should be used instead of VanillaEnchantments::fromString(), because it allows registering custom aliases.
This commit is contained in:
@ -26,7 +26,7 @@ namespace pocketmine\command\defaults;
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\command\utils\InvalidCommandSyntaxException;
|
||||
use pocketmine\item\enchantment\EnchantmentInstance;
|
||||
use pocketmine\item\enchantment\VanillaEnchantments;
|
||||
use pocketmine\item\enchantment\StringToEnchantmentParser;
|
||||
use pocketmine\lang\KnownTranslationFactory;
|
||||
use pocketmine\permission\DefaultPermissionNames;
|
||||
use pocketmine\utils\TextFormat;
|
||||
@ -66,9 +66,8 @@ class EnchantCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
try{
|
||||
$enchantment = VanillaEnchantments::fromString($args[1]);
|
||||
}catch(\InvalidArgumentException $e){
|
||||
$enchantment = StringToEnchantmentParser::getInstance()->parse($args[1]);
|
||||
if($enchantment === null){
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_enchant_notFound($args[1]));
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user