update Buttons For State
Updates the inventory GUI to reflect the buttons associated with the current state. This method clears the existing inventory, applies a background if specified, and sets the buttons mapped to the current state into the inventory.
Steps performed in this method:
Retrieves the list of buttons for the current state from
buttonMappings
.Clears the inventory to prepare for the new buttons.
Applies the background to the inventory, if defined.
Adds the buttons to the inventory and sets each button in its respective slot.
Updates the player's inventory to reflect these changes immediately.
It uses:
buttonMappings
: A map linking states to button configurations.applyBackground()
: Applies a visual background to the inventory.setItems(List<Button>)
: Updates the GUI items list with the current buttons.inventory.setItem(slot, item)
: Places individual buttons into their designated slots.player.updateInventory()
: Ensures the player's view is updated with any changes made to the GUI.
If the current state doesn't have mapped buttons, the inventory will remain empty aside from the background if one is applied.
This function assumes that currentState
has been set and that buttonMappings
contains a valid mapping for the state.