From 34276539fa72fc0cf62f3f8c651e998bfcf6baca Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 22 Dec 2012 10:11:18 +0100 Subject: [PATCH] Got rid of reflection code, now uses Bukkit method to check if witherskeleton --- .../nossr50/skills/gathering/Fishing.java | 28 ++++--------------- 1 file changed, 5 insertions(+), 23 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 858464fb5..f140306e8 100755 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java @@ -14,8 +14,11 @@ import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Sheep; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.material.MaterialData; import org.bukkit.material.Wool; import com.gmail.nossr50.config.AdvancedConfig; @@ -337,28 +340,7 @@ public class Fishing { break; case SKELETON: - Object o; - Class c; - Method m; - - o = le; - c = o.getClass(); - - boolean isWitherSkeleton = false; - - try { - m = c.getDeclaredMethod("getHandle"); - o = m.invoke(o); - - c = o.getClass(); - m = c.getDeclaredMethod("getSkeletonType"); - o = m.invoke(o); - - if(o instanceof Integer) - isWitherSkeleton = (((Integer) o) == 1); - } catch(Exception e) {} - - if (isWitherSkeleton) { + if (((Skeleton)le).getSkeletonType() == SkeletonType.WITHER) { if (DROP_NUMBER > 95) { Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 1)); } else if (DROP_NUMBER > 50) { @@ -401,7 +383,7 @@ public class Fishing { break; case SQUID: - Misc.dropItem(location, new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x0)); + Misc.dropItem(location, new ItemStack(new MaterialData(Material.INK_SACK, (byte) 0).toItemStack())); break; case WITCH: