001 package org.bukkit.event.entity;
002
003 import org.bukkit.entity.LightningStrike;
004 import org.bukkit.entity.Pig;
005 import org.bukkit.entity.PigZombie;
006 import org.bukkit.event.Cancellable;
007 import org.bukkit.event.HandlerList;
008
009 /**
010 * Stores data for pigs being zapped
011 */
012 public class PigZapEvent extends EntityEvent implements Cancellable {
013 private static final HandlerList handlers = new HandlerList();
014 private boolean canceled;
015 private final PigZombie pigzombie;
016 private final LightningStrike bolt;
017
018 public PigZapEvent(final Pig pig, final LightningStrike bolt, final PigZombie pigzombie) {
019 super(pig);
020 this.bolt = bolt;
021 this.pigzombie = pigzombie;
022 }
023
024 public boolean isCancelled() {
025 return canceled;
026 }
027
028 public void setCancelled(boolean cancel) {
029 canceled = cancel;
030 }
031
032 @Override
033 public Pig getEntity() {
034 return (Pig) entity;
035 }
036
037 /**
038 * Gets the bolt which is striking the pig.
039 *
040 * @return lightning entity
041 */
042 public LightningStrike getLightning() {
043 return bolt;
044 }
045
046 /**
047 * Gets the zombie pig that will replace the pig, provided the event is
048 * not cancelled first.
049 *
050 * @return resulting entity
051 */
052 public PigZombie getPigZombie() {
053 return pigzombie;
054 }
055
056 @Override
057 public HandlerList getHandlers() {
058 return handlers;
059 }
060
061 public static HandlerList getHandlerList() {
062 return handlers;
063 }
064 }