GUI contents

Discussion in 'Spigot Plugin Development' started by TheFuzzyHead5, May 31, 2017.

  1. How can I reset the location of an itemstack in a GUI without reopening it?
     
  2. What do you mean by resetting the location?
     
    • Informative Informative x 1
  3. Set it to null? As in
    Code (Text):
    inventory.setItem(slot, null);
    Or you can just completely replace it without setting it to null by just setting it to another item.
     
  4. You can create a new inventory with a different position of the item, and make the player open it.
     
  5. Honestly you can just keep a reference to the Inventory object, and manipulate it using (as @Virizion said) setItem(oldSlot, null) and setItem(newSlot, the item). The inventory should update itself without having to close/reopen.
     
  6. From what I leanred you can't just change the item in the gui you have to change it in the players opened gui. Like so:
    Code (Text):
    player.getOpenInventory().setItem(Inetger, ItemStack);