Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by Ayush_03, May 27, 2016.
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).
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.
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).
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?
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.
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.
I'm still confused. Once I extend BlockBreakEvent, what things shall I have in it?
Also, which event should I use, the default one or custom one?
Nvm, it worked thanks!
Mark as solved, thank you