Package wbs.utils.util.entities.state
Class SavedEntityState<T extends org.bukkit.entity.Entity>
java.lang.Object
wbs.utils.util.entities.state.SavedEntityState<T>
- All Implemented Interfaces:
org.bukkit.configuration.serialization.ConfigurationSerializable
- Direct Known Subclasses:
SavedLivingEntityState
public class SavedEntityState<T extends org.bukkit.entity.Entity>
extends Object
implements org.bukkit.configuration.serialization.ConfigurationSerializable
Represents a snapshot of an entity, tracking only specific qualities.
Can be captured and restored from entities to save an entity's state
before returning them to their former state later.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncaptureState(T target) Capture the tracked states for the given entity.static SavedEntityState<?>deserialize(Map<String, Object> args) restoreState(T target) Restore the captured states to the given entity.track(Collection<EntityState<? super T>> toTrack) Add multiple states to track.track(EntityState<? super T> toTrack) Add a new state to track.voidtrackAll()Add all known states that aren't already being tracked.trackIfAbsent(EntityState<? super T> toTrack) Add a new state to track, only if another of the same class has not been added.
-
Constructor Details
-
SavedEntityState
public SavedEntityState() -
SavedEntityState
-
-
Method Details
-
trackAll
public void trackAll()Add all known states that aren't already being tracked. If using an extending class, such asSavedPlayerState, additional states are tracked for the implementing classes entity type.Note that this does not use a concrete way of finding subclasses; the classpath is not scanned, and the generic parameter isn't used. This is manually implemented and will not reflect new changes without updating, including new trackable states created outside of WbsUtils.
-
track
Add multiple states to track. Overrides existing states if another state of the same class is already being tracked.- Parameters:
toTrack- The new states to track- Returns:
- The same object (for chaining)
-
track
Add a new state to track.- Parameters:
toTrack- The new state to track- Returns:
- The same object (for chaining)
-
trackIfAbsent
Add a new state to track, only if another of the same class has not been added.- Parameters:
toTrack- The new state to track- Returns:
- The same object (for chaining)
-
captureState
Capture the tracked states for the given entity.- Parameters:
target- The entity to capture states from.- Returns:
- The same object (for chaining)
-
restoreState
Restore the captured states to the given entity. The entity provided need not be the same entity the states were originally captured from.- Parameters:
target- The entity to restore the states to.- Returns:
- The same object (for chaining)
-
deserialize
-
serialize
- Specified by:
serializein interfaceorg.bukkit.configuration.serialization.ConfigurationSerializable
-