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

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

package org.bukkit.event.entity;

import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.Pig;
import org.bukkit.entity.PigZombie;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

/**
 * Stores data for pigs being zapped
 */
public class PigZapEvent extends EntityEvent implements Cancellable {
  private static final HandlerList handlers = new HandlerList();
  private final PigZombie pigzombie;
  private final LightningStrike bolt;
  private boolean canceled;

  public PigZapEvent(final Pig pig, final LightningStrike bolt, final PigZombie pigzombie) {
    super(pig);
    this.bolt = bolt;
    this.pigzombie = pigzombie;
  }

  public static HandlerList getHandlerList() {
    return handlers;
  }

  public boolean isCancelled() {
    return canceled;
  }

  public void setCancelled(boolean cancel) {
    canceled = cancel;
  }

  @Override
  public Pig getEntity() {
    return (Pig) entity;
  }

  /**
   * Gets the bolt which is striking the pig.
   *
   * @return lightning entity
   */
  public LightningStrike getLightning() {
    return bolt;
  }

  /**
   * Gets the zombie pig that will replace the pig, provided the event is
   * not cancelled first.
   *
   * @return resulting entity
   */
  public PigZombie getPigZombie() {
    return pigzombie;
  }

  @Override
  public HandlerList getHandlers() {
    return handlers;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy