cn.nukkit.event.entity.CreeperPowerEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powernukkit Show documentation
Show all versions of powernukkit Show documentation
A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.
package cn.nukkit.event.entity;
import cn.nukkit.entity.mob.EntityCreeper;
import cn.nukkit.entity.weather.EntityLightningStrike;
import cn.nukkit.event.Cancellable;
import cn.nukkit.event.HandlerList;
/**
* @author MagicDroidX (Nukkit Project)
*/
public class CreeperPowerEvent extends EntityEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlers() {
return handlers;
}
private final PowerCause cause;
private EntityLightningStrike bolt;
public CreeperPowerEvent(final EntityCreeper creeper, final EntityLightningStrike bolt, final PowerCause cause) {
this(creeper, cause);
this.bolt = bolt;
}
public CreeperPowerEvent(final EntityCreeper creeper, final PowerCause cause) {
this.entity = creeper;
this.cause = cause;
}
@Override
public EntityCreeper getEntity() {
return (EntityCreeper) super.getEntity();
}
/**
* Gets the lightning bolt which is striking the Creeper.
*
* @return The Entity for the lightning bolt which is striking the Creeper
*/
public EntityLightningStrike getLightning() {
return bolt;
}
/**
* Gets the cause of the creeper being (un)powered.
*
* @return A PowerCause value detailing the cause of change in power.
*/
public PowerCause getCause() {
return cause;
}
/**
* An enum to specify the cause of the change in power
*/
public enum PowerCause {
/**
* Power change caused by a lightning bolt
*
* Powered state: true
*/
LIGHTNING,
/**
* Power change caused by something else (probably a plugin)
*
* Powered state: true
*/
SET_ON,
/**
* Power change caused by something else (probably a plugin)
*
* Powered state: false
*/
SET_OFF
}
}