mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-21 05:44:17 +00:00
Add EntityToggleSwimEvent and isSwimming / setSwimming API
This commit is contained in:
parent
f8b2086d60
commit
8ef78e74f2
2 changed files with 59 additions and 0 deletions
|
@ -325,6 +325,22 @@ public interface LivingEntity extends Attributable, Entity, Damageable, Projecti
|
||||||
*/
|
*/
|
||||||
public void setGliding(boolean gliding);
|
public void setGliding(boolean gliding);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks to see if an entity is swimming.
|
||||||
|
*
|
||||||
|
* @return True if this entity is swimming.
|
||||||
|
*/
|
||||||
|
public boolean isSwimming();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes entity start or stop swimming.
|
||||||
|
*
|
||||||
|
* This may have unexpected results if the entity is not in water.
|
||||||
|
*
|
||||||
|
* @param swimming True if the entity is swimming.
|
||||||
|
*/
|
||||||
|
public void setSwimming(boolean swimming);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether an entity will have AI.
|
* Sets whether an entity will have AI.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
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 swimming status is toggled.
|
||||||
|
*/
|
||||||
|
public class EntityToggleSwimEvent extends EntityEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private boolean cancel = false;
|
||||||
|
private final boolean isSwimming;
|
||||||
|
|
||||||
|
public EntityToggleSwimEvent(LivingEntity who, final boolean isSwimming) {
|
||||||
|
super(who);
|
||||||
|
this.isSwimming = isSwimming;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSwimming() {
|
||||||
|
return isSwimming;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue