Class PotionEffectsState
java.lang.Object
wbs.utils.util.entities.state.tracker.PotionEffectsState
- All Implemented Interfaces:
org.bukkit.configuration.serialization.ConfigurationSerializable,EntityState<org.bukkit.entity.LivingEntity>
public class PotionEffectsState
extends Object
implements EntityState<org.bukkit.entity.LivingEntity>, org.bukkit.configuration.serialization.ConfigurationSerializable
An
EntityState that captures a LivingEntity's currently active potion effects.- See Also:
-
LivingEntity.getActivePotionEffects()
-
Constructor Summary
ConstructorsConstructorDescriptionCreates the state with no potion effects.PotionEffectsState(@NotNull Collection<org.bukkit.potion.PotionEffect> effects) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEffect(@NotNull org.bukkit.potion.PotionEffect effect) voidcaptureState(org.bukkit.entity.LivingEntity target) Capture the state of an instance ofEntityStateaccording to the implementation, and store it untilEntityState.restoreState(T)is called.static PotionEffectsStatedeserialize(Map<String, Object> args) Deserializer method for converting aMapinto this object, for use inEntityStateManager@NotNull Collection<org.bukkit.potion.PotionEffect>@NotNull Set<Class<? extends EntityState<?>>>Used to build a graph of captured states, allowing states to be restored in the appropriate order, such as restoringAllowFlightStateafterGameModeState, to prevent a change toGameMode.SURVIVALfrom overriding thePlayer.getAllowFlight()state.voidrestoreState(org.bukkit.entity.LivingEntity target) Restore the state of an instance ofEntityStateaccording to the implementation.voidsetEffects(@NotNull Collection<org.bukkit.potion.PotionEffect> effects)
-
Constructor Details
-
PotionEffectsState
public PotionEffectsState()Creates the state with no potion effects. -
PotionEffectsState
- Parameters:
effects- A collection of potion effects to track
-
-
Method Details
-
captureState
public void captureState(org.bukkit.entity.LivingEntity target) Description copied from interface:EntityStateCapture the state of an instance ofEntityStateaccording to the implementation, and store it untilEntityState.restoreState(T)is called.- Specified by:
captureStatein interfaceEntityState<org.bukkit.entity.LivingEntity>- Parameters:
target- TheEntityStatefrom which to capture.
-
restoreState
public void restoreState(org.bukkit.entity.LivingEntity target) Description copied from interface:EntityStateRestore the state of an instance ofEntityStateaccording to the implementation.- Specified by:
restoreStatein interfaceEntityState<org.bukkit.entity.LivingEntity>- Parameters:
target- TheEntityStatefor which to the stored state.
-
getEffects
- Returns:
- A collection of potion effects to track
-
setEffects
- Parameters:
effects- A collection of potion effects to track
-
addEffect
public void addEffect(@NotNull @NotNull org.bukkit.potion.PotionEffect effect) - Parameters:
effect- A single potion effect to add to be tracked
-
restoreAfter
Description copied from interface:EntityStateUsed to build a graph of captured states, allowing states to be restored in the appropriate order, such as restoringAllowFlightStateafterGameModeState, to prevent a change toGameMode.SURVIVALfrom overriding thePlayer.getAllowFlight()state.- Specified by:
restoreAfterin interfaceEntityState<org.bukkit.entity.LivingEntity>- Returns:
- A set of classes to restore after, if present in a given
SavedEntityState.
-
deserialize
Deserializer method for converting aMapinto this object, for use inEntityStateManager- Parameters:
args- The partially deserialized Map.- Returns:
- An instance of this class, deserialized from args.
-
serialize
- Specified by:
serializein interfaceorg.bukkit.configuration.serialization.ConfigurationSerializable
-