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);
}
}
}
Aggregations