Package wbs.utils.util.entities.state
Interface EntityState<T extends org.bukkit.entity.Entity>
- Type Parameters:
T- The Entity subclass this state may be used on
- All Known Implementing Classes:
AllowFlightState,FallDistanceState,FireTicksState,FlyingState,GameModeState,HealthState,HungerState,InventoryState,InvulnerableState,LocationState,PotionEffectsState,RemainingAirState,SaturationState,ScoreboardState,VelocityState,XPState
public interface EntityState<T extends org.bukkit.entity.Entity>
Represents a capture of some property of an entity, such
as health.
The data captured in EntityStates should be immutable to the game loop; that is, after capturing, it shouldn't matter what happens to the captured entity. When an entity is restored, the tracked state should be identical to the moment it was captured, unless the EntityState object was directly interacted with.
As an example, a captured ItemStack should appear the same after being restored as it did when captured, even if the original ItemStack had it's amount or ItemMeta changed.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcaptureState(T target) Capture the state of an instance ofEntityStateaccording to the implementation, and store it untilrestoreState(T)is called.@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(T target) Restore the state of an instance ofEntityStateaccording to the implementation.
-
Method Details
-
captureState
Capture the state of an instance ofEntityStateaccording to the implementation, and store it untilrestoreState(T)is called.- Parameters:
target- TheEntityStatefrom which to capture.
-
restoreState
Restore the state of an instance ofEntityStateaccording to the implementation.- Parameters:
target- TheEntityStatefor which to the stored state.
-
restoreAfter
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.- Returns:
- A set of classes to restore after, if present in a given
SavedEntityState.
-