From 6cc56b8c2ccd6ae3b01aac549ca2a1c694818065 Mon Sep 17 00:00:00 2001 From: Feildmaster Date: Mon, 17 Oct 2011 07:38:03 -0500 Subject: [PATCH] Added ItemDespawnEvent --- src/main/java/net/minecraft/server/EntityItem.java | 11 ++++++++++- .../bukkit/craftbukkit/event/CraftEventFactory.java | 13 ++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java index d314cef97e..40c148ca5e 100644 --- a/src/main/java/net/minecraft/server/EntityItem.java +++ b/src/main/java/net/minecraft/server/EntityItem.java @@ -1,6 +1,9 @@ package net.minecraft.server; -import org.bukkit.event.player.PlayerPickupItemEvent; // CraftBukkit +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.player.PlayerPickupItemEvent; +// CraftBukkit End public class EntityItem extends Entity { @@ -83,6 +86,12 @@ public class EntityItem extends Entity { ++this.e; ++this.b; if (this.b >= 6000) { + // CraftBukkit start + if(CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { + this.b = 0; + return; + } + // CraftBukkit end this.die(); } } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 17438f7c3d..a5f834280d 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -141,7 +141,6 @@ public class CraftEventFactory { /** * Player Interact event */ - public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, ItemStack itemstack) { if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) { throw new IllegalArgumentException(); @@ -286,6 +285,18 @@ public class CraftEventFactory { return event; } + /** + * ItemDespawnEvent + */ + public static ItemDespawnEvent callItemDespawnEvent(EntityItem entityitem) { + org.bukkit.entity.Entity entity = entityitem.getBukkitEntity(); + + ItemDespawnEvent event = new ItemDespawnEvent(entity, entity.getLocation()); + + ((CraftServer) entity.getServer()).getPluginManager().callEvent(event); + return event; + } + /** * BlockFadeEvent */