Solved StackOverFlowError when calling BlockBreakEvent

Discussion in 'Spigot Plugin Development' started by Ayush_03, May 27, 2016.

  1. Removed.
    #1 Ayush_03, May 27, 2016
    Last edited: May 27, 2016
  2. I think what is happening is that you are calling a BlockBreakEvent from inside a block break event. Your listener is then catching this newly called event and calling another one. This keeps going until you run out of memory. One option is for you to create a new class that extends BlockBreakEvent (like VeinMineBlockBreakEvent) and inside your listener check if the block break event is an instanceof this custom class. If it is then return (and don't call another event).
    • Like Like x 1
    • Agree Agree x 1
    • Winner Winner x 1
  3. I want it so that it supports world protection plugins. Like, I know I can use WG API, but one who doesn't use WG, can get their server grieved.
  4. Yeah that should be fine. It extends BlockBreakEvent so the regular handlers should be invoked (that is why you need to check using instanceof so that you don't get stuck in your infinite recursive loop).
  5. Another thing I would like to say is, my BlockBreakEvent is on the priority Monitor. If I try the thing you told me to, will it work?
  6. The fact that it is on monitor shouldn't change anything. This means that you are letting all other handlers have a crack at the blockbreak before you get a look at it. If you are indeed just "monitoring" the state of the event and not modifying it yourself then this is the appropriate priority. So yes it will still work, and your handler is on the correct priority.
  7. If you're using NoCheatPlus make sure you add your new class to the events to ignore or players will not be able to use your plugin.
  8. I'm still confused. Once I extend BlockBreakEvent, what things shall I have in it?
  9. Also, which event should I use, the default one or custom one?
  10. Nvm, it worked thanks!
  11. Mark as solved, thank you