From 8af503acebd75a90385c926d106efa6900ce04d1 Mon Sep 17 00:00:00 2001 From: NihilistBrew Date: Sat, 3 Aug 2019 18:59:47 +0200 Subject: [PATCH] Fix spawner dupe and objectified e.getBock() --- src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java b/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java index e41e7fbb8..23a4d0338 100644 --- a/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java +++ b/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java @@ -1837,17 +1837,19 @@ public class SlimefunSetup { @Override public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List drops) { if (SlimefunManager.isItemSimiliar(item, SlimefunItems.PICKAXE_OF_CONTAINMENT, true)) { - if (e.getBlock().getType() != Material.SPAWNER) return true; - BlockStorage.clearBlockInfo(e.getBlock()); + Block b = e.getBlock(); // Refactored it into this so we don't need to call e.getBlock() all the time. + if (b.getType() != Material.SPAWNER || BlockStorage.hasBlockInfo(b)) return true; + // If the spawner's BlockStorage has BlockInfo, then it's not a vanilla spawner and shouldn't give a broken spawner. + BlockStorage.clearBlockInfo(b); ItemStack spawner = SlimefunItems.BROKEN_SPAWNER.clone(); ItemMeta im = spawner.getItemMeta(); List lore = im.getLore(); for (int i = 0; i < lore.size(); i++) { - if (lore.get(i).contains("")) lore.set(i, lore.get(i).replace("", StringUtils.format(((CreatureSpawner) e.getBlock().getState()).getSpawnedType().toString()))); + if (lore.get(i).contains("")) lore.set(i, lore.get(i).replace("", StringUtils.format(((CreatureSpawner) b.getState()).getSpawnedType().toString()))); } im.setLore(lore); spawner.setItemMeta(im); - e.getBlock().getLocation().getWorld().dropItemNaturally(e.getBlock().getLocation(), spawner); + b.getLocation().getWorld().dropItemNaturally(b.getLocation(), spawner); e.setExpToDrop(0); return true; }