Hi there, I'm having a small issue with the code. The purpose of the code is to count all the dead entities in specific world "TestWorld". The problem is that the code completely ignores the name of the world and counts the beings regardless of the worlds in which they are being killed. Any ideas? Spoiler: Code Code (Text): public void killZombie(EntityDeathEvent e) { Entity deadEntity = e.getEntity(); Entity killer = e.getEntity().getKiller(); if(killer.getLocation().getWorld().getName().equalsIgnoreCase("TestWorld")) { if(deadEntity.getLocation().getWorld().getName().equalsIgnoreCase("TestWorld")) { if (((killer instanceof Player)) && ((deadEntity instanceof Zombie))) { int killCount = this.configGetter.getConfig().getInt("ZombieKills"); this.configGetter.getConfig().set("ZombieKills", Integer.valueOf(killCount + 1)); saveConfig(); } } } }
Are you sure you don't have code duplicated elsewhere that does this without checking the world? Additionally you don't need to use the Integer class on (killCount + 1) I'm also a bit confused by your "configGetter" which doesn't actually get the config you get than get it after?
Just chedked, I don't have the code duplicated. Can anyone think of an alternative ways of checking the world?
How about this Code (Text): public void killZombie(EntityDeathEvent e, World world) It's hard to understand you're code, I'll make a better version Code (Text): for(Entity e : Bukkit.getWorld(p.getName).getEntitiesByClass(Zombie.class, Skeleton.class) { config blah blah e.remove() That's kinda pseudo code, just mess around with it
Still can't get it to work Spoiler: Code Code (Text): public void killZombie(EntityDeathEvent e, World w) { Entity deadEntity = e.getEntity(); Entity killer = e.getEntity().getKiller(); Player p = (Player)e.getEntity().getKiller(); for(Entity f : Bukkit.getWorld(p.getName()).getEntitiesByClass(Zombie.class)) { if(killer.getLocation().getWorld().getName().equalsIgnoreCase("TestWorld")) { if (((killer instanceof Player)) && ((deadEntity instanceof Zombie))) { int killCount = this.configGetter.getConfig().getInt("ZombieKills"); this.configGetter.getConfig().set("ZombieKills", Integer.valueOf(killCount + 1)); saveConfig(); } } } } Update: After many hours I finally got it to work. The code which I've posted originally is correct.