mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-20 18:31:23 +00:00
Handle InvalidArgumentException thrown by VanillaEnchantments::fromString (#3878)
This commit is contained in:
parent
9947e13121
commit
3b632a8deb
@ -69,14 +69,18 @@ class EnchantCommand extends VanillaCommand{
|
|||||||
|
|
||||||
if(is_numeric($args[1])){
|
if(is_numeric($args[1])){
|
||||||
$enchantment = VanillaEnchantments::byMcpeId((int) $args[1]);
|
$enchantment = VanillaEnchantments::byMcpeId((int) $args[1]);
|
||||||
}else{
|
|
||||||
$enchantment = VanillaEnchantments::fromString($args[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!($enchantment instanceof Enchantment)){
|
if(!($enchantment instanceof Enchantment)){
|
||||||
$sender->sendMessage(new TranslationContainer("commands.enchant.notFound", [$args[1]]));
|
$sender->sendMessage(new TranslationContainer("commands.enchant.notFound", [$args[1]]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
try{
|
||||||
|
$enchantment = VanillaEnchantments::fromString($args[1]);
|
||||||
|
}catch(\InvalidArgumentException $e){
|
||||||
|
$sender->sendMessage(new TranslationContainer("commands.enchant.notFound", [$args[1]]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$level = 1;
|
$level = 1;
|
||||||
if(isset($args[2])){
|
if(isset($args[2])){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user