public class StatusEffect extends java.lang.Object implements Keyed
PersistentDataAPI
and use NBT data that is
saved across server restarts.
You can specify a level for your status effect too.Constructor and Description |
---|
StatusEffect(NamespacedKey key) |
Modifier and Type | Method and Description |
---|---|
void |
add(Player p,
int level,
int duration,
java.util.concurrent.TimeUnit unit)
This applies this
StatusEffect to the given Player . |
void |
add(Player p,
int duration,
java.util.concurrent.TimeUnit unit)
This applies this
StatusEffect to the given Player . |
void |
addPermanent(Player p,
int level)
This applies this
StatusEffect to the given Player . |
void |
clear(Player p)
This will remove this
StatusEffect from the given Player . |
NamespacedKey |
getKey() |
java.util.OptionalInt |
getLevel(Player p)
This method returns an
OptionalInt describing the level of this status
effect on that player. |
boolean |
isPresent(Player p)
This will check whether this
StatusEffect is currently applied
to that Player . |
public StatusEffect(NamespacedKey key)
public NamespacedKey getKey()
public void add(Player p, int duration, java.util.concurrent.TimeUnit unit)
StatusEffect
to the given Player
.
You can specify a duration, this will reference
add(Player, int, int, TimeUnit)
with a level of 1.p
- The Player
whom to apply the effect toduration
- The duration of how long that status effect shall lastunit
- The TimeUnit
for the given durationpublic void add(Player p, int level, int duration, java.util.concurrent.TimeUnit unit)
StatusEffect
to the given Player
.p
- The Player
whom to apply the effect tolevel
- The level of this effectduration
- The duration of how long that status effect shall lastunit
- The TimeUnit
for the given durationpublic void addPermanent(Player p, int level)
StatusEffect
to the given Player
.
This will apply it permanently, there is no duration.p
- The Player
whom to apply the effect tolevel
- The level of this effectpublic boolean isPresent(Player p)
StatusEffect
is currently applied
to that Player
.
If the effect has expired, it will automatically remove all associated
NBT data of this effect.p
- The Player
to check forStatusEffect
is currently appliedpublic java.util.OptionalInt getLevel(Player p)
OptionalInt
describing the level of this status
effect on that player.p
- The Player
to check forOptionalInt
that describes the resultpublic void clear(Player p)
StatusEffect
from the given Player
.p
- The Player
to clear it from