From 59127df5f0a093f13850902df0c90c584a9197d0 Mon Sep 17 00:00:00 2001 From: StarWishSama Date: Sun, 2 Feb 2020 21:37:36 +0800 Subject: [PATCH] Try to fix drop air on Explosive Pickaxe --- pom.xml | 2 +- .../core/services/AutoSavingService.java | 2 +- .../listeners/BlockListener.java | 2 +- .../SlimefunItem/items/ExplosivePickaxe.java | 168 +++++++++--------- 4 files changed, 87 insertions(+), 87 deletions(-) diff --git a/pom.xml b/pom.xml index 549d735ac7..7dd729fa70 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 me.mrCookieSlime Slimefun - 4.2-git-20200201 + 4.2-UNOFFCIAL-20200202 1.8 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java index 1720e08fa9..c181811813 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java @@ -41,7 +41,7 @@ public void saveAllPlayers() { } if (players > 0) { - Slimefun.getLogger().log(Level.INFO, "Auto-Saved Player Data for {0} Player(s)!", players); + Slimefun.getLogger().log(Level.INFO, "自动储存了 {0} 个玩家的数据!", players); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 8a19085b34..70849d4907 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -257,7 +257,7 @@ public void onBlockBreak(BlockBreakEvent e) { return; } } - else if (item != null) { + else if (item.getType() != Material.AIR) { for (ItemHandler handler : SlimefunItem.getHandlers(BlockBreakHandler.class)) { if (((BlockBreakHandler) handler).onBlockBreak(e, item, fortune, drops)) break; } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/items/ExplosivePickaxe.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/items/ExplosivePickaxe.java index f3cc8de0b6..150e09cdc8 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/items/ExplosivePickaxe.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/items/ExplosivePickaxe.java @@ -25,87 +25,87 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class ExplosivePickaxe extends SimpleSlimefunItem implements NotPlaceable, DamageableItem { - - private boolean damageOnUse; - - public ExplosivePickaxe(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, String[] keys, Object[] values) { - super(category, item, recipeType, recipe, keys, values); - } - - @Override - protected boolean areItemHandlersPrivate() { - return false; - } - - @Override - public BlockBreakHandler getItemHandler() { - return (e, item, fortune, drops) -> { - if (isItem(item)) { - if (Slimefun.hasUnlocked(e.getPlayer(), this, true)) { - e.getBlock().getWorld().createExplosion(e.getBlock().getLocation(), 0.0F); - e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.3F, 1F); - - for (int x = -1; x <= 1; x++) { - for (int y = -1; y <= 1; y++) { - for (int z = -1; z <= 1; z++) { - if (x == 0 && y == 0 && z == 0) { - continue; - } - - Block b = e.getBlock().getRelative(x, y, z); - - if (b.getType() != Material.AIR && !b.isLiquid() && !MaterialCollections.getAllUnbreakableBlocks().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) { - SlimefunPlugin.getProtectionManager().logAction(e.getPlayer(), b, ProtectableAction.BREAK_BLOCK); - - b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); - SlimefunItem sfItem = BlockStorage.check(b); - boolean allow = false; - - if (sfItem != null && !(sfItem instanceof HandledBlock)) { - SlimefunBlockHandler handler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID()); - - if (handler != null) { - allow = handler.onBreak(e.getPlayer(), e.getBlock(), sfItem, UnregisterReason.PLAYER_BREAK); - } - - if (allow) { - drops.add(BlockStorage.retrieve(e.getBlock())); - } - } - else if (b.getType() == Material.PLAYER_HEAD) { - b.breakNaturally(); - } - else if (b.getType().name().endsWith("_SHULKER_BOX")) { - b.breakNaturally(); - } - else { - for (ItemStack drop : b.getDrops(getItem())) { - b.getWorld().dropItemNaturally(b.getLocation(), (b.getType().toString().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE) ? new CustomItem(drop, fortune): drop); - } - b.setType(Material.AIR); - } - - damageItem(e.getPlayer(), item); - } - } - } - } - } - - return true; - } - else return false; - }; - } - - @Override - public void postRegister() { - damageOnUse = ((boolean) Slimefun.getItemValue(getID(), "damage-on-use")); - } - - @Override - public boolean isDamageable() { - return damageOnUse; - } - -} + + private boolean damageOnUse; + + public ExplosivePickaxe(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, String[] keys, Object[] values) { + super(category, item, recipeType, recipe, keys, values); + } + + @Override + protected boolean areItemHandlersPrivate() { + return false; + } + + @Override + public BlockBreakHandler getItemHandler() { + return (e, item, fortune, drops) -> { + if (isItem(item)) { + if (Slimefun.hasUnlocked(e.getPlayer(), this, true)) { + e.getBlock().getWorld().createExplosion(e.getBlock().getLocation(), 0.0F); + e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.3F, 1F); + + for (int x = -1; x <= 1; x++) { + for (int y = -1; y <= 1; y++) { + for (int z = -1; z <= 1; z++) { + if (x == 0 && y == 0 && z == 0) { + continue; + } + + Block b = e.getBlock().getRelative(x, y, z); + + if (b.getType() != Material.AIR && !b.isLiquid() && !MaterialCollections.getAllUnbreakableBlocks().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) { + SlimefunPlugin.getProtectionManager().logAction(e.getPlayer(), b, ProtectableAction.BREAK_BLOCK); + + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); + SlimefunItem sfItem = BlockStorage.check(b); + boolean allow = false; + + if (sfItem != null && !(sfItem instanceof HandledBlock)) { + SlimefunBlockHandler handler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID()); + + if (handler != null) { + allow = handler.onBreak(e.getPlayer(), e.getBlock(), sfItem, UnregisterReason.PLAYER_BREAK); + } + + if (allow) { + drops.add(BlockStorage.retrieve(e.getBlock())); + } + } + else if (b.getType() == Material.PLAYER_HEAD) { + b.breakNaturally(); + } + else if (b.getType().name().endsWith("_SHULKER_BOX")) { + b.breakNaturally(); + } + else { + for (ItemStack drop : b.getDrops(getItem())) { + b.getWorld().dropItemNaturally(b.getLocation(), (b.getType().toString().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE) ? new CustomItem(drop, fortune): drop); + } + b.setType(Material.AIR); + } + + damageItem(e.getPlayer(), item); + } + } + } + } + } + + return true; + } + else return false; + }; + } + + @Override + public void postRegister() { + damageOnUse = ((boolean) Slimefun.getItemValue(getID(), "damage-on-use")); + } + + @Override + public boolean isDamageable() { + return damageOnUse; + } + +} \ No newline at end of file