use of com.elmakers.mine.bukkit.api.event.MagicMobDeathEvent in project MagicPlugin by elBukkit.
the class MobController method onEntityDeath.
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDeath(EntityDeathEvent event) {
// TODO: fix all of this, don't reference by names.
Entity entity = event.getEntity();
if (!(entity instanceof LivingEntity)) {
return;
}
LivingEntity died = (LivingEntity) entity;
String name = died.getCustomName();
if (name == null || name.isEmpty()) {
return;
}
// TODO Fix this
EntityData mob = mobsByName.get(name);
if (mob == null)
return;
MagicMobDeathEvent deathEvent = new MagicMobDeathEvent(controller, mob, event);
Bukkit.getPluginManager().callEvent(deathEvent);
if (!died.hasMetadata("nodrops")) {
mob.modifyDrops(controller, event);
}
// Prevent double-deaths .. gg Mojang?
// Kind of hacky to use this flag for it, but seemed easiest
died.setCustomNameVisible(false);
died.setCustomName(null);
}
Aggregations