mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 23:15:29 +00:00
Fixed EnchantCommand being retarded, close #1012
This commit is contained in:
parent
3b7fc21839
commit
5f6dc25c9f
@ -56,17 +56,6 @@ class EnchantCommand extends VanillaCommand{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$enchantId = (int) $args[1];
|
|
||||||
$enchantLevel = isset($args[2]) ? (int) $args[2] : 1;
|
|
||||||
|
|
||||||
$enchantment = Enchantment::getEnchantment($enchantId);
|
|
||||||
if(!($enchantment instanceof Enchantment)){
|
|
||||||
$sender->sendMessage(new TranslationContainer("commands.enchant.notFound", [$enchantId]));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$enchantment->setLevel($enchantLevel);
|
|
||||||
|
|
||||||
$item = $player->getInventory()->getItemInHand();
|
$item = $player->getInventory()->getItemInHand();
|
||||||
|
|
||||||
if($item->getId() <= 0){
|
if($item->getId() <= 0){
|
||||||
@ -74,6 +63,19 @@ class EnchantCommand extends VanillaCommand{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(is_numeric($args[1])){
|
||||||
|
$enchantment = Enchantment::getEnchantment((int) $args[1]);
|
||||||
|
}else{
|
||||||
|
$enchantment = Enchantment::getEnchantmentByName($args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!($enchantment instanceof Enchantment)){
|
||||||
|
$sender->sendMessage(new TranslationContainer("commands.enchant.notFound", [$args[1]]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$enchantment->setLevel((int) ($args[2] ?? 1));
|
||||||
|
|
||||||
$item->addEnchantment($enchantment);
|
$item->addEnchantment($enchantment);
|
||||||
$player->getInventory()->setItemInHand($item);
|
$player->getInventory()->setItemInHand($item);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user