Search in sources :

Example 6 with BlockStateChange

use of me.botsko.prism.api.BlockStateChange in project Prism-Bukkit by prism.

the class PrismMiscEvents method onPrismBlocksExtinguishEvent.

/**
 * PrismExtinguishEvent.
 * @param event PrismExtinguishEvent.
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPrismBlocksExtinguishEvent(final PrismExtinguishEvent event) {
    // Get all block changes for this event
    final ArrayList<BlockStateChange> blockStateChanges = event.getBlockStateChanges();
    if (!blockStateChanges.isEmpty()) {
        // Create an entry for the rollback as a whole
        final Handler primaryAction = ActionFactory.createPrismProcess("prism-process", PrismProcessType.EXTINGUISH, event.onBehalfOf(), "" + event.getRadius());
        final long id = RecordingTask.insertActionIntoDatabase(primaryAction);
        if (id == 0) {
            return;
        }
        for (final BlockStateChange stateChange : blockStateChanges) {
            final BlockState orig = stateChange.getOriginalBlock();
            final BlockState newBlock = stateChange.getNewBlock();
            // Build the action
            RecordingQueue.addToQueue(ActionFactory.createPrismRollback("prism-extinguish", orig, newBlock, event.onBehalfOf(), id));
        }
    // ActionQueue.save();
    }
}
Also used : BlockStateChange(me.botsko.prism.api.BlockStateChange) BlockState(org.bukkit.block.BlockState) Handler(me.botsko.prism.api.actions.Handler) EventHandler(org.bukkit.event.EventHandler) EventHandler(org.bukkit.event.EventHandler)

Aggregations

BlockStateChange (me.botsko.prism.api.BlockStateChange)6 BlockState (org.bukkit.block.BlockState)3 Handler (me.botsko.prism.api.actions.Handler)2 Location (org.bukkit.Location)2 EventHandler (org.bukkit.event.EventHandler)2 ArrayList (java.util.ArrayList)1 BlockStateChangeImpl (me.botsko.prism.events.BlockStateChangeImpl)1 PrismDrainEvent (me.botsko.prism.events.PrismDrainEvent)1 PrismExtinguishEvent (me.botsko.prism.events.PrismExtinguishEvent)1 Component (net.kyori.adventure.text.Component)1 TextComponent (net.kyori.adventure.text.TextComponent)1 World (org.bukkit.World)1 Block (org.bukkit.block.Block)1 BlockData (org.bukkit.block.data.BlockData)1 CommandSender (org.bukkit.command.CommandSender)1 Player (org.bukkit.entity.Player)1