Class StatusEffect
- java.lang.Object
-
- io.github.thebusybiscuit.slimefun4.api.player.StatusEffect
-
- All Implemented Interfaces:
Keyed
public class StatusEffect extends Object implements Keyed
A very simple API that is meant for adding/getting/clearing custom status effects to/from players. The effects are stored viaPersistentDataAPI
and use NBT data that is saved across server restarts. You can specify a level for your status effect too.- Author:
- TheBusyBiscuit
-
-
Constructor Summary
Constructors Constructor Description StatusEffect(NamespacedKey key)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Player p, int level, int duration, TimeUnit unit)
This applies thisStatusEffect
to the givenPlayer
.void
add(Player p, int duration, TimeUnit unit)
This applies thisStatusEffect
to the givenPlayer
.void
addPermanent(Player p, int level)
This applies thisStatusEffect
to the givenPlayer
.void
clear(Player p)
This will remove thisStatusEffect
from the givenPlayer
.NamespacedKey
getKey()
OptionalInt
getLevel(Player p)
This method returns anOptionalInt
describing the level of this status effect on that player.boolean
isPresent(Player p)
This will check whether thisStatusEffect
is currently applied to thatPlayer
.
-
-
-
Constructor Detail
-
StatusEffect
public StatusEffect(NamespacedKey key)
-
-
Method Detail
-
getKey
public NamespacedKey getKey()
-
add
public void add(Player p, int duration, TimeUnit unit)
This applies thisStatusEffect
to the givenPlayer
. You can specify a duration, this will referenceadd(Player, int, int, TimeUnit)
with a level of 1.
-
add
public void add(Player p, int level, int duration, TimeUnit unit)
This applies thisStatusEffect
to the givenPlayer
.
-
addPermanent
public void addPermanent(Player p, int level)
This applies thisStatusEffect
to the givenPlayer
. This will apply it permanently, there is no duration.- Parameters:
p
- ThePlayer
whom to apply the effect tolevel
- The level of this effect
-
isPresent
public boolean isPresent(Player p)
This will check whether thisStatusEffect
is currently applied to thatPlayer
. If the effect has expired, it will automatically remove all associated NBT data of this effect.- Parameters:
p
- ThePlayer
to check for- Returns:
- Whether this
StatusEffect
is currently applied
-
getLevel
public OptionalInt getLevel(Player p)
This method returns anOptionalInt
describing the level of this status effect on that player.- Parameters:
p
- ThePlayer
to check for- Returns:
- An
OptionalInt
that describes the result
-
clear
public void clear(Player p)
This will remove thisStatusEffect
from the givenPlayer
.- Parameters:
p
- ThePlayer
to clear it from
-
-