1.14.4 Unable to cancel drops on BlockBreakEvent called by a plugin

Discussion in 'Spigot Plugin Development' started by Uxon, Jan 24, 2020.

  1. Hey there,

    For my plugin Oraxen, I am working on a mechanic which allows to instantly smelt ores like iron and gold (so when you break them, you directly get an ingot). It is working fine with a pickaxe since if I break an iron ore it gives me an iron ingot, but if I am trying to use a hammer (an item using another mechanic I called bigmining which basically allows you to mine different blocks at the same time) I also get iron ores...

    Here is the code of my smeltingmechanic: https://github.com/Th0rgal/Oraxen/b...vided/smelting/SmeltingMechanicsListener.java

    But the problem probably comes from the other mechanics which break blocks that way:
    Code (Text):

    private void breakBlock(Player player, Block block) {
        if (block.isLiquid() || block.getType() == Material.BEDROCK || block.getType() == Material.BARRIER)
        blocksToProcess += 1; // to avoid this method to call itself <- need other way to handle players using the same tool at the same time
        BlockBreakEvent blockBreakEvent = new BlockBreakEvent(block, player);
        if (!blockBreakEvent.isCancelled())
    This allows the hammers to be supported by plugins like worldguard (since they should be allowed to cancel the blockbreak): but in my case this is pretty buggy because what I'm using to cancel the loots (event.setDropItems(false);) seems absolutely not working with events called by plugins (not naturally).

    Did I dod something wrong? Do you have any ideas?

    Thank you,