[Bleeding] Added new target events. Fixes BUKKIT-935

This commit is contained in:
feildmaster
2012-03-09 15:40:59 -06:00
committed by EvilSeph
parent a967d6e371
commit 77ef051095
7 changed files with 59 additions and 35 deletions

View File

@@ -430,7 +430,13 @@ public class CraftEventFactory {
}
public static EntityTargetEvent callEntityTargetEvent(Entity entity, Entity target, EntityTargetEvent.TargetReason reason) {
EntityTargetEvent event = new EntityTargetEvent(entity.getBukkitEntity(), target.getBukkitEntity(), reason);
EntityTargetEvent event = new EntityTargetEvent(entity.getBukkitEntity(), target == null ? null : target.getBukkitEntity(), reason);
entity.getBukkitEntity().getServer().getPluginManager().callEvent(event);
return event;
}
public static EntityTargetLivingEntityEvent callEntityTargetLivingEvent(Entity entity, EntityLiving target, EntityTargetEvent.TargetReason reason) {
EntityTargetLivingEntityEvent event = new EntityTargetLivingEntityEvent(entity.getBukkitEntity(), (LivingEntity) target.getBukkitEntity(), reason);
entity.getBukkitEntity().getServer().getPluginManager().callEvent(event);
return event;
}
@@ -458,7 +464,6 @@ public class CraftEventFactory {
public static ItemStack callPreCraftEvent(InventoryCrafting matrix, ItemStack result, InventoryView lastCraftView, boolean isRepair) {
CraftInventoryCrafting inventory = new CraftInventoryCrafting(matrix, matrix.resultInventory);
inventory.setResult(new CraftItemStack(result));
PrepareItemCraftEvent event = new PrepareItemCraftEvent(inventory, lastCraftView, isRepair);
Bukkit.getPluginManager().callEvent(event);