public class Kill implements Listener{ @EventHandler public void on(PlayerDeathEvent e){ Player za = e.getEntity().getKiller(); int kill = Main.getKills(); Main.cfg.getInt("Kills." + za.getName(), kill+1); try { Main.cfg.save(Main.file); } catch (IOException e1) { e1.printStackTrace(); } }
There is so much wrong with this code... I don't know where to begin. Please show us the code of the main class, your config and your stack trace.
Main public static File file = new File("plugins/Dead", "deads.yml"); public static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file); public void onEnable(){ this.getServer().getPluginManager().registerEvents(new Dead(), this); this.getServer().getPluginManager().registerEvents(new Kill(), this); try { cfg.load(file); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (InvalidConfigurationException e) { e.printStackTrace(); } try { cfg.save(file); } catch (IOException e) { e.printStackTrace(); } } public void onDisable(){ try { cfg.save(file); } catch (IOException e) { e.printStackTrace(); } } public static int getDeaths() { return cfg.getInt("Deads", 0); } public static int getKills(){ return cfg.getInt("Kills", 0); } } And ? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Plugers11 -------------------------------------------------^ (code button) Could you use the code button to show your code please.