From 87c4f318a41da126c06145cb484ac0b397641fd4 Mon Sep 17 00:00:00 2001 From: Glitchfinder Date: Wed, 31 Oct 2012 12:39:04 -0700 Subject: [PATCH] Fixing fishing a bit. --- .../com/gmail/nossr50/skills/gathering/Fishing.java | 6 +++--- src/main/java/com/gmail/nossr50/util/ItemChecks.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java index 24e837814..12aef4cd5 100755 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java @@ -153,7 +153,7 @@ public class Fishing { player.sendMessage(LocaleLoader.getString("Fishing.ItemFound")); - if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) { + if (ItemChecks.isEnchantable(fishingResults)) { int randomChance = 100; if (player.hasPermission("mcmmo.perks.lucky.fishing")) { @@ -205,7 +205,7 @@ public class Fishing { randomChance = (int) (randomChance * 0.75); } - final int DROP_NUMBER = random.nextInt(randomChance); + final int DROP_NUMBER = random.nextInt(randomChance) + 1; LivingEntity le = (LivingEntity) event.getCaught(); EntityType type = le.getType(); @@ -385,7 +385,7 @@ public class Fishing { break; case WITCH: - final int DROP_NUMBER_2 = random.nextInt(randomChance); + final int DROP_NUMBER_2 = random.nextInt(randomChance) + 1; if (DROP_NUMBER > 97) { if(DROP_NUMBER_2 > 66) { Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8197)); diff --git a/src/main/java/com/gmail/nossr50/util/ItemChecks.java b/src/main/java/com/gmail/nossr50/util/ItemChecks.java index 429d5e8d5..3e195b922 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ItemChecks.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.util; import org.bukkit.inventory.ItemStack; +import org.bukkit.Material; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.api.SpoutToolsAPI; @@ -463,4 +464,14 @@ public class ItemChecks { return false; } } + + /** + * Checks to see if an item is enchantable. + * + * @param is Item to check + * @return true if the item is enchantable, false otherwise + */ + public static boolean isEnchantable(ItemStack is) { + return isArmor(is) || isSword(is) || isAxe(is) || isShovel(is) || isPickaxe(is) || (is.getType() == Material.BOW); + } }