1.8.8 GUI item actions

Discussion in 'Spigot Plugin Development' started by Lukacizek, Jan 14, 2022.

  1. Items:
    "DELETE_ITEM":
    Name: "Delete the item"
    Slot: 10
    Lore:
    -Amogus is sus
    Material: BARRIER
    Action: "DELETE_CUBE"

    Basically i want when the item is clicked it gets its action name from config where the item is.
    I want to make it so every action has its own class and in that class there is a method execute where its specified what the action does

    All help is appreciated
     
    • Optimistic Optimistic x 2
  2. maxresdefault.jpg
     
    • Funny Funny x 5
  3. 1) You have already received answers on the previous thread.
    2) Don't spam the forum with the same threads.
     
    • Funny Funny x 1
  4. Hello
     
    • Optimistic Optimistic x 2
  5. No point in making another thread.
     
  6. You guys flooded the other one with unnessecarry replies
     
    • Funny Funny x 4
    • Friendly Friendly x 1
    • Optimistic Optimistic x 1
  7. I actually found a thread where somebody had the same exact issue as you check here
    All of the answers are pretty solid.
     
    • Informative Informative x 2
    • Winner Winner x 1
  8. Those anwsers are not what i was looking for,.please get out of my thread and stop flooding it
     
    • Funny Funny x 2
    • Optimistic Optimistic x 1
  9. What exactly are you looking for your question was answered pretty clearly and accurately.

    1. Backtrack the item to the config
    2. find action
    3. use action in event if item matches

    ^ this is way less detailed than my previous answer on the last thread, but it exactly asks what you want. You will not be spoonfed code.
     
  10. I think you have the wrong idea of what this category is for, its for helping other people with code, no one is going to spoon food for you here.

    What have you tried so far?
    What are you struggling with?
     
    • Agree Agree x 2
  11. No idea how to do that
     
    • Winner Winner x 1
  12. Did you at least put any effort to trying or you waiting for imaginary supply drops of code?
     
  13. Well if you are building items from a configuration file there is obviously going to be some form of data on that item that would lead back to that item. Specifically since its in a GUI you can exploit its slot number.
    InventoryClickEvent 1.8.8
    Now I like to store my GUI's in memory on top of having them in the config so this is much more of a trivial task for me as I'd call the InventoryBuilder and extract the information I need to continue without looping through the whole config, however if you do need to do that I would loop through everything grab until slot is equal to what you need it to be. Use that section and grab the action. This can all be done in a static method and you can pass it around to wherever you need. Now granted we are working with configuration files here I would check more than just the slot to be safe.

    Code (Java):
    public static String getActionFromConfig(FileConfiguration config, ItemStack stack){
    // loop through config or grab data needed for path
      // other logic follows
    return action
    }
     
    #13 Y2K_, Jan 16, 2022
    Last edited: Jan 16, 2022
  14. ... how do i get the path of item that player clicked in config like maybe search for slot and then search where it has that slot number
     
    • Funny Funny x 1
  15. https://tryitands.ee/

    Also you havent asked my question, What are you struggling with, it seems like you are just waiting for somone to give you the code which isnt going to happen
     
    • Winner Winner x 2