Loop based on config number?

Discussion in 'Plugin Development' started by FreakyPear5, Mar 6, 2020.

Thread Status:
Not open for further replies.
  1. Hi everyone!
    I've got a really weird request..
    I'm making a plugin with a GUI that needs to have icons that are changeable in the Config file.
    How would I go about making a loop that, based on a number set in the Config file, creates new icons?
    I know how to grab things from the Config file, just not sure about how to do it in an int for loop.
    Could someone please help me?

    Thank you!
    Lawrence H.
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. So far I have this:

    Code:
    # Please configure the maps that you want to display on the GUI.
    maps:
     
       # Amount of maps to display
       count: 1
       # Name of inventory
       name: "MapVotes"
       # Size of inventory
       size: 36
     
     
       1:
          # Name of icon - you can also use color codes.
          name: "Example"
          # Type of block that you want to use.
          block: "WOOL"
          # Slot that you want it to be in in the GUI.
          location: 15
    I want the user to be able to type as many icons as they want going down in 1,2,3 etc. and the plugin gets them in a loop and turns them into items.
     
    Last edited by a moderator: Mar 6, 2020
  4. Offline

    timtower Administrator Administrator Moderator

    @FreakyPear5 You can use ConfigurationSection#getKeys(false) to get all nodes in a section.
     
  5. Ok thank you, and how would i make it run the same thing that number of times so that I can get it to make the ItemStacks for the GUI?
     
  6. Offline

    Kars

    @FreakyPear5 google "Java variables" and "Java for loop"
     
  7. Ok will do thanks, wasn't sure what to look up before :p
     
Thread Status:
Not open for further replies.

Share This Page