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