For loop through config booleans

Discussion in 'Plugin Development' started by HackintoshMan, Jul 16, 2013.

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

    HackintoshMan

    I have a config with command names in it.

    Code:
    Commands
        home: true
        spawn: false
        kill: true
    I need to create a for loop that will loop through all of the nodes of Commands (home, spawn, and kill) and I need to get the boolean values so that it know weather or not to register the command. How can I loop through all of those?
     
  2. Offline

    soulofw0lf

    for (String key : getConfig().getconfigurationSection("Commands").getKeys(false)){
    boolean currentKey = getConfig().getBoolean("Commands." + keys);
    //code to execute based on true or false example: if (currentKey){System.out.println(key + " is true);}
     
  3. Offline

    HackintoshMan

    Thanks, but now when I go to register the command, I need to get the class name. I name the command classes like this:

    CommandTime
    CommandHelp

    So now I need to loop through all of the classes to find the one that says Command<command_name> and create a class variable that I can use for the class name, right?
     
  4. Offline

    soulofw0lf

    are these preset? cause if so for each one you could just easily do if (getConfig().getBoolean("Commands.home"){//register CommandHome} ?
     
  5. Offline

    HackintoshMan

    What do you mean by preset?
     
Thread Status:
Not open for further replies.

Share This Page