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

org.bukkit.event.hanging.HangingPlaceEvent Maven / Gradle / Ivy

package org.bukkit.event.hanging;

import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

/**
 * Triggered when a hanging entity is created in the world
 */
public class HangingPlaceEvent extends HangingEvent implements Cancellable {
  private static final HandlerList handlers = new HandlerList();
  private final Player player;
  private final Block block;
  private final BlockFace blockFace;
  private boolean cancelled;

  public HangingPlaceEvent(final Hanging hanging, final Player player, final Block block, final BlockFace blockFace) {
    super(hanging);
    this.player = player;
    this.block = block;
    this.blockFace = blockFace;
  }

  public static HandlerList getHandlerList() {
    return handlers;
  }

  /**
   * Returns the player placing the hanging entity
   *
   * @return the player placing the hanging entity
   */
  public Player getPlayer() {
    return player;
  }

  /**
   * Returns the block that the hanging entity was placed on
   *
   * @return the block that the hanging entity was placed on
   */
  public Block getBlock() {
    return block;
  }

  /**
   * Returns the face of the block that the hanging entity was placed on
   *
   * @return the face of the block that the hanging entity was placed on
   */
  public BlockFace getBlockFace() {
    return blockFace;
  }

  public boolean isCancelled() {
    return cancelled;
  }

  public void setCancelled(boolean cancel) {
    this.cancelled = cancel;
  }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy