From 9b24dd306c1a79b271dec4205ed4a2fbf7cc4d6a Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Wed, 4 Nov 2015 13:35:25 -0500 Subject: [PATCH] Actually use Hylian Treasure config values. Fixes #2688 --- .../skills/herbalism/HerbalismManager.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 61396112c..6131c5ae4 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.List; import org.bukkit.CropState; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.NetherWartsState; import org.bukkit.block.BlockState; @@ -235,15 +236,24 @@ public class HerbalismManager extends SkillManager { Player player = getPlayer(); - if (treasures.isEmpty() || !EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) { + if (treasures.isEmpty()) { return false; } + int skillLevel = getSkillLevel(); + Location location = blockState.getLocation(); - blockState.setType(Material.AIR); - - Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop()); - player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck")); - return true; + for (HylianTreasure treasure : treasures) { + if (skillLevel >= treasure.getDropLevel() && SkillUtils.treasureDropSuccessful(getPlayer(), treasure.getDropChance(), activationChance)) { + if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) { + return false; + } + blockState.setType(Material.AIR); + Misc.dropItem(location, treasure.getDrop()); + player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck")); + return true; + } + } + return false; } /**