Solved Get previous inventory opened ?

Discussion in 'Spigot Plugin Development' started by Drawethree, May 23, 2017.

  1. Hey guys, im doing a gui plugin and each gui will have a door ( that will open main menu ) and lever ( which will opens previous menu ). How can i check for previous gui opened for player ?
  2. have 1 menu that has every GUI section your player can goto, and then send them to that, insted of sending them back to the previous GUI
  3. I simply use a Callback.
  4. HashMaps?
  5. Store the data in a map each time they click on a 'door' in the main inventory, mapping player UUID to Inventory. When they then go to click to go back to the previous inventory, via another 'door', you can simple use map#get(uuid) to get the inventory they previously had open, then send them to that. Once you did that, remove the previous map entry, and add the one they just came from. This way youll always have a way to access the inventory the player had just opened. Make sure to account for the fact that they may close the inventory and reopen it as well, removing data as necessary.
    • Agree Agree x 1
  6. That was what I was thinking
    • Like Like x 1
  7. Code (Text):
    Map<UUID, Inventory> back = new HashMap<UUID, Inventory>();

    back.put(player.getUniqueId(), inv);

    //GO BACK