001 package org.bukkit.event.entity; 002 003 import org.bukkit.entity.Entity; 004 import org.bukkit.entity.Player; 005 import org.bukkit.event.Cancellable; 006 import org.bukkit.event.Event; 007 import org.bukkit.event.HandlerList; 008 009 /** 010 * Called immediately prior to a creature being leashed by a player. 011 */ 012 public class PlayerLeashEntityEvent extends Event implements Cancellable { 013 private static final HandlerList handlers = new HandlerList(); 014 private final Entity leashHolder; 015 private final Entity entity; 016 private boolean cancelled = false; 017 private final Player player; 018 019 public PlayerLeashEntityEvent(Entity what, Entity leashHolder, Player leasher) { 020 this.leashHolder = leashHolder; 021 this.entity = what; 022 this.player = leasher; 023 } 024 025 /** 026 * Returns the entity that is holding the leash. 027 * 028 * @return The leash holder 029 */ 030 public Entity getLeashHolder() { 031 return leashHolder; 032 } 033 034 /** 035 * Returns the entity being leashed. 036 * 037 * @return The entity 038 */ 039 public Entity getEntity() { 040 return entity; 041 } 042 043 /** 044 * Returns the player involved in this event 045 * 046 * @return Player who is involved in this event 047 */ 048 public final Player getPlayer() { 049 return player; 050 } 051 052 @Override 053 public HandlerList getHandlers() { 054 return handlers; 055 } 056 057 public static HandlerList getHandlerList() { 058 return handlers; 059 } 060 061 public boolean isCancelled() { 062 return this.cancelled; 063 } 064 065 public void setCancelled(boolean cancel) { 066 this.cancelled = cancel; 067 } 068 }