Search in sources :

Example 1 with ActionBlock

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

the class ListenerFlow method logFlow.

@SuppressWarnings("deprecation")
private void logFlow(Class<? extends ActionFlow> clazz, BlockState state, Material to, BlockState from) {
    ActionBlock action = this.newAction(clazz, state.getWorld());
    if (action != null) {
        BlockState newState = state.getBlock().getState();
        newState.setType(to);
        newState.setRawData((byte) (from.getRawData() + 1));
        action.setLocation(state.getLocation());
        action.setOldBlock(state);
        action.setNewBlock(newState);
        this.logAction(action);
    }
}
Also used : BlockState(org.bukkit.block.BlockState) ActionBlock(org.cubeengine.module.log.action.block.ActionBlock)

Example 2 with ActionBlock

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

the class ListenerFlow method log.

private void log(Class<? extends ActionBlock> clazz, BlockState state, Material to) {
    ActionBlock action = this.newAction(clazz, state.getWorld());
    if (action != null) {
        action.setLocation(state.getLocation());
        action.setOldBlock(state);
        action.setNewBlock(to);
        this.logAction(action);
    }
}
Also used : ActionBlock(org.cubeengine.module.log.action.block.ActionBlock)

Example 3 with ActionBlock

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

the class ListenerBlockIgnite method onIgnite.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onIgnite(BlockIgniteEvent event) {
    BlockState oldState = event.getBlock().getState();
    ActionBlock action;
    switch(event.getCause()) {
        case FIREBALL:
            action = this.newAction(IgniteFireball.class, oldState.getWorld());
            if (action != null) {
                ProjectileSource shooter = ((Fireball) event.getIgnitingEntity()).getShooter();
                if (shooter instanceof Entity) {
                    ((IgniteFireball) action).setShooter((Entity) shooter);
                    if (shooter instanceof Ghast) {
                        LivingEntity target = BukkitUtils.getTarget((Ghast) shooter);
                        if (target instanceof Player) {
                            ((IgniteFireball) action).setPlayer((Player) target);
                        }
                    } else if (shooter instanceof Player) {
                        ((IgniteFireball) action).setPlayer((Player) shooter);
                    }
                }
            }
            break;
        case LAVA:
            action = this.newAction(IgniteLava.class, oldState.getWorld());
            if (action != null) {
                ((IgniteLava) action).setSource(event.getIgnitingBlock().getLocation());
            }
            break;
        case LIGHTNING:
            action = this.newAction(IgniteLightning.class, oldState.getWorld());
            break;
        case FLINT_AND_STEEL:
            action = this.newAction(IgniteLighter.class, oldState.getWorld());
            if (action != null && event.getPlayer() != null) {
                ((IgniteLighter) action).setPlayer(event.getPlayer());
            }
            break;
        case ENDER_CRYSTAL:
        case EXPLOSION:
            action = this.newAction(IgniteOther.class, oldState.getWorld());
            break;
        case SPREAD:
            return;
        default:
            this.module.getLog().warn("Unknown IgniteCause! {}", event.getCause().name());
            return;
    }
    if (action != null) {
        action.setOldBlock(oldState);
        action.setNewBlock(FIRE);
        action.setLocation(oldState.getLocation());
        this.logAction(action);
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.spongepowered.api.entity.Entity) Player(org.spongepowered.api.entity.player.Player) ActionBlock(org.cubeengine.module.log.action.block.ActionBlock) LivingEntity(org.bukkit.entity.LivingEntity) BlockState(org.bukkit.block.BlockState) Fireball(org.bukkit.entity.Fireball) Ghast(org.bukkit.entity.Ghast) ProjectileSource(org.bukkit.projectiles.ProjectileSource) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ActionBlock (org.cubeengine.module.log.action.block.ActionBlock)3 BlockState (org.bukkit.block.BlockState)2 Fireball (org.bukkit.entity.Fireball)1 Ghast (org.bukkit.entity.Ghast)1 LivingEntity (org.bukkit.entity.LivingEntity)1 EventHandler (org.bukkit.event.EventHandler)1 ProjectileSource (org.bukkit.projectiles.ProjectileSource)1 Entity (org.spongepowered.api.entity.Entity)1 Player (org.spongepowered.api.entity.player.Player)1