config.getValues not working

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

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

    TheBoy3

    I want to retrieve a list of nodes from the config, but my plugin doesn't seem to send the player anything, even though the list isn't null. Here is my code:

    Code:java
    1.  
    2. if (args.length == 0) {
    3. Collection<Object> configkitscoll = config.getConfigurationSection("kit.").getValues(false).values();
    4. String[] configkits = (String[]) configkitscoll.toArray();
    5. if (configkits.length != 0 && configkits != null) {
    6. player.sendMessage(configkits);
    7. } else {
    8. player.sendMessage(ChatColor.GREEN + "No kits were found.");
    9. }
    10. }
    11.  


    How can I fix this?
     
  2. Offline

    ZeusAllMighty11

    change
    Code:
    String[] configkits = (String[]) configkitscoll.toArray();
    
    to

    Code:
    String[] configkits = configkitscoll.toArray(new String[configkits.size()]);
     
  3. Offline

    travja

    Try removing the period out of .getConfigurationSection("kits.")
     
  4. Offline

    TheBoy3

    That gives me errors, so I tried configkitscoll.size() and it still doesn't work.

    Nope, doesn't work that way either :(
     
  5. Offline

    travja

    Map<String, Object> temp = spawns.getConfigurationSection("Spawns").getValues(false); This is what I use in HungerArena... then I loop through the entrySet()... try this I guess...
     
Thread Status:
Not open for further replies.

Share This Page