List Help

Discussion in 'Plugin Development' started by CarlosArias604, May 30, 2012.

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

    CarlosArias604

    Hello Bukkit community! I need your help, To get straight to point here it is:
    - I need to make a list
    - My Java isn't the best so this could be some obvious reason
    - This is just for learning purposes at the moment
    - Whoever answers gets a metaphorical cookie, Yes a metaphorical cookie

    My code:
    Code:
                if (args.length == 1){
                    if (args[1].equalsIgnoreCase("rules")){
                        player.sendMessage(getConfig().getStringList("Rules"));
     
                    }       
                }
    (Yes it's a "Sub Command")

    Thank you for your time and hopefully someone can correct me!

    Sincerely
    Carlos
     
  2. Offline

    Njol

    Since you didn't really specify what you want to do I'll just guess:
    Code:
                if (args.length == 1){
                    if (args[0].equalsIgnoreCase("rules")){
                        for (String line : getConfig().getStringList("Rules")) {
                            player.sendMessage(line);
                        }
                    }     
                }
    This code send each line in "rules" to the player separately (i.e. on a new line)
     
    CarlosArias604 likes this.
  3. Offline

    r0306

    CarlosArias604
    All you have to do is assign the value of the config's stringlist to a list variable.
    Code:
    List<String> list = player.sendMessage(getConfig().getStringList("Rules"));
     
    CarlosArias604 likes this.
Thread Status:
Not open for further replies.

Share This Page