Skip to content

Commit

Permalink
Merge pull request Slimefun#3940 from J3fftw1/fix/items-adder-dupe
Browse files Browse the repository at this point in the history
Fixes duplication glitch with explosive tools in combination with itemsadder
  • Loading branch information
Sfiguz7 authored Sep 6, 2023
2 parents 7e482ea + e032437 commit d683a63
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

import dev.lone.itemsadder.api.CustomBlock;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Material;
Expand Down Expand Up @@ -35,9 +36,9 @@

/**
* This {@link SlimefunItem} is a super class for items like the {@link ExplosivePickaxe} or {@link ExplosiveShovel}.
*
*
* @author TheBusyBiscuit
*
*
* @see ExplosivePickaxe
* @see ExplosiveShovel
*
Expand Down Expand Up @@ -83,13 +84,21 @@ private void breakBlocks(BlockBreakEvent e, Player p, ItemStack item, Block b, L
if (!blockExplodeEvent.isCancelled()) {
for (Block block : blockExplodeEvent.blockList()) {
if (canBreak(p, block)) {
if (Slimefun.getIntegrations().isCustomBlock(block)) {
drops.addAll(CustomBlock.byAlreadyPlaced(block).getLoot());
CustomBlock.remove(block.getLocation());
}
blocksToDestroy.add(block);
}
}
}
} else {
for (Block block : blocks) {
if (canBreak(p, block)) {
if (Slimefun.getIntegrations().isCustomBlock(block)) {
drops.addAll(CustomBlock.byAlreadyPlaced(block).getLoot());
CustomBlock.remove(block.getLocation());
}
blocksToDestroy.add(block);
}
}
Expand Down Expand Up @@ -137,8 +146,6 @@ protected boolean canBreak(@Nonnull Player p, @Nonnull Block b) {
return false;
} else if (!b.getWorld().getWorldBorder().isInside(b.getLocation())) {
return false;
} else if (Slimefun.getIntegrations().isCustomBlock(b)) {
return false;
} else {
return Slimefun.getProtectionManager().hasPermission(p, b.getLocation(), Interaction.BREAK_BLOCK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

import dev.lone.itemsadder.api.CustomBlock;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Server;
Expand Down Expand Up @@ -236,7 +237,7 @@ public boolean isEventFaked(@Nonnull Event event) {
public boolean isCustomBlock(@Nonnull Block block) {
if (isItemsAdderInstalled) {
try {
return ItemsAdder.isCustomBlock(block);
return CustomBlock.byAlreadyPlaced(block) != null;
} catch (Exception | LinkageError x) {
logError("ItemsAdder", x);
}
Expand Down

0 comments on commit d683a63

Please sign in to comment.