How do I add a YAML node without overwriting the others?
Posted: Sat Mar 24, 2012 5:32 am
I have this YAML file:
User: root: - 127.0.0.1And I want to be able to add a node under the "User" node (at the level where "root" is at), but when I do that, it overwrites previous nodes. I'm about 90% sure this is the wrong way to do it because I tried the handle the Set<String> just like a List<String>, but here's the code I'm using (in the LoginListener):
Set<String> userList = plugin.users.getConfigurationSection("User").getKeys(false); if (!userList.contains(playerName.getName().toLowerCase())){ userList.add(playerName.getName().toLowerCase()); plugin.users.set("User", userList); try{ plugin.users.save(plugin.usersFile); }catch (IOException e){ e.printStackTrace(); } }This is basically what I want the YAML file to look like afterwards, short of the specific IP addresses and/or usernames of course:
User: root: - 127.0.0.1 offluffy: - 192.168.2.3Unless another problem shows up, this is likely the last question you'll hear from me concerning this plugin XD Which maybe a relief to you since I started the last 4 or 5 threads in this section prior to this. .-. Hope that's not considered spamming XP