summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authort00thpick1 <t00thpick1dirko@gmail.com>2016-03-12 12:08:25 -0500
committermd_5 <git@md-5.net>2016-03-20 11:28:23 +1100
commit0b10b8e543444426153f48d4ec348ac15f4cf1f3 (patch)
tree15b0210f4d65608256892f7a1aba8520f1e3571d
parent485fc0c47004dcad63c4b425a25dfd9850bc3cb6 (diff)
downloadbukkit-0b10b8e543444426153f48d4ec348ac15f4cf1f3.tar
bukkit-0b10b8e543444426153f48d4ec348ac15f4cf1f3.tar.gz
bukkit-0b10b8e543444426153f48d4ec348ac15f4cf1f3.tar.lz
bukkit-0b10b8e543444426153f48d4ec348ac15f4cf1f3.tar.xz
bukkit-0b10b8e543444426153f48d4ec348ac15f4cf1f3.zip
SPIGOT-1904: AreaEffectCloud events and additional API
-rw-r--r--src/main/java/org/bukkit/entity/AreaEffectCloud.java15
-rw-r--r--src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java55
-rw-r--r--src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java58
3 files changed, 128 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/entity/AreaEffectCloud.java b/src/main/java/org/bukkit/entity/AreaEffectCloud.java
index c9d04db7..f88be2ff 100644
--- a/src/main/java/org/bukkit/entity/AreaEffectCloud.java
+++ b/src/main/java/org/bukkit/entity/AreaEffectCloud.java
@@ -6,6 +6,7 @@ import org.bukkit.Particle;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
+import org.bukkit.projectiles.ProjectileSource;
/**
* Represents an area effect cloud which will imbue a potion effect onto
@@ -207,4 +208,18 @@ public interface AreaEffectCloud extends Entity {
* @param color cloud color
*/
void setColor(Color color);
+
+ /**
+ * Retrieve the original source of this cloud.
+ *
+ * @return the {@link ProjectileSource} that threw the LingeringPotion
+ */
+ public ProjectileSource getSource();
+
+ /**
+ * Set the original source of this cloud.
+ *
+ * @param source the {@link ProjectileSource} that threw the LingeringPotion
+ */
+ public void setSource(ProjectileSource source);
}
diff --git a/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java b/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java
new file mode 100644
index 00000000..bf2e7513
--- /dev/null
+++ b/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java
@@ -0,0 +1,55 @@
+package org.bukkit.event.entity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.Validate;
+import org.bukkit.entity.AreaEffectCloud;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.ThrownPotion;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+
+/**
+ * Called when a lingering potion applies it's effects. Happens
+ * once every 5 ticks
+ */
+public class AreaEffectCloudApplyEvent extends EntityEvent {
+ private static final HandlerList handlers = new HandlerList();
+ private final List<LivingEntity> affectedEntities;
+
+ public AreaEffectCloudApplyEvent(final AreaEffectCloud entity, final List<LivingEntity> affectedEntities) {
+ super(entity);
+ this.affectedEntities = affectedEntities;
+ }
+
+ @Override
+ public AreaEffectCloud getEntity() {
+ return (AreaEffectCloud) getEntity();
+ }
+
+ /**
+ * Retrieves a mutable list of the effected entities
+ * <p>
+ * It is important to note that not every entity in this list
+ * is guaranteed to be effected. The cloud may die during the
+ * application of its effects due to the depletion of {@link AreaEffectCloud#getDurationOnUse()}
+ * or {@link AreaEffectCloud#getRadiusOnUse()}
+ *
+ * @return the affected entity list
+ */
+ public List<LivingEntity> getAffectedEntities() {
+ return affectedEntities;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java b/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java
new file mode 100644
index 00000000..09861a5b
--- /dev/null
+++ b/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java
@@ -0,0 +1,58 @@
+package org.bukkit.event.entity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.commons.lang.Validate;
+import org.bukkit.entity.AreaEffectCloud;
+import org.bukkit.entity.LingeringPotion;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.ThrownPotion;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+
+/**
+ * Called when a splash potion hits an area
+ */
+public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+ private final AreaEffectCloud entity;
+
+ public LingeringPotionSplashEvent(final ThrownPotion potion, final AreaEffectCloud entity) {
+ super(potion);
+ this.entity = entity;
+ }
+
+ @Override
+ public LingeringPotion getEntity() {
+ return (LingeringPotion) super.getEntity();
+ }
+
+ /**
+ * Gets the AreaEffectCloud spawned
+ *
+ * @return The spawned AreaEffectCloud
+ */
+ public AreaEffectCloud getAreaEffectCloud() {
+ return entity;
+ }
+
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ public void setCancelled(boolean cancel) {
+ cancelled = cancel;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}