Spigot's BlockPlaceEvent actually fires after the block is already placed, and sets it back to the previous state if it's been cancelled.
Changes
Removed BlockHelper#generateBlockState and related reflection, as it's no longer needed.
Changed handleLocation block place event logic to match Spigot behavior - set the block, fire the event, set the block back if cancelled.
handleLocation used to generate a block state with the BlockData of the material being placed in, but that BlockState is meant to be the BlockState that got replaced; it now just gets the state from the block using normal Spigot API instead of using BlockHelper#generateBlockState.
handleLocation's block place event used to create a new ItemTag and get the item used to place the block from that, but that was a bit redundant, so changed to just new ItemStack(...).
Removed the ScriptEntry#dbCallShouldDebug check in the event firing logic, as Debug#echoDebug seems to have that built-in.
Additions
ModifyBlockCommand#callEvent - util to fire an event and return whether it's cancelled.
Reported on Discord.
Description
Spigot's
BlockPlaceEvent
actually fires after the block is already placed, and sets it back to the previous state if it's been cancelled.Changes
BlockHelper#generateBlockState
and related reflection, as it's no longer needed.handleLocation
block place event logic to match Spigot behavior - set the block, fire the event, set the block back if cancelled.handleLocation
used to generate a block state with theBlockData
of the material being placed in, but thatBlockState
is meant to be theBlockState
that got replaced; it now just gets the state from the block using normal Spigot API instead of usingBlockHelper#generateBlockState
.handleLocation
's block place event used to create a newItemTag
and get the item used to place the block from that, but that was a bit redundant, so changed to justnew ItemStack(...)
.ScriptEntry#dbCallShouldDebug
check in the event firing logic, asDebug#echoDebug
seems to have that built-in.Additions
ModifyBlockCommand#callEvent
- util to fire an event and return whether it's cancelled.