Getting an item name from an InventoryClickEvent

Discussion in 'Plugin Development' started by harvmaster, Aug 29, 2015.

Thread Status:
Not open for further replies.
  1. Offline


    Hi so I have been trying to check the name of an item in my gui shop but I have no clue how to get the name from. I have managed to get the type of the item but that is about it.
    If anyone could please help me it would be very appreciated.
    Thanks in advanced,
  2. Offline


    With an InventoryClickEvent call e.getCurrentItem().getItemMeta().getDisplayName().
  3. Offline


    @stefvanschie Well this way its kinda spoonfeeding, Keep it down please.
    The thing is that your code isnt null safe, if the item is null, or it has no item meta it will throw a nasty npe :/
    instead you need to check first if the item isnt null, it has item meta and a display name before doing that ^
  4. Offline


    @mine-care How would I've been able to give less code. If I would he still wouldn't know anything. I assumed he know that he would check for npe's. Offtopic: Why does everbody here hate spoonfeeding?
  5. @stefvanschie You'd be surprised.
    Offtopic: because it doesn't help people learn. They just copy the code and never try to understand it.
    mine-care likes this.
  6. Offline


    @bwfcwalshy Oh, I assumed people looked at the code and try to understand it, but it seems like I'm to only one then.
  7. Offline



    To start with, showing the least code possible isnt good. You need to make sure that what you provide will work and will not misslead someone or cause them problems later on. Being correct when you answer a question is vital.

    Now to the offtopic part, Spoonfeefing is not good because talking from experience most if not all users will just copy it paste it and then come up saying "Your code is wrong" and even if it works for them, they wont get any knowledge from it. Also getting the code from others, puting it in an arangement and passing as a plugin you made isnt right dont you think?

    anyway :- )
  8. Offline


    @harvmaster You're looking for the material name or the name from the itemMeta ?
  9. Offline


    Thank you guys for all of your help, hopefully this is what I am looking for.

    OffTopic: I personally have nothing against spoon feeding if it is not an extremely complex block of code where you can just kind of look and have an understanding. But if you are just giving somebody and entire block of code for something kind of easy then I don't really think that's the right thing to do because as you said, a lot of people will just copy and paste it and throw blames at people if it didn't work for them.
Thread Status:
Not open for further replies.

Share This Page