use of org.bukkit.entity.Enderman in project acidisland by tastybento.
the class IslandGuard method onEndermanDeath.
/**
* Drops the Enderman's block when he dies if he has one
*
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (!Settings.endermanDeathDrop)
return;
if (!inWorld(e.getEntity())) {
return;
}
if (!(e.getEntity() instanceof Enderman)) {
// plugin.getLogger().info("Not an Enderman!");
return;
}
// Get the block the enderman is holding
Enderman ender = (Enderman) e.getEntity();
MaterialData m = ender.getCarriedMaterial();
if (m != null && !m.getItemType().equals(Material.AIR)) {
// Drop the item
// plugin.getLogger().info("Dropping item " + m.toString());
e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), m.toItemStack(1));
}
}
Aggregations