Why doesnt \n work when getting a line from a config

Discussion in 'Spigot Plugin Development' started by Kyllian, Apr 24, 2017.

  1. Hey, I'm trying to kick a player with a line from the config

    \n worked fine before. But since I get it from the config, It doesn't work.

    This is my code:

    Code (Text):
    String kickMessage = sys32.getConfig().getString("KickMessage");
                    if (s instanceof Player) {
                        Player p = (Player) s;
                        kickMessage = kickMessage.replace("%player%", p.getName());
                    } else {
                        kickMessage = kickMessage.replace("%player%", "CONSOLE");
                    kickMessage = kickMessage.replace("%reason%", str);
                    return true;
    What's wrong?
  2. try using:

    Code (Java):

    string = string.replace("\\n", "\n");
    • Winner Winner x 1
    • Useful Useful x 1
  3. Nice, works. Can you explain why I should do that tho. I'm sure I only enter one \
  4. "\n" is literally just the characters. The actual new line which we specify as \n is its own character interpreted by the OS.