Solved How to get inventory name?

Discussion in 'Spigot Plugin Development' started by devonzimmi, Nov 18, 2019.

  1. So I'm creating a GUI that is going to have different pages. I want to distinguish the GUI inventories by name but I can't figure out how to grab the inventory's name. I've found threads explaining how to grab the name from getTitle but that is only available through an event listener. I also read somewhere that it was impossible to get the title from the object itself, but you can cast it to something to enable you access to the title. I've lost the source and am having trouble figuring this out.

    Can someone point me in the right direction of grabbing an inventory name?

    ** Please only post a code snippet if you're also going to explain it or post an article explaining the subject. I don't mean to sound ungrateful but I don't want to be spoon fed code. I want to understand so I can implement it into future projects. **
     
  2. Hi, you should save the inventory (Object) in some custom object like CustomInventory where you keep track of them and give an identificator
     
    • Useful Useful x 1
  3. I didn't think about that. That would fix this issue as well as clean up and shorten my whole project. Thank you so much! :)

    Edit: Marking as solved but will be allowing for more posts in case someone still wants to post their solution for other people possibly needing the same thing as I did.
     
    • Friendly Friendly x 1
  4. Valentina_pro

    Valentina_pro Previously TemperTantrum

  5. While you could do that it's not the "right way" and also won't work for all inventory types.