diff --git a/plugin/src/lightling/gibsoniacraft/util/BlockListener.java b/plugin/src/lightling/gibsoniacraft/util/BlockListener.java index 85bdd3e..b5d158f 100644 --- a/plugin/src/lightling/gibsoniacraft/util/BlockListener.java +++ b/plugin/src/lightling/gibsoniacraft/util/BlockListener.java @@ -90,10 +90,21 @@ public class BlockListener implements Listener Material blockMat = b.getType(); // Handle Fortune enchantment - if (enchantments.containsKey(Enchantment.LOOT_BONUS_BLOCKS) && ham && BlockRef.ValidHammerFortune.contains(blockMat) - || enchantments.containsKey(Enchantment.LOOT_BONUS_BLOCKS) && exc && BlockRef.ValidExcavatorFortune.contains(blockMat)) + if (enchantments.containsKey(Enchantment.LOOT_BONUS_BLOCKS) && ham && BlockRef.ValidHammerFortune.containsKey(blockMat) + || enchantments.containsKey(Enchantment.LOOT_BONUS_BLOCKS) && exc && BlockRef.ValidExcavatorFortune.containsKey(blockMat)) { double level = tool.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS); + Material drop; + + // Determine drop + if (ham) + { + drop = BlockRef.ValidHammerFortune.get(blockMat); + } + else + { + drop = BlockRef.ValidExcavatorFortune.get(blockMat); + } // Wiki: "Fortune I gives a 33% chance to multiply drops by 2" if (level == 1) @@ -101,7 +112,7 @@ public class BlockListener implements Listener double rng = (Math.random() * 100) + 1; if (rng >= 0 && rng < 33) { - b.getWorld().dropItemNaturally(blockLoc, new ItemStack(blockMat)); + b.getWorld().dropItemNaturally(blockLoc, new ItemStack(drop)); b.setType(Material.AIR); } @@ -117,14 +128,13 @@ public class BlockListener implements Listener double rng = (Math.random() * 100) + 1; if (rng >= 0 && rng < 25) { - b.getWorld().dropItemNaturally(blockLoc, new ItemStack(blockMat)); + b.getWorld().dropItemNaturally(blockLoc, new ItemStack(drop, 1)); b.setType(Material.AIR); } else if (rng >= 25 && rng < 50) { - b.getWorld().dropItemNaturally(blockLoc, new ItemStack(blockMat)); - b.getWorld().dropItemNaturally(blockLoc, new ItemStack(blockMat)); + b.getWorld().dropItemNaturally(blockLoc, new ItemStack(drop, 2)); b.setType(Material.AIR); } @@ -140,22 +150,19 @@ public class BlockListener implements Listener double rng = (Math.random() * 100) + 1; if (rng >= 0 && rng < 20) { - b.getWorld().dropItemNaturally(blockLoc, new ItemStack(blockMat)); + b.getWorld().dropItemNaturally(blockLoc, new ItemStack(drop, 1)); b.setType(Material.AIR); } else if (rng >= 20 && rng < 40) { - b.getWorld().dropItemNaturally(blockLoc, new ItemStack(blockMat)); - b.getWorld().dropItemNaturally(blockLoc, new ItemStack(blockMat)); + b.getWorld().dropItemNaturally(blockLoc, new ItemStack(drop, 2)); b.setType(Material.AIR); } else if (rng >= 40 && rng < 60) { - b.getWorld().dropItemNaturally(blockLoc, new ItemStack(blockMat)); - b.getWorld().dropItemNaturally(blockLoc, new ItemStack(blockMat)); - b.getWorld().dropItemNaturally(blockLoc, new ItemStack(blockMat)); + b.getWorld().dropItemNaturally(blockLoc, new ItemStack(drop, 3)); b.setType(Material.AIR); } @@ -166,8 +173,8 @@ public class BlockListener implements Listener } } - else if (enchantments.containsKey(Enchantment.SILK_TOUCH) && ham && BlockRef.ValidHammerFortune.contains(blockMat) - || enchantments.containsKey(Enchantment.SILK_TOUCH) && exc && BlockRef.ValidExcavatorFortune.contains(blockMat)) + else if (enchantments.containsKey(Enchantment.SILK_TOUCH) && ham && BlockRef.ValidHammerFortune.containsKey(blockMat) + || enchantments.containsKey(Enchantment.SILK_TOUCH) && exc && BlockRef.ValidExcavatorFortune.containsKey(blockMat)) { b.getWorld().dropItemNaturally(blockLoc, new ItemStack(blockMat)); b.setType(Material.AIR); diff --git a/plugin/src/lightling/gibsoniacraft/util/BlockRef.java b/plugin/src/lightling/gibsoniacraft/util/BlockRef.java index c01cf5b..40c4699 100644 --- a/plugin/src/lightling/gibsoniacraft/util/BlockRef.java +++ b/plugin/src/lightling/gibsoniacraft/util/BlockRef.java @@ -1,8 +1,10 @@ package lightling.gibsoniacraft.util; import java.util.ArrayList; +import java.util.HashMap; import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; /** * Contains constant blocks and items of a certain type @@ -130,24 +132,24 @@ public class BlockRef }}; /** - * A list of all valid blocks that fortune affects on hammers + * Stores all valid blocks that fortune affects on hammers and matches them with their corresponding items */ - public static ArrayList ValidHammerFortune = new ArrayList() + public static HashMap ValidHammerFortune = new HashMap() {{ - add(Material.COAL_ORE); - add(Material.DIAMOND_ORE); - add(Material.EMERALD_ORE); - add(Material.NETHER_QUARTZ_ORE); - add(Material.LAPIS_ORE); - add(Material.GLOWSTONE); + put(Material.COAL_ORE, Material.COAL); + put(Material.DIAMOND_ORE, Material.DIAMOND); + put(Material.EMERALD_ORE, Material.EMERALD); + put(Material.NETHER_QUARTZ_ORE, Material.QUARTZ); + put(Material.LAPIS_ORE, Material.LAPIS_LAZULI); + put(Material.GLOWSTONE, Material.GLOWSTONE_DUST); }}; /** - * A list of all valid blocks that fortune affects on excavators + * Stores all valid blocks that fortune affects on excavators and matches them with their corresponding items */ - public static ArrayList ValidExcavatorFortune = new ArrayList() + public static HashMap ValidExcavatorFortune = new HashMap() {{ - add(Material.GRAVEL); + put(Material.GRAVEL, Material.FLINT); }}; /**