diff --git a/plugin.yml b/plugin.yml index b59ea45..8720e1e 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: CustomEnchantments main: com.taiter.ce.Main -version: 2.2 +version: 2.2a softdepend: [WorldGuard, WorldEdit, Vault] diff --git a/src/com/taiter/ce/CEListener.java b/src/com/taiter/ce/CEListener.java index 7419939..48a2c53 100644 --- a/src/com/taiter/ce/CEListener.java +++ b/src/com/taiter/ce/CEListener.java @@ -70,53 +70,53 @@ public class CEListener implements Listener { - - - HashSet move = new HashSet(); - HashSet interact = new HashSet(); - HashSet interactE = new HashSet(); - HashSet interactR = new HashSet(); - HashSet interactL = new HashSet(); - HashSet damageTaken = new HashSet(); + + + HashSet move = new HashSet(); + HashSet interact = new HashSet(); + HashSet interactE = new HashSet(); + HashSet interactR = new HashSet(); + HashSet interactL = new HashSet(); + HashSet damageTaken = new HashSet(); HashSet damageGiven = new HashSet(); HashSet damageNature = new HashSet(); HashSet shootBow = new HashSet(); HashSet projectileThrow = new HashSet(); HashSet projectileHit = new HashSet(); - HashSet death = new HashSet(); - HashSet blockPlaced = new HashSet(); + HashSet death = new HashSet(); + HashSet blockPlaced = new HashSet(); HashSet blockBroken = new HashSet(); HashSet equipItem = new HashSet(); - - + + /* - * Almost all priorities are set to Monitor, the highest priority possible, + * Almost all priorities are set to Monitor, the highest priority possible, * which allows CE to check if an event has been cancelled by any kind of plugin beforehand. - * - * This is due to the fact that CE rarely cancels Events itself; + * + * This is due to the fact that CE rarely cancels Events itself; * with the addition of all events ignoring cancelled events this becomes apparent. - * - * If it is needed for an effect to cancel an event however, the priority HIGHEST is used, + * + * If it is needed for an effect to cancel an event however, the priority HIGHEST is used, * as cancelling the event this late fits best for not interfering with other plugins too much. - * + * */ - + //Inventory menu //PREVENTION of taking items out @EventHandler(priority = EventPriority.HIGHEST) public void inventoryMenuPrevention(InventoryDragEvent event) { - if(event.getView().getTopInventory().getTitle().startsWith("CE")) + if(event.getView().getTopInventory().getTitle().startsWith("CE")) event.setCancelled(true); } - + @EventHandler(priority = EventPriority.HIGHEST) public void inventoryMenuPrevention(InventoryCreativeEvent event) { - if(event.getView().getTopInventory().getTitle().startsWith("CE")) + if(event.getView().getTopInventory().getTitle().startsWith("CE")) event.setCancelled(true); } //PREVENTION - + @EventHandler(priority = EventPriority.HIGHEST) public void inventoryMenu(final InventoryClickEvent event) { if(event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR || event.getRawSlot() < -1) { @@ -129,21 +129,21 @@ public void inventoryMenu(final InventoryClickEvent event) { event.setResult(Result.ALLOW); event.setCancelled(true); - + //This is the back-button, located in the very last spot of each inventory - if((event.getRawSlot() == topInv.getSize()-1) && event.getCurrentItem().getType() != Material.AIR) { + if((event.getRawSlot() == topInv.getSize()-1) && event.getCurrentItem().getType() != Material.AIR) { p.closeInventory(); p.openInventory(Tools.getPreviousInventory(topInv.getTitle())); return; } - + //Opens the clicked Enchantments inventory and loads the permissions if needed if(topInv.getTitle().equals(Tools.prefix + "Enchantments")) { p.closeInventory(); p.openInventory(Tools.getEnchantmentMenu(p, clickedItem.getItemMeta().getDisplayName())); return; } - + //Opens the item inventory and loads the permissions if needed if(topInv.getTitle().equals(Tools.prefix + "Main Menu") && event.getRawSlot() == 4) { p.closeInventory(); @@ -151,9 +151,9 @@ public void inventoryMenu(final InventoryClickEvent event) { return; } - + //These are the specific menus, clicking one of them will lead to the enchanting menu, which needs to be 'notified' of the enchantment to give and it's cost - if(topInv.getTitle().equals(Tools.prefix + "Global") || topInv.getTitle().equals(Tools.prefix + "Bow") || topInv.getTitle().equals(Tools.prefix + "Armor") || topInv.getTitle().equals(Tools.prefix + "Helmet") || topInv.getTitle().equals(Tools.prefix + "Boots") || topInv.getTitle().equals(Tools.prefix + "Tool")) + if(topInv.getTitle().equals(Tools.prefix + "Global") || topInv.getTitle().equals(Tools.prefix + "Bow") || topInv.getTitle().equals(Tools.prefix + "Armor") || topInv.getTitle().equals(Tools.prefix + "Helmet") || topInv.getTitle().equals(Tools.prefix + "Boots") || topInv.getTitle().equals(Tools.prefix + "Tool")) if(p.isOp() || Tools.checkPermission(Tools.getEnchantmentByDisplayname(clickedItem.getItemMeta().getDisplayName()), p)) { Inventory enchantingMenu = Main.CEEnchantingMenu; enchantingMenu.setItem(0, clickedItem); @@ -164,12 +164,12 @@ public void inventoryMenu(final InventoryClickEvent event) { p.sendMessage(ChatColor.RED + "[CE] You do not have permission to buy this Enchantment."); return; } - + //This opens the Item Creation Menu - if(topInv.getTitle().equals(Tools.prefix + "Items")) + if(topInv.getTitle().equals(Tools.prefix + "Items")) if(p.isOp() || Tools.checkPermission(Tools.getItemByDisplayname(clickedItem.getItemMeta().getDisplayName()), p)) { - - + + Inventory approveMenu = Main.CEApproveMenu; approveMenu.setItem(0, clickedItem); p.closeInventory(); @@ -179,8 +179,8 @@ public void inventoryMenu(final InventoryClickEvent event) { p.sendMessage(ChatColor.RED + "[CE] You do not have permission to buy this Item."); return; } - - + + if(topInv.getTitle().equals(Tools.prefix + "Enchanting") || topInv.getTitle().equals(Tools.prefix + "Item Creation")) { double cost = 0; ItemStack item = clickedItem; @@ -218,55 +218,55 @@ public void inventoryMenu(final InventoryClickEvent event) { return; } } - + lore.add(ce.getDisplayName()); im.setLore(lore); item.setItemMeta(im); } else return; - + } else if(topInv.getTitle().equals(Tools.prefix + "Item Creation")) { item = topInv.getContents()[0]; cost = Tools.getItemByDisplayname(item.getItemMeta().getDisplayName()).getCost(); // if(item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equals(swimsuit.getDisplayName())) { //TODO: Always keep the position of the Swimsuit updated -// -// -// itemSet = true; -// +// +// +// itemSet = true; +// // int count = 0; -// +// // for(ItemStack i : event.getView().getBottomInventory()) // if(i == null || i.getType().equals(Material.AIR)) // count++; -// +// // if(count < 4) { // p.sendMessage(ChatColor.RED + "[CE] Your Inventory is full!"); // return; // } -// -// +// +// // } else { - + if(event.getView().getBottomInventory().firstEmpty() < 0) { p.sendMessage(ChatColor.RED + "[CE] Your Inventory is full!"); return; } - + // } - + ItemMeta itemIm = item.getItemMeta(); List lore = itemIm.getLore(); lore.remove(lore.size() - 1 ); itemIm.setLore(lore); item.setItemMeta(itemIm); type = "item " + itemIm.getDisplayName(); - } - + } + //TODO: Fix the cost for items // rewrite the whole section to check which enchantment or item is selected - + successString = (ChatColor.GREEN + "[CE] You have created the " + type + ChatColor.GREEN + "."); - + if(!p.isOp() && cost != 0) { if(Main.econ.getBalance(p.getName()) >= cost) { EconomyResponse ecr = Main.econ.withdrawPlayer(p.getName(), cost); @@ -294,20 +294,20 @@ public void inventoryMenu(final InventoryClickEvent event) { // ItemStack cp = item.clone(); // ItemStack le = item.clone(); // ItemStack bo = item.clone(); -// +// // String[] parts = swimsuit.parts; -// +// // cp.setType(Material.IRON_CHESTPLATE); // le.setType(Material.IRON_LEGGINGS); // bo.setType(Material.IRON_BOOTS); -// +// // im.setDisplayName(parts[1]); // cp.setItemMeta(im); // im.setDisplayName(parts[2]); // le.setItemMeta(im); // im.setDisplayName(parts[3]); // bo.setItemMeta(im); -// +// // p.getInventory().addItem(item); // p.getInventory().addItem(cp); // p.getInventory().addItem(le); @@ -319,100 +319,100 @@ public void inventoryMenu(final InventoryClickEvent event) { p.sendMessage(successString); return; } - + p.closeInventory(); try { p.openInventory(Tools.getNextInventory(clickedItem.getItemMeta().getDisplayName())); } catch (Exception e) { p.sendMessage(ChatColor.RED + "[CE] This feature is disabled."); } - - - + + + } } - - + + //ENTITIES: org.bukkit.event.entity - - + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void antiArrowSpam(ProjectileHitEvent event) { // Destroys the Arrows of the Minigun if (event.getEntityType().equals(EntityType.ARROW)) { Arrow arrow = (Arrow) event.getEntity(); ProjectileSource shooter = arrow.getShooter(); - if (shooter instanceof Player) - if (arrow.hasMetadata("ce.minigunarrow")) - if (((Player) shooter).getGameMode().equals(GameMode.CREATIVE)) + if (shooter instanceof Player) + if (arrow.hasMetadata("ce.minigunarrow")) + if (((Player) shooter).getGameMode().equals(GameMode.CREATIVE)) arrow.remove(); } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void EntityDamageByEntityEvent(EntityDamageByEntityEvent e) { - + Entity damager = e.getDamager(); Entity damaged = e.getEntity(); - + if(damaged instanceof Player) CEventHandler.handleEvent((Player) damaged, e, damageTaken); - if(damager instanceof Player) - CEventHandler.handleEvent((Player) damager, e, damageGiven); + if(damager instanceof Player) + CEventHandler.handleEvent((Player) damager, e, damageGiven); else if(damager instanceof Arrow) if(damager.hasMetadata("ce.bow.item") || damager.hasMetadata("ce.bow.enchantment")) CEventHandler.handleBows((Player) ((Projectile) damager).getShooter(), e); - - + + } - - + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void EntityDamageEvent(EntityDamageEvent e) { - + Entity damaged = e.getEntity(); - + if(damaged instanceof Player) { - + CEventHandler.handleEvent((Player) damaged, e, damageNature); - + if(damaged.hasMetadata("ce.springs")) { e.setCancelled(true); Vector vel = damaged.getVelocity(); vel.setY( (vel.getY() * -0.75 ) > 1 ? vel.getY() * -0.75 : 0); damaged.setVelocity(vel); } - - + + } - + } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void EntityExplodeEvent(EntityExplodeEvent e) { - + if(e.getEntity() != null && e.getEntity().hasMetadata("ce.explosive")) { e.getEntity().remove(); e.setCancelled(true); } - + } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void EntityShootBowEvent(EntityShootBowEvent e) { Entity shooter = e.getEntity(); - + if(shooter instanceof Player) CEventHandler.handleEvent((Player) shooter, e, shootBow); } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void ProjectileHitEvent(ProjectileHitEvent e) { ProjectileSource shooter = e.getEntity().getShooter(); - + if(shooter instanceof Player) { if(e.getEntity().hasMetadata("ce.projectile.item")) { CItem ci = Tools.getItemByOriginalname(e.getEntity().getMetadata("ce.projectile.item").get(0).asString()); @@ -422,49 +422,73 @@ public void ProjectileHitEvent(ProjectileHitEvent e) { } } - + //PLAYER: org.bukkit.event.player - + // @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) // public void PlayerDeathEvent(PlayerDeathEvent e) { -// +// // CEventHandler.handleEvent(e.getEntity(), e, deathEnchantments); -// +// // } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void ProjectileLaunchEvent(ProjectileLaunchEvent e) { - + ProjectileSource shooter = e.getEntity().getShooter(); - + if(shooter instanceof Player) CEventHandler.handleEvent((Player) shooter, e, projectileThrow); - + } - + @EventHandler(priority = EventPriority.HIGHEST) public void SignChangeEvent(SignChangeEvent e) { - if(e.getLine(0).equals("[CustomEnchant]") && !e.getPlayer().isOp()) - e.setCancelled(true); + if(e.getLine(0).equals("[CustomEnchant]")) + if(!e.getPlayer().isOp()) + e.setCancelled(true); + else { + String ench = e.getLine(1); + CEnchantment ce = Tools.getEnchantmentByDisplayname(ench); + if(ce == null) + ce = Tools.getEnchantmentByOriginalname(ench); + if(ce == null) + for(CEnchantment ceT : Main.enchantments) + if(Tools.checkForEnchantment(ench, ceT)) + ce = ceT; + if(ce == null) { + e.getPlayer().sendMessage(ChatColor.RED + "[CE] Could not find Custom Enchantment " + ench + "."); + e.setCancelled(true); + return; + } + try { + Integer.parseInt(e.getLine(3).replaceAll("\\D+","")); + } catch(NumberFormatException ex) { + e.getPlayer().sendMessage(ChatColor.RED + "[CE] The cost you entered is invalid."); + e.setCancelled(true); + return; + } + e.getPlayer().sendMessage(ChatColor.GREEN + "[CE] Successfully created a sign shop for the enchantment " + ench + "."); + } } @EventHandler(priority = EventPriority.HIGHEST) public void PlayerInteractEvent(PlayerInteractEvent e) { - + CEventHandler.handleEvent(e.getPlayer(), e, interact); - + if(e.getAction().toString().startsWith("LEFT")) CEventHandler.handleEvent(e.getPlayer(), e, interactL); else if(e.getAction().toString().startsWith("RIGHT")) CEventHandler.handleEvent(e.getPlayer(), e, interactR); - - if(e.getClickedBlock() != null && e.getClickedBlock() instanceof Sign) - if(((Sign) e.getClickedBlock()).getLine(0).equals("[CustomEnchant]")) { + + if(e.getClickedBlock() != null && e.getClickedBlock().getType().toString().contains("SIGN")) + if(((Sign) e.getClickedBlock().getState()).getLine(0).equals("[CustomEnchant]")) { Player p = e.getPlayer(); if(!Main.hasEconomy) { - p.performCommand("/ce menu"); + p.performCommand("ce menu"); } else if(p.getItemInHand().getType() != Material.AIR){ - Sign sign = ((Sign) e.getClickedBlock()); + Sign sign = ((Sign) e.getClickedBlock().getState()); CEnchantment ce = Tools.getEnchantmentByDisplayname(sign.getLine(1)); if(ce == null) Tools.getEnchantmentByOriginalname(sign.getLine(1)); @@ -474,20 +498,20 @@ else if(e.getAction().toString().startsWith("RIGHT")) ce = ceT; if(ce == null) return; - + ItemStack inHand = p.getItemInHand(); if(!Tools.isApplicable(inHand, ce)) { p.sendMessage(ChatColor.RED + "[CE] This enchantment can not be applied to this item."); return; } - + int cost = 0; try { cost = Integer.parseInt(sign.getLine(3).replaceAll("\\D+","")); } catch(NumberFormatException ex) { return; } - + if(inHand.hasItemMeta() && inHand.getItemMeta().hasLore()) { List lore = inHand.getItemMeta().getLore(); for(int i = 0; i < lore.size(); i++) @@ -518,15 +542,15 @@ else if(e.getAction().toString().startsWith("RIGHT")) p.sendMessage(ChatColor.RED + "[CE] You already have the maximum level of this enchantment!"); return; } - } + } } - + List lore = new ArrayList(); ItemMeta im = inHand.getItemMeta(); - + if(inHand.getItemMeta().hasLore()) lore = im.getLore(); - + if(Main.econ.getBalance(p.getName()) >= cost) { EconomyResponse ecr = Main.econ.withdrawPlayer(p.getName(), cost); if(ecr.transactionSuccess()) @@ -542,63 +566,66 @@ else if(e.getAction().toString().startsWith("RIGHT")) p.closeInventory(); return; } - + lore.add(ce.getDisplayName() + " I"); im.setLore(lore); inHand.setItemMeta(im); return; - - + + + } else { + p.sendMessage(ChatColor.RED + "[CE] You do not have an item in your hand."); + return; } } - + } - + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void PlayerInteractEntityEvent(PlayerInteractEntityEvent e) { - + CEventHandler.handleEvent(e.getPlayer(), e, interactE); - + } - + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void PlayerMoveEvent(PlayerMoveEvent e) { - - - + + + Location from = e.getFrom(); Location to = e.getTo(); - + if(from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ() ) { - + CEventHandler.handleEvent(e.getPlayer(), e, move); CEventHandler.handleMines(e.getPlayer(), e); - + } - + } - - - + + + //BLOCKS: org.bukkit.event.block - - + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void BlockPlaceEvent(BlockPlaceEvent e) { - + CEventHandler.handleEvent(e.getPlayer(), e, blockPlaced); - + } - - + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void BlockBreakEvent(BlockBreakEvent e) { - + if(e.getBlock().hasMetadata("ce.Ice")) e.setCancelled(true); - + CEventHandler.handleEvent(e.getPlayer(), e, blockBroken); if(e.getBlock().hasMetadata("ce.mine")) { Block b = e.getBlock(); @@ -610,7 +637,7 @@ public void BlockBreakEvent(BlockBreakEvent e) { b.getRelative(0,0,1), b.getRelative(0,0,-1) }; - + for(Block block : blocks) { if(block.hasMetadata("ce.mine.secondary")) { String[] s = block.getMetadata("ce.mine.secondary").get(0).asString().split(" "); @@ -621,40 +648,40 @@ public void BlockBreakEvent(BlockBreakEvent e) { } } } - + } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void BlockFromToEvent(BlockFromToEvent e) { - + if(e.getBlock().hasMetadata("ce.Ice")) e.setCancelled(true); - + } - - - + + + //ENCHANTMENT: org.bukkit.event.enchantment - - + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void EnchantItemEvent(EnchantItemEvent e) { - + if(Tools.random.nextInt(100) < (Integer.parseInt(Main.config.getString("Global.Enchantments.CEnchantingProbability")))) { CEventHandler.handleEnchanting(e); } - - + + } - - - + + + //WORLD: org.bukkit.event.world - - - - - - + + + + + + } diff --git a/src/com/taiter/ce/CItems/Deathscythe.java b/src/com/taiter/ce/CItems/Deathscythe.java index ff76c74..c2fc325 100644 --- a/src/com/taiter/ce/CItems/Deathscythe.java +++ b/src/com/taiter/ce/CItems/Deathscythe.java @@ -27,6 +27,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.player.PlayerInteractEvent; @@ -101,6 +102,10 @@ public boolean effect(Event event, final Player player) { Location loc = player.getLocation(); List ents = player.getNearbyEntities(Range, Range, Range); + for(int i = ents.size()-1; i >= 0; i--) + if(!(ents.get(i) instanceof LivingEntity)) + ents.remove(i); + if(ents.isEmpty()) { loc.getWorld().playSound(loc, Sound.PORTAL_TRAVEL, 0.01f, 100f); player.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.ITALIC + "There are no souls nearby"); diff --git a/src/com/taiter/ce/Enchantments/Boots/Gears.java b/src/com/taiter/ce/Enchantments/Boots/Gears.java index 617df75..4119b94 100644 --- a/src/com/taiter/ce/Enchantments/Boots/Gears.java +++ b/src/com/taiter/ce/Enchantments/Boots/Gears.java @@ -49,9 +49,9 @@ public void effect(Event e, ItemStack item, int level) { final Player player = event.getPlayer(); if(Main.repeatPotionEffects) { - Tools.repeatPotionEffect(item, player, PotionEffectType.SPEED, strength+level, true, this); + Tools.repeatPotionEffect(item, player, PotionEffectType.SPEED, strength+level-1, true, this); } else { - event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 120, strength + level), true); + event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 120, strength + level-1), true); generateCooldown(player, 100l); } } diff --git a/src/com/taiter/ce/Enchantments/Boots/Springs.java b/src/com/taiter/ce/Enchantments/Boots/Springs.java index 4bf2f68..f65fa53 100644 --- a/src/com/taiter/ce/Enchantments/Boots/Springs.java +++ b/src/com/taiter/ce/Enchantments/Boots/Springs.java @@ -48,9 +48,9 @@ public void effect(Event e, ItemStack item, int level) { PlayerMoveEvent event = (PlayerMoveEvent) e; Player player = event.getPlayer(); if(Main.repeatPotionEffects) - Tools.repeatPotionEffect(item, player, PotionEffectType.JUMP, strength+level, true, this); + Tools.repeatPotionEffect(item, player, PotionEffectType.JUMP, strength+level-1, true, this); else { - event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 120, strength + level), true); + event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 120, strength + level-1), true); generateCooldown(player, 100l); } } diff --git a/src/com/taiter/ce/Enchantments/Tools/Smelting.java b/src/com/taiter/ce/Enchantments/Tools/Smelting.java index 9579fd4..b1ef1b6 100644 --- a/src/com/taiter/ce/Enchantments/Tools/Smelting.java +++ b/src/com/taiter/ce/Enchantments/Tools/Smelting.java @@ -27,7 +27,6 @@ import org.bukkit.event.Event; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; import com.taiter.ce.Enchantments.CEnchantment; @@ -49,7 +48,7 @@ public void effect(Event e, ItemStack item, int level) { ItemStack itemToDrop = null; Material drop = null; - MaterialData md = null; + short dur = 0; Block b = event.getBlock(); @@ -63,11 +62,9 @@ else if(m == Material.IRON_ORE) drop = Material.IRON_INGOT; else if(m == Material.GOLD_ORE) drop = Material.GOLD_INGOT; - else if(m == Material.DIAMOND_ORE) - drop = Material.DIAMOND; - else if(m == Material.WOOD) { + else if(m.toString().contains("LOG")) { drop = Material.COAL; - md = new MaterialData(Material.COAL, (byte) 1); + dur = 1; } else if(m == Material.SAND) drop = Material.GLASS; @@ -76,8 +73,7 @@ else if(m == Material.CLAY) if(drop != null) { itemToDrop = new ItemStack(drop, event.getBlock().getDrops(player.getItemInHand()).size()); //Prevents unallowed tool usage (Wooden Pickaxe -> Diamond Ore) - if(md != null) - itemToDrop.setData(md); + itemToDrop.setDurability(dur); event.setCancelled(true); player.getWorld().dropItemNaturally(b.getLocation(), itemToDrop); player.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 12);