Solved Multiple lines with getString not working?

Discussion in 'Spigot Plugin Development' started by Sean0402, Jun 14, 2019 at 11:03 PM.

Thread Status:
Not open for further replies.
  1. Hey all, I've been having an issue with displaying multiple lines with the getString from the config method.

    Here is my code;
    config.yml
    Code (Text):

    test: |-
      - 't'
      - 'g'
      - 't'
      - 'bb'
    Commands.yml issue
    Code (Text):
    if(args[0].equalsIgnoreCase("test")){
                for(final String messages : plugin.getConfig().getStringList("test")){
                    p.sendMessage(ChatColor.translateAlternateColorCodes('&', messages));
                    return true;
                }
    Returns this in-game;
    https://imgur.com/uBjJ29v
     
  2. Well you're looping over a string list and then exiting after the first iteration. You probably meant to put return true outside the closing bracket? Also why are you using final in a loop?
     
    • Informative Informative x 1
  3. You're exiting after the first element of the collection has been iterated over and you do not allow for other elements to be sent. Move the return true statement outside of the loop.
     
    • Informative Informative x 1
  4. Thanks both. Also, Eclipse adds that final statement by default because of my settings. I haven't disabled that yet.
     
Thread Status:
Not open for further replies.

Share This Page