Config Boolean need help fast

Discussion in 'Plugin Development' started by plarsootje, Jul 10, 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:
    List<String> inUseKits = new ArrayList<String>();
    Set<String> names = ConfigHandler.TeamDeathMatchKits.getConfigurationSection("Kits").getKeys(false);
            
    for (String keyString : ConfigHandler.TeamDeathMatchKits.getConfigurationSection("Kits" + "." + names).getKeys(false)){
                if (ConfigHandler.TeamDeathMatchKits.getBoolean("Kits" + "." + names+ keyString) == true){
               inUseKits.add(keyString);
                }
            }
            
    player.sendMessage("§aAviable kits: §f" + inUseKits);
    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 );
    }
    I've getting an error in the console a nullpointer error but i know why its because names goes in 1 string not the name seperated from eachother so how can i seperate the names and get the boolean?
    If you don't understand something please ask i wan't to get this working as fast as possible
     
  2. Offline

    JazzaG

    Null pointer? String? Separated? Eachother?
    Help me help you.
     
  3. i just need to get the kits that are in use sended to the player
     
  4. Offline

    CubieX

    is this your full config file?
    because you do
    Code:
    getConfigurationSection("Kits")
    but there is no section "Kits" in the given config in your start post.
     
  5. Offline

    Hoolean

    Don't put 'need help fast' in your thread title, it's just attention seeking and seems condescending as you're implying that you're more important and need help faster than anyone else in this sub-forum ._.
     
  6. Yeah ok but it is in the config "kits" and i know how to get a list but i need toget only the kits that hase inUse: TRUE. The kits that are false they may not show up in the list sended to the player
     
  7. Offline

    CubieX

    Can you show us the config file which holds the kits please?
    And also the part where you inizialize your custom FileConfiguration?

    Because obviously something around these lines is "null".
     
  8. I know whats null the "names" is null
    Names is aml the kits in a list
    So what it does is looking for "Kits" + "." + names
    So it looks for "kits"+"."+allthekits

    But i need to have a way that i get each kit seperated to find the "inUse"
    Because now it can't find the string names because it doesnt exists because the names is :" ninja,medic"
    I hope you understand it
     
  9. Offline

    soulofw0lf

    no one is going to help you if you don't show the code everyone has asked to see to be able to help you. It is impossible for us to know what's going on without seeing the things they've asked for.
     
  10. Noone will help me if im not showing the code then look good because i'vr posted the code!
     
  11. Offline

    Hoolean

    You've posted small snippets of everything and have not even posted the error, only it's name.

    For people to be able to help you easily, please supply your full code and full error.
     
  12. The error is a nullpointer error and i know its the names because it doesn't take the kits seperated look good at the code and maby someone finaly understand it because i know the problem and i already tried some time to explain it with everything i can do
     
  13. Offline

    Hoolean

    plarsootje

    I think I may have finally understood a bit of what you said :p

    Try changing your code to this:
    Code:java
    1. List<String> inUseKits = new ArrayList<String>();
    2. Set<String> names = ConfigHandler.TeamDeathMatchKits.getConfigurationSection("Kits").getKeys(false);
    3.  
    4. for (String name : names){
    5. if (ConfigHandler.TeamDeathMatchKits.getBoolean("Kits" + "." + name+".InUse")){
    6. inUseKits.add(name);
    7. }
    8. }
    9.  
    10. player.sendMessage("§aAvailable kits: §f" + inUseKits);
     
Thread Status:
Not open for further replies.

Share This Page