Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2163 from Infernus102/patch-3
Browse files Browse the repository at this point in the history
Enchantment max level condition
  • Loading branch information
ishitatsuyuki authored Nov 6, 2016
2 parents 3a7789b + 10c9eb5 commit 017fa6f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pocketmine/command/defaults/EnchantCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ public function execute(CommandSender $sender, $currentAlias, array $args){
return true;
}
}

$id = $enchantment->getId();
$maxLevel = Enchantment::getEnchantMaxLevel($id);
if($enchantLevel > $maxLevel or $enchantLevel <= 0){
$sender->sendMessage(new TranslationContainer("commands.enchant.maxLevel", [$maxLevel]));
return true;
}
$enchantment->setLevel($enchantLevel);

$item = $player->getInventory()->getItemInHand();
Expand Down
1 change: 1 addition & 0 deletions src/pocketmine/lang/locale/eng.ini
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ commands.effect.success.removed.all=Took all effects from {%0}
commands.effect.failure.notActive=Couldn't take {%0} from {%1} as they do not have the effect
commands.effect.failure.notActive.all=Couldn't take any effects from {%0} as they do not have any

commands.enchant.maxLevel=Level Range of that enchantment is 1 - {%0}
commands.enchant.noItem=The target is not holding an item
commands.enchant.notFound=There is no such enchantment with ID {%0}
commands.enchant.success=Enchanting succeeded
Expand Down

0 comments on commit 017fa6f

Please sign in to comment.