Class GameModeState
java.lang.Object
wbs.utils.util.entities.state.tracker.GameModeState
- All Implemented Interfaces:
org.bukkit.configuration.serialization.ConfigurationSerializable,EntityState<org.bukkit.entity.Player>
public class GameModeState
extends Object
implements EntityState<org.bukkit.entity.Player>, org.bukkit.configuration.serialization.ConfigurationSerializable
An
EntityState that captures the game mode a Player is currently in.- See Also:
-
HumanEntity.getGameMode()
-
Constructor Summary
ConstructorsConstructorDescriptionCreates the state with no starting value - if the state is restored, it will have no effectGameModeState(@Nullable org.bukkit.GameMode mode) -
Method Summary
Modifier and TypeMethodDescriptionvoidcaptureState(org.bukkit.entity.Player target) Capture the state of an instance ofEntityStateaccording to the implementation, and store it untilEntityState.restoreState(T)is called.static GameModeStatedeserialize(Map<String, Object> args) Deserializer method for converting aMapinto this object, for use inEntityStateManager@Nullable org.bukkit.GameModegetMode()@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.Player target) Restore the state of an instance ofEntityStateaccording to the implementation.voidsetMode(@Nullable org.bukkit.GameMode mode)
-
Constructor Details
-
GameModeState
public GameModeState()Creates the state with no starting value - if the state is restored, it will have no effect -
GameModeState
public GameModeState(@Nullable @Nullable org.bukkit.GameMode mode) - Parameters:
mode- The game mode the player is in.
-
-
Method Details
-
captureState
public void captureState(org.bukkit.entity.Player 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.Player>- Parameters:
target- TheEntityStatefrom which to capture.
-
restoreState
public void restoreState(org.bukkit.entity.Player target) Description copied from interface:EntityStateRestore the state of an instance ofEntityStateaccording to the implementation.- Specified by:
restoreStatein interfaceEntityState<org.bukkit.entity.Player>- Parameters:
target- TheEntityStatefor which to the stored state.
-
getMode
@Nullable public @Nullable org.bukkit.GameMode getMode()- Returns:
- The game mode the player is in.
-
setMode
public void setMode(@Nullable @Nullable org.bukkit.GameMode mode) - Parameters:
mode- The game mode the player is in.
-
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.Player>- 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
-