null error in trying to call a list out of a map from config.yml

Discussion in 'Plugin Development' started by soulofw0lf, Apr 16, 2013.

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

    soulofw0lf

    **warning - very new to coding
    i have tried everything i can think of to try to get a list of titles that are stored in my config to be sent to the player as messages and nothing i have tried works.

    Code:
    current config setup referenced
     
    players:
        player1name:
            titles:
            - title1
            - title2
            - title3
        player2name:
            titles:
            - title1
            - title3
     
     
    call to send message code line
        Player p = Bukkit.getPlayer(args[1]);
            if (p == null) {
                sender.sendMessage("Could Not Find Player!!");
                return true;
                }
              List<String> s = this.Ach.getConfig().getStringList("players." + p + ".titles");
              sender.sendMessage(s + " - ");
     
     
    Ach is defined earlier to reference my main class that get config is defined in.
    what i expect to be outputed with player1name as the args[1] value
    title1 - title2 - title3 -

    with a valid player name instead of returning the titles the player has, all i'm getting sent to chat is
    [] -

    any help anyone could provide would be greatly appreciated!!!!
     
  2. Offline

    StevenMG

    You should be getting the value or players.playername, but instead you are trying to get players.playername.titles.

    The config you are showing does not have .titles anywhere.
     
  3. Offline

    soulofw0lf

    that was an error on my part, just forgot to write them into the example here, it's been updated to reflect that.
     
Thread Status:
Not open for further replies.

Share This Page