Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Add `BlockModifyEvent`

Open jessiejs opened this issue 1 year ago • 1 comments

Is your feature request related to a problem?

Right now, if you want to restrict block modifications, you need a heavy plugin like CoreProtect, etc. I would like to make a plugin that detects when a block is replaced, and stop it.

Describe the solution you'd like.

A new class called BlockModifyEvent, the event would contain a property for the block, the old state, and the new state, and a cause enum, which can be one of the following:

  • Block type change
  • Block property change
  • Block entity data change

Describe alternatives you've considered.

Handling every single possible event for blocks changing is extremely hard to maintain.

Other

No response

jessiejs avatar Jan 19 '24 05:01 jessiejs

Block entity data change

I'm not sure what this means. Anytime what changes on a block entity, anything that is stored in NBT? that means every single tick, it would fire for every furnace because the burn/fuel time is stored in NBT. Anything any inventory changed, including anything hopper-related. We already have intense events for those in the InventoryMoveItemEvent.

Handling every single possible event for blocks changing is extremely hard to maintain

While this might be true, it's not generally good practice to have 2 events for one thing. That can cause more confusion around which event is fired first, what happens if I cancel the first one, does the second one fire, etc. There is a pretty good catch-all that happens when a block changes in any way, the BlockPhysicsEvent. It is a pretty intense event, that fires VERY frequently.

I'll wait to see what others say about this, but for now, I'm in the camp of "close this, as its too invasive/complex and redundant given all the other events that we have".

Machine-Maker avatar Jan 19 '24 05:01 Machine-Maker