Class VelocityState
java.lang.Object
wbs.utils.util.entities.state.tracker.VelocityState
- All Implemented Interfaces:
org.bukkit.configuration.serialization.ConfigurationSerializable,EntityState<org.bukkit.entity.Entity>
public class VelocityState
extends Object
implements EntityState<org.bukkit.entity.Entity>, org.bukkit.configuration.serialization.ConfigurationSerializable
An
EntityState that captures an Entity's current velocity.- See Also:
-
Entity.getVelocity()
-
Constructor Summary
ConstructorsConstructorDescriptionCreates the state with the no velocity set.VelocityState(@NotNull org.bukkit.util.Vector velocity) -
Method Summary
Modifier and TypeMethodDescriptionvoidcaptureState(org.bukkit.entity.Entity target) Capture the state of an instance ofEntityStateaccording to the implementation, and store it untilEntityState.restoreState(T)is called.static VelocityStatedeserialize(Map<String, Object> args) Deserializer method for converting aMapinto this object, for use inEntityStateManager@Nullable org.bukkit.util.Vector@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.Entity target) Restore the state of an instance ofEntityStateaccording to the implementation.voidsetVelocity(@Nullable org.bukkit.util.Vector velocity)
-
Constructor Details
-
VelocityState
public VelocityState()Creates the state with the no velocity set. -
VelocityState
public VelocityState(@NotNull @NotNull org.bukkit.util.Vector velocity) - Parameters:
velocity- The current velocity of the entity.
-
-
Method Details
-
captureState
public void captureState(org.bukkit.entity.Entity 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.Entity>- Parameters:
target- TheEntityStatefrom which to capture.
-
restoreState
public void restoreState(org.bukkit.entity.Entity target) Description copied from interface:EntityStateRestore the state of an instance ofEntityStateaccording to the implementation.- Specified by:
restoreStatein interfaceEntityState<org.bukkit.entity.Entity>- Parameters:
target- TheEntityStatefor which to the stored state.
-
getVelocity
@Nullable public @Nullable org.bukkit.util.Vector getVelocity()- Returns:
- The current velocity of the entity.
-
setVelocity
public void setVelocity(@Nullable @Nullable org.bukkit.util.Vector velocity) - Parameters:
velocity- The current velocity of the entity.
-
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.Entity>- 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
-