Getting single line from config list

Discussion in 'Plugin Development' started by thapengwin, Apr 18, 2013.

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

    thapengwin

    I have a config, and the part I want to get looks like this:
    Code:
    ignore-ip:
    - youriphere
    - 127-0-0-1
    (the IP is separated by dashes because java doesn't like dots. Yes, I've got the player's IP and replaced all dots with dashes)
    I want to scan the whole list and look for my IP (127-0-0-1, aka localhost), and if it finds my IP I want it to do this:
    Code:
    e.disallow(null, ChatColor.RED + "You can not change usernames! Please join as " + player.getName());
            for (Player player1 : getServer().getOnlinePlayers()) {
                if (player1.hasPermission("NoDupeIP.notify"))
                   player1.sendMessage(ChatColor.DARK_RED + player.getName() + "(" + player.getAddress().getAddress().getHostAddress().replace(".", "-") + ")" + " tried to join with a changed username!");
    Thanks for your help!
     
  2. thapengwin
    Java has nothing to do with that, it's YML that doesn't like dots and the reason is because they're used as a path separator for the loader... which you can change to something else (in config.options() I belive) to allow use of dots...
    or I belive you need to enclose them in single quotes... e.g. - '127.0.0.1'.

    But you'd just want to use config.getStringList("path") and check if contains(ipString)... if you're keeping the dash thing you should convert dots to dashes for ipString before checking contains.
     
Thread Status:
Not open for further replies.

Share This Page