mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-26 06:24:54 +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);
|
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.
|
* 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.
|
* Removes all the effects currently applied to the entity.
|
||||||
*
|
|
||||||
* @param potion The potion to add
|
|
||||||
*/
|
*/
|
||||||
public void addEffect(@NotNull Potion potion) {
|
public void clearEffects() {
|
||||||
removeEffect(potion.getEffect());
|
for (TimedPotion timedPotion : effects) {
|
||||||
this.effects.add(new TimedPotion(potion, System.currentTimeMillis()));
|
timedPotion.getPotion().sendRemovePacket(this);
|
||||||
potion.sendAddPacket(this);
|
callEvent(EntityPotionRemoveEvent.class, new EntityPotionRemoveEvent(
|
||||||
callEvent(EntityPotionAddEvent.class, new EntityPotionAddEvent(this, potion));
|
this,
|
||||||
|
timedPotion.getPotion()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
this.effects.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user