private void handleNpeDeath(Entity subject) { EntityDamageEvent cause = subject.getLastDamageCause(); // Increment the NPE's total death stat NpeData npeData = this.plugin.getNpeDataByClass(subject.getClass()); npeData.incTotalDeaths(); // Increment the ServerData statistics plugin.serverData.incNpesKilled(); if (cause instanceof EntityDamageByEntityEvent) { Entity predicate = ((EntityDamageByEntityEvent) cause).getDamager(); if (predicate instanceof Player) { // The NPE was killed by a player, reward them for their accomplishments PlayerData killerData = this.plugin.getPlayerData(((Player) predicate).getName(), ""); String mobName = this.plugin.getSimpleClassName(subject.getClass()).toLowerCase(); if (mobName.startsWith("craft")) { // it looks like a lot of the class names follow the format "CraftX", such as "CraftWolf" // or "CraftCreeper" mobName = mobName.substring(5); } if (killerData.getMobsKilled().containsKey(mobName)) { killerData.incMobsKilled(mobName); } else { plugin.log.info("MineJMX: A player killed an unknown mob type (\"" + mobName + "\")"); } // and increment the NPE's specific death stat npeData.incDeathsByPlayer(); } else { // The NPE was killed by another mob, increment NpeData statistics again NpeData killerData = this.plugin.getNpeDataByClass(predicate.getClass()); killerData.incNpesKilled(); // and increment the original NPE's specific death stat npeData.incDeathsByNpe(); } } else if (cause instanceof EntityDamageByBlockEvent) { // killed by environment, increment the specific death counter npeData.incDeathsByEnvironment(); } else { // drowned, burned, fell, etc...increment the environmental death counter switch (cause.getCause()) { case CONTACT: case DROWNING: case FALL: case FIRE: case FIRE_TICK: case LAVA: case LIGHTNING: npeData.incDeathsByEnvironment(); break; } } }