Why is this not blocking drops of blocks?

Discussion in 'Spigot Plugin Development' started by BryceTheCoder, Jun 17, 2015.

  1. Hey yo! So I am attempting to stop any drops that come from breaking blocks.
    This is what I got so far:

    @EventHandler(ignoreCancelled=true, priority=EventPriority.LOWEST)
    public void onBreak(BlockBreakEvent e) {

    Why is coal ore still dropping coal?
    I did the EventPriority as the LOWEST because that will be the most recent changes which is me clearing all the drops.
    NOTE: I have no other conflicting plugins that do anything with the block breaking.
  2. block.getDrops() only returns a copy of the dropped items. Clearing this copy will not effect the original drops list. There is no clean way of doing what you want, sadly. You will end up breaking something somewhere (most likely logging plugins), if you proceed further. :(
  3. Cancel the block break, and then call Block#breakNaturally to break it.
  4. Thus breaking things, like logging plugins. :p
  5. Just do:

    Code (Text):
    BlockBreakEvent event = new BlockBreakEvent(blockBroken, whoBrokeIt);
  6. Thus causing a recursive loop. Since, you know, this is happening from within a BlockBreakEvent listener... ;)
  7. So wouldn't loggers still register the block break?

    Or is the setCancelled.. well.. cancelling it.
  8. One boolean to fix them all.
  9. isCancelled()?
  10. Thus doubling the length of your broken blocks logged. ;)
  11. Assuming cancelled events aren't logged, and you don't have to worry about the event you fired yourself (in terms of cancelling, as you control it's post-event behaviour), it should only be logged once as you only need to cancel the original event.
    I was more thinking about a boolean field.
    • Like Like x 1
  12. So... whats the point of canceling it, then calling to break it naturally? This will do the same thing. Cancel the event, then normally break it?
    Is there no way to stop the droppings of an ore?
  13. Break Naturally should remove the drops.
  14. Why not just check ItemSpawnEvent and cancel it if the material matches what the block drops?
  15. Just setting the blocks type to AIR in the BlockBreakEvent will cancel all drops.
  16. Could also stop logging plugins from functioning correctly. Best way is to cancel the original event, set a boolean to true which stops execution of that blockbreaklistener, run your own event for the logging plugins and then set the block to air and set the bool to false again
    • Agree Agree x 1