mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-19 05:31:32 +01:00
SPIGOT-1571: Add Entity Glide Events.
By: 0x277F <0x277F@gmail.com>
This commit is contained in:
parent
2fe89bac6f
commit
8c8383109a
2 changed files with 65 additions and 0 deletions
|
@ -366,4 +366,19 @@ public interface LivingEntity extends Attributable, Entity, Damageable, Projecti
|
||||||
* @return whether the operation was successful
|
* @return whether the operation was successful
|
||||||
*/
|
*/
|
||||||
public boolean setLeashHolder(Entity holder);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue