Search in sources :

Example 1 with BlockPreFallEvent

use of org.cubeengine.module.log.action.block.BlockPreFallEvent in project modules-extra by CubeEngine.

the class ListenerPlayerBlock method onBlockPlace.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
    Block blockPlaced = event.getBlockPlaced();
    PlayerBlockPlace action = this.newAction(PlayerBlockPlace.class, blockPlaced.getWorld());
    if (action != null) {
        action.setLocation(event.getBlock().getLocation());
        action.setPlayer(event.getPlayer());
        action.setOldBlock(event.getBlockReplacedState());
        action.setNewBlock(blockPlaced.getState());
        this.logAction(action);
        if (this.isActive(BlockFall.class, blockPlaced.getWorld()) && blockPlaced.getRelative(DOWN).getType() == AIR && (blockPlaced.getType().hasGravity() || blockPlaced.getType() == DRAGON_EGG)) {
            this.module.getCore().getEventManager().fireEvent(new BlockPreFallEvent(blockPlaced.getLocation(), action));
        }
    }
    Block lily = blockPlaced.getRelative(UP);
    if (blockPlaced.getType() != STATIONARY_WATER && lily.getType() == WATER_LILY) {
        PlayerBlockBreak wAction = this.newAction(PlayerBlockBreak.class);
        if (wAction != null) {
            wAction.setPlayer(event.getPlayer());
            wAction.setLocation(lily.getLocation());
            wAction.setOldBlock(lily.getState());
            wAction.setNewBlock(AIR);
            wAction.reference = this.reference(action);
            this.logAction(wAction);
        }
    }
}
Also used : PlayerBlockBreak(org.cubeengine.module.log.action.block.player.destroy.PlayerBlockBreak) BlockPreFallEvent(org.cubeengine.module.log.action.block.BlockPreFallEvent) ListenerBlock(org.cubeengine.module.log.action.block.ListenerBlock) Block(org.bukkit.block.Block) NoteBlock(org.bukkit.block.NoteBlock) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Block (org.bukkit.block.Block)1 NoteBlock (org.bukkit.block.NoteBlock)1 EventHandler (org.bukkit.event.EventHandler)1 BlockPreFallEvent (org.cubeengine.module.log.action.block.BlockPreFallEvent)1 ListenerBlock (org.cubeengine.module.log.action.block.ListenerBlock)1 PlayerBlockBreak (org.cubeengine.module.log.action.block.player.destroy.PlayerBlockBreak)1