001 package org.bukkit.event.entity;
002
003 import org.bukkit.entity.Horse;
004 import org.bukkit.event.Cancellable;
005 import org.bukkit.event.HandlerList;
006
007 /**
008 * Called when a horse jumps.
009 */
010 public class HorseJumpEvent extends EntityEvent implements Cancellable {
011 private static final HandlerList handlers = new HandlerList();
012 private boolean cancelled;
013 private float power;
014
015 public HorseJumpEvent(final Horse horse, final float power) {
016 super(horse);
017 this.power = power;
018 }
019
020 public boolean isCancelled() {
021 return cancelled;
022 }
023
024 public void setCancelled(boolean cancel) {
025 cancelled = cancel;
026 }
027
028 @Override
029 public Horse getEntity() {
030 return (Horse) entity;
031 }
032
033 /**
034 * Gets the power of the jump.
035 * <p>
036 * Power is a value that defines how much of the horse's jump strength
037 * should be used for the jump. Power is effectively multiplied times
038 * the horse's jump strength to determine how high the jump is; 0
039 * represents no jump strength while 1 represents full jump strength.
040 * Setting power to a value above 1 will use additional jump strength
041 * that the horse does not usually have.
042 * <p>
043 * Power does not affect how high the horse is capable of jumping, only
044 * how much of its jumping capability will be used in this jump. To set
045 * the horse's overall jump strength, see {@link
046 * Horse#setJumpStrength(double)}.
047 *
048 * @return jump strength
049 */
050 public float getPower() {
051 return power;
052 }
053
054 /**
055 * Sets the power of the jump.
056 * <p>
057 * Jump power can be set to a value above 1.0 which will increase the
058 * strength of this jump above the horse's actual jump strength.
059 * <p>
060 * Setting the jump power to 0 will result in the jump animation still
061 * playing, but the horse not leaving the ground. Only canceling this
062 * event will result in no jump animation at all.
063 *
064 * @param power power of the jump
065 */
066 public void setPower(float power) {
067 this.power = power;
068 }
069
070 @Override
071 public HandlerList getHandlers() {
072 return handlers;
073 }
074
075 public static HandlerList getHandlerList() {
076 return handlers;
077 }
078 }