[SOLVED] How to make a player break a block?

Discussion in 'Spigot Plugin Development' started by GODofCRAFTERS, May 16, 2015.

  1. I need to process an event by which a block can be broken. But the problem is, if I use "event.getClickedBlock().breakNaturally(event.getItem());", it breaks the block, which is what I want except that it breaks the block even if the player was in a region where block breaking wasn't allowed. How do I also tell it to break the block as a player?
    I just need it to create an event where the player himself/herself breaks the block that he/she clicks (Left Click). How would I do that?
     
  2. Maybe check if the player can break in the region?
     
  3. Have you tried simply firing a BlockBreakEvent and checking if it was cancelled?
     
  4. @DarkSeraphim I tried that and it never fires the event for some reason. But anyways, thanks for your help guys, I managed to get around my problem in instants after I posted this thread. Sorry for the toruble :/ Thanks again :D
     
  5. (I meant firing it yourself, just saying)

    Anyway, other people with similar questions might be interested to know how you solved your issues;).
     
  6. Well I made a Listener which listened for BlockDamageEvent. And based on whether the player suited my large list of permissions and conditions I did event.setInstaBreak(true);. It was the easiest fix I've ever done. But I thought over it for more than an hour as I wasn't using the BlockDamageEvent. Guess I just gotta think "outside the box" more :p Thanks :D