Class StatusEffect
java.lang.Object
io.github.thebusybiscuit.slimefun4.api.player.StatusEffect
- All Implemented Interfaces:
net.kyori.adventure.key.Keyed,org.bukkit.Keyed
A very simple API that is meant for adding/getting/clearing custom status effects
to/from players.
The effects are stored via
PersistentDataAPI 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidThis applies thisStatusEffectto the givenPlayer.voidThis applies thisStatusEffectto the givenPlayer.voidaddPermanent(org.bukkit.entity.Player p, int level) This applies thisStatusEffectto the givenPlayer.voidclear(org.bukkit.entity.Player p) This will remove thisStatusEffectfrom the givenPlayer.org.bukkit.NamespacedKeygetKey()getLevel(org.bukkit.entity.Player p) This method returns anOptionalIntdescribing the level of this status effect on that player.booleanisPresent(org.bukkit.entity.Player p) This will check whether thisStatusEffectis currently applied to thatPlayer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bukkit.Keyed
key
-
Constructor Details
-
StatusEffect
public StatusEffect(@Nonnull org.bukkit.NamespacedKey key)
-
-
Method Details
-
getKey
@Nonnull public org.bukkit.NamespacedKey getKey()- Specified by:
getKeyin interfaceorg.bukkit.Keyed
-
add
This applies thisStatusEffectto the givenPlayer. You can specify a duration, this will referenceadd(Player, int, int, TimeUnit)with a level of 1.- Parameters:
p- ThePlayerwhom to apply the effect toduration- The duration of how long that status effect shall lastunit- TheTimeUnitfor the given duration
-
add
public void add(@Nonnull org.bukkit.entity.Player p, int level, int duration, @Nonnull TimeUnit unit) This applies thisStatusEffectto the givenPlayer.- Parameters:
p- ThePlayerwhom to apply the effect tolevel- The level of this effectduration- The duration of how long that status effect shall lastunit- TheTimeUnitfor the given duration
-
addPermanent
public void addPermanent(@Nonnull org.bukkit.entity.Player p, int level) This applies thisStatusEffectto the givenPlayer. This will apply it permanently, there is no duration.- Parameters:
p- ThePlayerwhom to apply the effect tolevel- The level of this effect
-
isPresent
public boolean isPresent(@Nonnull org.bukkit.entity.Player p) This will check whether thisStatusEffectis currently applied to thatPlayer. If the effect has expired, it will automatically remove all associated NBT data of this effect.- Parameters:
p- ThePlayerto check for- Returns:
- Whether this
StatusEffectis currently applied
-
getLevel
This method returns anOptionalIntdescribing the level of this status effect on that player.- Parameters:
p- ThePlayerto check for- Returns:
- An
OptionalIntthat describes the result
-
clear
public void clear(@Nonnull org.bukkit.entity.Player p) This will remove thisStatusEffectfrom the givenPlayer.- Parameters:
p- ThePlayerto clear it from
-