From 4511dd79fa095e020d906d13f58f51003e6b1e00 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 22 Dec 2012 10:10:54 +0100 Subject: [PATCH 1/7] Now uses proper gamemode check and uses Misc.dropItem --- .../java/com/gmail/nossr50/skills/repair/Salvage.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java index a67fea83b..e2bfa534e 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java @@ -1,8 +1,8 @@ package com.gmail.nossr50.skills.repair; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.getspout.spoutapi.SpoutManager; @@ -14,6 +14,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.ItemChecks; +import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; @@ -27,13 +28,12 @@ public class Salvage { return; } - if (player.getGameMode().equals(0)){ + if(player.getGameMode() == GameMode.SURVIVAL) { final PlayerProfile profile = Users.getProfile(player); final int skillLevel = profile.getSkillLevel(SkillType.REPAIR); final int unlockLevel = configInstance.getSalvageUnlockLevel(); if (skillLevel >= unlockLevel) { - final World world = player.getWorld(); final float currentdura = inHand.getDurability(); if (currentdura == 0) { @@ -42,7 +42,7 @@ public class Salvage { player.setItemInHand(new ItemStack(0)); location.setY(location.getY() + 1); - world.dropItem(location, new ItemStack(itemID, salvagedAmount)); + Misc.dropItem(location, new ItemStack(itemID, salvagedAmount)); player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess")); } else { player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability")); From 34276539fa72fc0cf62f3f8c651e998bfcf6baca Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 22 Dec 2012 10:11:18 +0100 Subject: [PATCH 2/7] 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: From e0bba80f55929cb09d39d4fc7ae4370d9ddfd9da Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 22 Dec 2012 11:17:48 +0100 Subject: [PATCH 3/7] Made skulls drops more rare. --- .../java/com/gmail/nossr50/skills/gathering/Fishing.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 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 f140306e8..46410e2a5 100755 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.gathering; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -264,7 +263,7 @@ public class Fishing { break; case CREEPER: - if (DROP_NUMBER > 95) { + if (DROP_NUMBER > 98) { Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 4)); } else { Misc.dropItem(location, new ItemStack(Material.SULPHUR)); @@ -341,7 +340,7 @@ public class Fishing { case SKELETON: if (((Skeleton)le).getSkeletonType() == SkeletonType.WITHER) { - if (DROP_NUMBER > 95) { + if (DROP_NUMBER > 98) { Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 1)); } else if (DROP_NUMBER > 50) { Misc.dropItem(location, new ItemStack(Material.BONE)); @@ -350,7 +349,7 @@ public class Fishing { Misc.randomDropItems(location, new ItemStack(Material.COAL), 50, 2); } } else { - if (DROP_NUMBER > 95) { + if (DROP_NUMBER > 98) { Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM)); } else if (DROP_NUMBER > 50) { Misc.dropItem(location, new ItemStack(Material.BONE)); @@ -418,7 +417,7 @@ public class Fishing { break; case ZOMBIE: - if (DROP_NUMBER > 95) { + if (DROP_NUMBER > 98) { Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 2)); } else { Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH)); From 01142b67c61a57eafd10ce338daac42bbf123491 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sun, 23 Dec 2012 00:00:29 +0100 Subject: [PATCH 4/7] Changed skull drop rates to 3% --- .../java/com/gmail/nossr50/skills/gathering/Fishing.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 46410e2a5..9c5596ce0 100755 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java @@ -263,7 +263,7 @@ public class Fishing { break; case CREEPER: - if (DROP_NUMBER > 98) { + if (DROP_NUMBER > 97) { Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 4)); } else { Misc.dropItem(location, new ItemStack(Material.SULPHUR)); @@ -340,7 +340,7 @@ public class Fishing { case SKELETON: if (((Skeleton)le).getSkeletonType() == SkeletonType.WITHER) { - if (DROP_NUMBER > 98) { + if (DROP_NUMBER > 97) { Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 1)); } else if (DROP_NUMBER > 50) { Misc.dropItem(location, new ItemStack(Material.BONE)); @@ -349,7 +349,7 @@ public class Fishing { Misc.randomDropItems(location, new ItemStack(Material.COAL), 50, 2); } } else { - if (DROP_NUMBER > 98) { + if (DROP_NUMBER > 97) { Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM)); } else if (DROP_NUMBER > 50) { Misc.dropItem(location, new ItemStack(Material.BONE)); @@ -417,7 +417,7 @@ public class Fishing { break; case ZOMBIE: - if (DROP_NUMBER > 98) { + if (DROP_NUMBER > 97) { Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 2)); } else { Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH)); From 8a97718dd4016c2ad3e2972079492692c1b178a1 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sun, 23 Dec 2012 18:44:39 +0100 Subject: [PATCH 5/7] Don't use MaterialData when its not needed. --- src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9c5596ce0..a01a092ea 100755 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java @@ -382,7 +382,7 @@ public class Fishing { break; case SQUID: - Misc.dropItem(location, new ItemStack(new MaterialData(Material.INK_SACK, (byte) 0).toItemStack())); + Misc.dropItem(location, new ItemStack(Material.INK_SACK, 1, (short) 0)); break; case WITCH: From bb1dbab984a555fe2377436cf6a0eb59384eb5cf Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sun, 23 Dec 2012 22:05:10 +0100 Subject: [PATCH 6/7] Iron golem and Snowman pumpkin drop rates are now 3% for the sake of consistency --- .../java/com/gmail/nossr50/skills/gathering/Fishing.java | 5 ++--- 1 file changed, 2 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 a01a092ea..f110636aa 100755 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java @@ -17,7 +17,6 @@ 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; @@ -283,7 +282,7 @@ public class Fishing { break; case IRON_GOLEM: - if (DROP_NUMBER > 95) { + if (DROP_NUMBER > 97) { Misc.dropItem(location, new ItemStack(Material.PUMPKIN)); } else if (DROP_NUMBER > 85) { Misc.dropItem(location, new ItemStack(Material.IRON_INGOT)); @@ -365,7 +364,7 @@ public class Fishing { break; case SNOWMAN: - if (DROP_NUMBER > 95) { + if (DROP_NUMBER > 97) { Misc.dropItem(location, new ItemStack(Material.PUMPKIN)); } else { Misc.dropItem(location, new ItemStack(Material.SNOW_BALL)); From cdb5fed5a5308b2303f64f3e1421222761da509c Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Mon, 24 Dec 2012 13:00:50 +0100 Subject: [PATCH 7/7] Changed bonus to float Fixes bug where only 1 diamond was needed to fully repair an almost broken diamond pickaxe --- src/main/java/com/gmail/nossr50/mcMMO.java | 2 -- src/main/java/com/gmail/nossr50/skills/repair/Repair.java | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 849ccada0..53bb4f5a7 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -14,8 +14,6 @@ import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitScheduler; -import org.bukkit.World; - import com.gmail.nossr50.commands.general.AddlevelsCommand; import com.gmail.nossr50.commands.general.AddxpCommand; import com.gmail.nossr50.commands.general.InspectCommand; diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java index 87ac93bdf..eeedf2e9b 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -210,12 +210,12 @@ public class Repair { * @return The final amount of durability repaired to the item */ protected static short repairCalculate(Player player, int skillLevel, short durability, int repairAmount) { - double bonus; - if(skillLevel >= repairMasteryMaxBonusLevel) bonus = (double) repairMasteryChanceMax; - else bonus = ((double) skillLevel / (double) repairMasteryMaxBonusLevel) * (double) repairMasteryChanceMax; + float bonus; + if(skillLevel >= repairMasteryMaxBonusLevel) bonus = repairMasteryChanceMax; + else bonus = (skillLevel / repairMasteryMaxBonusLevel) * repairMasteryChanceMax; if (permInstance.repairMastery(player)) { - bonus = ((double) repairAmount * bonus); + bonus = (repairAmount * bonus); repairAmount += (int) bonus; }