Class InventoryState
java.lang.Object
wbs.utils.util.entities.state.tracker.InventoryState
- All Implemented Interfaces:
org.bukkit.configuration.serialization.ConfigurationSerializable,EntityState<org.bukkit.entity.Player>
public class InventoryState
extends Object
implements EntityState<org.bukkit.entity.Player>, org.bukkit.configuration.serialization.ConfigurationSerializable
- See Also:
-
HumanEntity.getInventory()PlayerInventory.getHeldItemSlot()
-
Constructor Summary
ConstructorsConstructorDescriptionCreates the state with no items or item slot configured.InventoryState(org.bukkit.inventory.ItemStack[] contents) InventoryState(org.bukkit.inventory.ItemStack[] contents, int itemSlot) -
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 InventoryStatedeserialize(Map<String, Object> args) Deserializer method for converting aMapinto this object, for use inEntityStateManager@Nullable org.bukkit.inventory.ItemStack[]int@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.voidsetContents(org.bukkit.inventory.ItemStack[] contents) voidsetItemSlot(int itemSlot)
-
Constructor Details
-
InventoryState
public InventoryState()Creates the state with no items or item slot configured. -
InventoryState
public InventoryState(org.bukkit.inventory.ItemStack[] contents) - Parameters:
contents- The items to track
-
InventoryState
public InventoryState(org.bukkit.inventory.ItemStack[] contents, int itemSlot) - Parameters:
contents- The items to trackitemSlot- The item slot (0-8, representing slots 1-9 in the hotbar) to track.
-
-
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.
-
getContents
@Nullable public @Nullable org.bukkit.inventory.ItemStack[] getContents()- Returns:
- The items to track
-
setContents
public void setContents(org.bukkit.inventory.ItemStack[] contents) - Parameters:
contents- The items to track
-
getItemSlot
public int getItemSlot()- Returns:
- The item slot (0-8, representing slots 1-9 in the hotbar) to track.
-
setItemSlot
public void setItemSlot(int itemSlot) - Parameters:
itemSlot- The item slot (0-8, representing slots 1-9 in the hotbar) to track.
-
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
-