diff options
author | 0x277F <0x277F@gmail.com> | 2016-03-09 20:14:05 -0700 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-03-12 21:00:41 +1100 |
commit | 58b2aab4746e91a03e5f67b9f8b864ca0d21aaba (patch) | |
tree | 550b0d3292f23e1dc70132346729a8fc8fcc72fb /src/main | |
parent | 98e11881045219287f7b00cca66a4698b6023baa (diff) | |
download | bukkit-58b2aab4746e91a03e5f67b9f8b864ca0d21aaba.tar bukkit-58b2aab4746e91a03e5f67b9f8b864ca0d21aaba.tar.gz bukkit-58b2aab4746e91a03e5f67b9f8b864ca0d21aaba.tar.lz bukkit-58b2aab4746e91a03e5f67b9f8b864ca0d21aaba.tar.xz bukkit-58b2aab4746e91a03e5f67b9f8b864ca0d21aaba.zip |
SPIGOT-1571: Add Entity Glide Events.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/bukkit/entity/LivingEntity.java | 15 | ||||
-rw-r--r-- | src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java | 50 |
2 files changed, 65 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java index 46347b9c..3582d2ff 100644 --- a/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java @@ -366,4 +366,19 @@ public interface LivingEntity extends Attributable, Entity, Damageable, Projecti * @return whether the operation was successful */ public boolean setLeashHolder(Entity holder); + + /** + * Checks to see if an entity is gliding, such as using an Elytra. + * @return True if this entity is gliding. + */ + public boolean isGliding(); + + /** + * Makes entity start or stop gliding. This will work even if an Elytra + * is not equipped, but will be reverted by the server immediately after + * unless an event-cancelling mechanism is put in place. + * @param gliding True if the entity is gliding. + */ + public void setGliding(boolean gliding); + } diff --git a/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java b/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java new file mode 100644 index 00000000..67fbf8fb --- /dev/null +++ b/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java @@ -0,0 +1,50 @@ +package org.bukkit.event.entity; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Sent when an entity's gliding status is toggled with an Elytra. + * Examples of when this event would be called: + * <ul> + * <li>Player presses the jump key while in midair and using an Elytra</li> + * <li>Player lands on ground while they are gliding (with an Elytra)</li> + * </ul> + * This can be visually estimated by the animation in which a player turns horizontal. + */ +public class EntityToggleGlideEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + + private boolean cancel = false; + private final boolean isGliding; + + public EntityToggleGlideEvent(LivingEntity who, final boolean isGliding) { + super(who); + this.isGliding = isGliding; + } + + @Override + public boolean isCancelled() { + return cancel; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } + + public boolean isGliding() { + return isGliding; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + +} |