hey guys, So, i found a problem in my plugin, it doesn't update an integer in the config when it should, im a little tired, so that might be the problem of that i couldnt find the solution There are no problems in my console. Anyways, here is my code: Code:java @EventHandler public void onDeath(PlayerDeathEvent e) { Player p = e.getEntity(); if(data.getConfigurationSection("stats." + p.getUniqueId()) == null) { p.sendMessage(ChatColor.BLUE + "ExperiencePvP> " + ChatColor.WHITE + "There is no section available for you!"); return; } data.set("stats." + p.getKiller().getUniqueId() + ".kills", data.getInt("stats." + p.getKiller().getUniqueId() + ".kills" + (int) 1)); data.set("stats." + p.getUniqueId() + ".deaths", data.getInt("stats." + p.getUniqueId() + ".deaths") + (int) 1); if(data.getInt("stats." + p.getKiller().getUniqueId() + ".kills") == (int) 0 || data.getInt("stats." + p.getKiller().getUniqueId() + ".deaths") == (int) 0) { return; } if(data.getInt("stats." + p.getUniqueId() + ".kills") == (int) 0 || data.getInt("stats." + p.getUniqueId() + ".deaths") == (int) 0) { return; } settings.saveData(); p.getKiller().sendMessage(ChatColor.BLUE + "ExperiencePvP> " + ChatColor.WHITE + "Congratulations on killing " + p.getName() + "!"); if (p.getKiller() == null) { data.set("stats." + p.getUniqueId() + ".deaths", data.getInt("stats." + p.getUniqueId() + ".deaths") + (int) 1); settings.saveData(); } }
iAmGuus Assuming 'data' isn't null and the rest of the code is correct, have you registered your events?
iAmGuus If you did register, add debug messages with syso. (System.out.println), you probably return somewhere before the actual saving.
I did register my events in the Main class. Im gonna try the debug messages for the kills now, because death updates work. Ok, so what works: the death update and the kill message, but the kill update doesnt. Here is my new code: Code:java @EventHandler public void onDeath(PlayerDeathEvent e) { Player p = e.getEntity(); Player killer = p.getKiller(); if (settings.getData().getConfigurationSection("stats." + p.getUniqueId()) == null) { p.sendMessage(ChatColor.BLUE + "ExperiencePvP> " + ChatColor.WHITE + "There is no section available for you!"); } settings.getData().set("stats." + killer.getUniqueId() + ".kills", settings.getData().getInt("stats." + killer.getUniqueId() + ".kills" + (int) 1)); settings.getData().set("stats." + p.getUniqueId() + ".deaths", settings.getData().getInt("stats." + p.getUniqueId() + ".deaths") + (int) 1); settings.saveData(); killer.sendMessage(ChatColor.BLUE + "ExperiencePvP> " + ChatColor.WHITE + "Congratulations on killing " + p.getName() + "!"); if (p.getKiller() == null) { settings.getData().set("stats." + p.getUniqueId() + ".deaths", settings.getData().getInt("stats." + p.getUniqueId() + ".deaths") + (int) 1); settings.saveData(); } } Bump EDIT by Moderator: merged posts, please use the edit button instead of double posting.
If your console has any errors, a stack trace would do wonders for us. I think part of your error is this Code: settings.getData().getInt("stats." + killer.getUniqueId() + ".kills" + (int) 1) This is essentially telling your getData() method to get a line from the config that says "stats.<players UUID>.kills1. Try this instead Code: settings.getData().set("stats." + killer.getUniqueId() + ".kills", settings.getData().getInt("stats." + killer.getUniqueId() + ".kills")+1);