mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-27 14:13:24 +02:00
Added Entity#clearEffects
This commit is contained in:
parent
1fda2aba6d
commit
77148338b9
@ -1261,6 +1261,18 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
|
||||
return Collections.unmodifiableList(effects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an effect to an entity.
|
||||
*
|
||||
* @param potion The potion to add
|
||||
*/
|
||||
public void addEffect(@NotNull Potion potion) {
|
||||
removeEffect(potion.getEffect());
|
||||
this.effects.add(new TimedPotion(potion, System.currentTimeMillis()));
|
||||
potion.sendAddPacket(this);
|
||||
callEvent(EntityPotionAddEvent.class, new EntityPotionAddEvent(this, potion));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes effect from entity, if it has it.
|
||||
*
|
||||
@ -1281,15 +1293,17 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an effect to an entity.
|
||||
*
|
||||
* @param potion The potion to add
|
||||
* Removes all the effects currently applied to the entity.
|
||||
*/
|
||||
public void addEffect(@NotNull Potion potion) {
|
||||
removeEffect(potion.getEffect());
|
||||
this.effects.add(new TimedPotion(potion, System.currentTimeMillis()));
|
||||
potion.sendAddPacket(this);
|
||||
callEvent(EntityPotionAddEvent.class, new EntityPotionAddEvent(this, potion));
|
||||
public void clearEffects() {
|
||||
for (TimedPotion timedPotion : effects) {
|
||||
timedPotion.getPotion().sendRemovePacket(this);
|
||||
callEvent(EntityPotionRemoveEvent.class, new EntityPotionRemoveEvent(
|
||||
this,
|
||||
timedPotion.getPotion()
|
||||
));
|
||||
}
|
||||
this.effects.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user