Solved Loop through string list from config and display the text. [HELP]

Discussion in 'Plugin Development' started by dan14941, May 3, 2014.

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

    dan14941

    What the title says.

    Here is bits of the code im trying:
    Code:
    @Override
        public void onEnable()
        {
            config.options().header("Add your custom ranks below!");
            String[] defaultRanks = {"admin","moderator","co-owner"};
        }
     
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
        {
    if(commandLabel.equalsIgnoreCase("staff"))
            {
                player.sendMessage(ChatColor.BLUE + "== " + ChatColor.DARK_AQUA + "Lorem Craft Server Info Plugin - by: dan14941" + ChatColor.BLUE + " ==");
                player.sendMessage(ChatColor.DARK_BLUE + "                      STAFF LIST"); //55
                player.sendMessage(ChatColor.YELLOW + "Server Owner: " + ChatColor.GOLD + config.getString("Staff.owner.name") + s + online(config.getString("Staff.owner.name")));
               
                for(int i = 0; i < config.getStringList("Staff.ranks").size(); i++)
                {
                    player.sendMessage(ChatColor.YELLOW + config.getString("Staff.ranks" + i));
                }
            }
           
            return true;
        }
    when i run the command it just says in teh chat: null
     
  2. Offline

    Wizehh

    Err.. try this?
    PHP:
    for (String str config.getStringList("Staff.ranks") {
        
    player.sendMessage(str);
    }
    Oh, and
    {config.getString("Staff.ranks" + i));} - you'd want to add a dot to the end of 'ranks' if you wanted to get a node.
     
    dan14941 and hintss like this.
  3. Offline

    dan14941

    Wizehh Thanx so much just restating my pc

    Wizehh I love you <3

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

Share This Page