Solved Fetching and setting items from a config file

Discussion in 'Spigot Plugin Development' started by MrFishCakes, Apr 22, 2017.

Thread Status:
Not open for further replies.
  1. Hello,
    I am messing around with somethings for a GUI. Server owners will be able to add the custom items they set in the config into the GUI. I know how to make the GUIs and trigger events and such but how can I fetch the set item from the config and then place it in the GUI? And how would I also be able to replace all of the %target% with the actual target player's name? My config.yml would look like this:
    Code (YAML):

    GUI
    :
      Main
    :
        Size
    : 54
        Name
    : '&cPunish &7> &c%target%'
      Items
    :
        1
    :
          Name
    : '&cBan'
          Lore
    : '&eAn example lore'
          Command
    : 'ban %target% %reason%'
          Slot
    : 5
          Item
    : DIRT
        2
    :
          Name
    : '&cMute'
          Lore
    : '&eAnother lore'
          Command
    : 'mute %target% %reason%'
          Slot
    : 18
          Item
    : STONE
     
     
  2. Learn how yml works and use the data to create an itemstack. You could replace the placeholders with string.replace("%target%", p.getName());
     
  3. Why not just make a configuration file in a similar format?

    Code (Text):

    item:
          Item-1:
                 name: ""
                 lore:
                 - 'My Lore'
                 item: GOLD_INGOT
     
    Etc

    Then you can iterate over each item and get the strings as needed.
     
Thread Status:
Not open for further replies.