Solved Getting subnodes from .yml with a different path separator

Discussion in 'Plugin Development' started by Chinwe, Jun 21, 2013.

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

    Chinwe

    Hai.

    I'm saving IPs to a .yml, where the players' names are saved under that, ie:
    Code:
    127.0.0.1:
    - Chinwe
    - AnotherPlayer
    I am using commas as the path separator for the .yml, which works fine for writing. But when I try to get all the IPs from the file, it seems to use . as the path separator again:

    Code:
    for (String s : ipStore.getConfigurationSection("ipStore").getKeys(false))
    This only prints out the first part of the IP, such as "127".

    Code:
    .getKeys(true)
    This prints out each part of each IP, like this:

    Is there any way to get every IP in one piece?

    Thanks in advance :>
     
  2. Offline

    Alex5657

    Just get every fourth key in the set and get the list by it.
     
  3. Offline

    Chinwe

    I thought about that but thought there had to be another, more efficient way :c

    But it seems that the answer is nice and simple again, thanks :>
     
  4. Offline

    slayr288

    chinwe
    When you get the ip and store it, replace the '.' with a '-' for example, and then when you get the ip, just replace back the '.'.

    Edit example:
    Code:
            String ip = "127.0.0.1";
            ip.replace('.', '-');
            //store ip

    Code:
            //get ip
            ip.replace('-', '.');
     
Thread Status:
Not open for further replies.

Share This Page