001 package org.bukkit.event.player; 002 003 import org.bukkit.entity.Entity; 004 import org.bukkit.entity.Player; 005 import org.bukkit.event.Cancellable; 006 import org.bukkit.event.HandlerList; 007 008 /** 009 * Represents an event that is called when a player right clicks an entity. 010 */ 011 public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellable { 012 private static final HandlerList handlers = new HandlerList(); 013 protected Entity clickedEntity; 014 boolean cancelled = false; 015 016 public PlayerInteractEntityEvent(final Player who, final Entity clickedEntity) { 017 super(who); 018 this.clickedEntity = clickedEntity; 019 } 020 021 public boolean isCancelled() { 022 return cancelled; 023 } 024 025 public void setCancelled(boolean cancel) { 026 this.cancelled = cancel; 027 } 028 029 /** 030 * Gets the entity that was rightclicked by the player. 031 * 032 * @return entity right clicked by player 033 */ 034 public Entity getRightClicked() { 035 return this.clickedEntity; 036 } 037 038 @Override 039 public HandlerList getHandlers() { 040 return handlers; 041 } 042 043 public static HandlerList getHandlerList() { 044 return handlers; 045 } 046 }