Quick question.

Discussion in 'Plugin Development' started by maxxb123, Apr 11, 2014.

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

    maxxb123

    Alright, so let's say, I wanted to create a command called /hi

    It'd tell the player a random message from the config.yml file. How would that work? I'm clueless. :p Any help?
     
  2. Offline

    Brixishuge

    Code:
    section = plugin.getConfig().getConfigurationSection("SECTION_NAME")
    section.getString(sectionname.message)
    
    That will help...

    edit:

    just saw you want to add random message, you can gather all messages as explained above, add them to arraylist and retrieve random item from it, how to take random item from ArrayList is explained here:

    http://stackoverflow.com/questions/5034370/retrieving-a-random-item-from-arraylist
     
  3. Offline

    maxxb123

    Brixishuge, I know it's a late response, but how would I add the message from the config.yml file to the ArayList?
     
  4. Offline

    Brixishuge

    maxxb123

    I believe it's:

    Code:
    section = plugin.getConfig().getConfigurationSection("SECTION_NAME")
    somearraylist.add(section.getString(sectionname.message))
    
     
    Konkz likes this.
  5. Offline

    Rocoty

    maxxb123 If you are using a list in the config it is pretty simple. Just use the getStringList method from config. However I do not know if this is the case. Would you kindly show us how you have your config set up?
     
Thread Status:
Not open for further replies.

Share This Page