niceIp is basically the IP address with the dots replaced with underscores so it doesn't jack up the YAML file.
//Add the IP to users.yml if it isn't there already if (!ipList.contains(niceIp)){ plugin.users.set("Address." + niceIp, new ArrayList<String>()); try{ plugin.users.save(plugin.usersFile); }catch(IOException e){ e.printStackTrace(); } }This one just adds the node if it doesn't exist.
//Add the username under an IP node in users.yml if (plugin.users.getStringList("Address").contains(niceIp) && !(plugin.users.getStringList("Address." + niceIp).contains(niceName))){ List<String> ipUsers = plugin.users.getStringList("Address." + niceIp); ipUsers.add(niceName); plugin.users.set("Address." + niceIp, ipUsers); try{ plugin.users.save(plugin.usersFile); }catch (IOException e){ e.printStackTrace(); } }This one adds an entry to the node the previous one created, or adds another entry to the node if it already exists, if the entry doesn't already exist.
The problem I'm having is that the plugin isn't creating the new node or inserting any new values. I'm not sure why, I've looked over it countless times @.@
For reference, the file it's writing to is structured like this:
User: <username>: ips: - <IP Address> <username>: ips: - <IP Address> Address: <IP Address>: - <username> <IP Address>: - <username>IP addresses in the Address section have underscores instead of dots, i.e., 127_0_0_1
P.S. - The YAML syntax highlighting seems to have some alignment issues XD