use of org.spongepowered.api.entity.player.Player 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