All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bukkit.event.entity.CreeperPowerEvent Maven / Gradle / Ivy

package org.bukkit.event.entity;

import org.bukkit.entity.Creeper;
import org.bukkit.entity.LightningStrike;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

/**
 * Called when a Creeper is struck by lightning.
 * 

* If a Creeper Power event is cancelled, the Creeper will not be powered. */ public class CreeperPowerEvent extends EntityEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private final PowerCause cause; private boolean canceled; private LightningStrike bolt; public CreeperPowerEvent(final Creeper creeper, final LightningStrike bolt, final PowerCause cause) { this(creeper, cause); this.bolt = bolt; } public CreeperPowerEvent(final Creeper creeper, final PowerCause cause) { super(creeper); this.cause = cause; } public static HandlerList getHandlerList() { return handlers; } public boolean isCancelled() { return canceled; } public void setCancelled(boolean cancel) { canceled = cancel; } @Override public Creeper getEntity() { return (Creeper) entity; } /** * Gets the lightning bolt which is striking the Creeper. * * @return The Entity for the lightning bolt which is striking the Creeper */ public LightningStrike 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; } @Override public HandlerList getHandlers() { return handlers; } /** * 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 } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy