diff options
author | md_5 <git@md-5.net> | 2018-07-15 16:17:23 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-07-15 16:17:23 +1000 |
commit | 8ef78e74f2ed68035d59fc97ac6c5adc476e15c1 (patch) | |
tree | fdbb220e601441093306378c68f42dd758e24368 | |
parent | f8b2086d60942eb2cd7ac25a2a1408cb790c222c (diff) | |
download | bukkit-8ef78e74f2ed68035d59fc97ac6c5adc476e15c1.tar bukkit-8ef78e74f2ed68035d59fc97ac6c5adc476e15c1.tar.gz bukkit-8ef78e74f2ed68035d59fc97ac6c5adc476e15c1.tar.lz bukkit-8ef78e74f2ed68035d59fc97ac6c5adc476e15c1.tar.xz bukkit-8ef78e74f2ed68035d59fc97ac6c5adc476e15c1.zip |
Add EntityToggleSwimEvent and isSwimming / setSwimming API
-rw-r--r-- | src/main/java/org/bukkit/entity/LivingEntity.java | 16 | ||||
-rw-r--r-- | src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java | 43 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java index 8b2fb74c..97c2172b 100644 --- a/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java @@ -326,6 +326,22 @@ public interface LivingEntity extends Attributable, Entity, Damageable, Projecti 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. * * @param ai whether the mob will have AI or not. diff --git a/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java b/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java new file mode 100644 index 00000000..87b11044 --- /dev/null +++ b/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java @@ -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; + } +} |