Need help with boolean Config

Discussion in 'Plugin Development' started by plarsootje, Jun 24, 2013.

Thread Status:
Not open for further replies.
  1. Hello,
    I'm working on a plugin and i need to firgure out how i do this:
    I have a customconfig with all kind of kits
    i have a command where you can see what kits are in use
    players can set the visebility by change the boolean "InUse" to false
    look at the code this can maby help because i can't explain it well :)

    Getting the list for the command:
    Code:
            Set<String> names = ConfigHandler.TeamDeathMatchKitsConfig.getConfigurationSection("Kits").getKeys(false);
            boolean InUse = ConfigHandler.TeamDeathMatchKitsConfig.getBoolean("Kits" + "." + names + "." +  "InUse");
            player.sendMessage("§6Kit: §f/tdm kit <kit>"+"\n§2Aviable Kits:" + "\n§a" + names);
    Config
    Code:
      Ninja:
        InUse: true
        Armor:
          Helmet: 302
          Chestplate: 303
          Leggings: 304
          Boots: 305
        Items:
          Item1: 276
          Amount1: 1
          Item2: 0
          Amount2: 1
          Item3: 0
          Amount3: 1
          Item4: 0
          Amount4: 1
          Item5: 0
          Amount5: 1
      Medic:
        InUse: true
        Armor:
          Helmet: 298
          Chestplate: 299
          Leggings: 300
          Boots: 301
        Items:
          Item1: 331
          Amount1: 1
          Item2: 0
          Amount2: 1
          Item3: 0
          Amount3: 1
          Item4: 0
          Amount4: 1
          Item5: 0
          Amount5: 1
    So i want to have that something like
    Code:
    for(boolean that is true) {
    player.sendMessage(all the booleans that are true );
    }
    If you don't understand something please ask i wan't to get this working as fast as possible
     
  2. So, you want to cycle through all the Kits, and send a Message, which contains all Kits which are inUse?
     
  3. Yeah
     
  4. plarsootje
    Code:java
    1.  
    2. Set<String> names = ConfigHandler.TeamDeathMatchKitsConfig.getConfigurationSection("Kits").getKeys(false);
    3.  
    4. String kitsInUse = "Following Kits are in use: ";
    5. for(int i = 0;i < names.Size();i++)
    6. {
    7. if(ConfigHandler.TeamDeathMatchKitsConfig.getBoolean("Kits" + "." + names[I][I] + "." + "InUse")[/I][/I]
    8. [I]kitsInUse += name + ",";[/I]
    9. [I]}[/I]
    10.  
    11. [I]p.sendMessage(kitsInUse);[/I]
    12. [I][/I]
     


  5. Thanks for the reply
    I get a error under

    if(ConfigHandler.TeamDeathMatchKitsConfig.getBoolean("Kits" + "." + names + "." + "InUse"))

    "type of expession must be an arry"
     
  6. yea sry, the Editor fucked up, use names[ i ]
     
  7. still get the error

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
Thread Status:
Not open for further replies.

Share This Page