// Spawn Boss public void spawnBoss(Location location, String bossName) { ConfigurationSection bossSection = instance.getConfig().getConfigurationSection("bosses." + bossName); LivingEntity bossMob = location.getWorld().spawn(location, Skeleton.class); bossMob.setCustomName(chat.colorize(bossSection.getString("display-name"))); bossMob.setMaxHealth(bossSection.getDouble("health")); bossMob.setHealth(bossSection.getDouble("health")); } // EntityDeathEvent (check if the entity's name equals a boss name in the config) @EventHandler public void onBossDeath(EntityDeathEvent event) { LivingEntity mob = event.getEntity(); Player killer = event.getEntity().getKiller(); System.out.println("Custom Name " + mob.getCustomName()); // Returns null even though the mob killed has a name tag if(killer == null) return; if(mob.getCustomName() == null) return; if(mob.getEquipment().getItemInHand() == null) return; ConfigurationSection bossSection = instance.getConfig().getConfigurationSection("bosses"); for(String boss : bossSection.getKeys(false)) { if(mob.getCustomName().equals(chat.colorize(instance.getConfig().getString("bosses." + boss + ".display-name")))) { event.getDrops().clear(); for(String command : bossSection.getStringList(boss + ".rewards")) { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replace("%player%", killer.getName())); } } } }