geforkt von Mirrors/Paper
SPIGOT-1904: AreaEffectCloud events and additional API
By: t00thpick1 <t00thpick1dirko@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
b9403026cd
Commit
4bfc4d66d9
@ -6,6 +6,7 @@ import org.bukkit.Particle;
|
|||||||
import org.bukkit.potion.PotionData;
|
import org.bukkit.potion.PotionData;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an area effect cloud which will imbue a potion effect onto
|
* 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
|
* @param color cloud color
|
||||||
*/
|
*/
|
||||||
void setColor(Color 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);
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren