diff options
author | James Logsdon <dwarf@girsbrain.org> | 2011-02-11 16:49:51 -0500 |
---|---|---|
committer | Erik Broes <erikbroes@grum.nl> | 2011-02-12 01:09:42 +0100 |
commit | 82931a601d556de2396cb9f1b740e7cbbd329616 (patch) | |
tree | 8959705b8b1fb72096f9702a48dd9d4ab533d282 /src/main/java | |
parent | 71f97ffc5b3368a758123f161d33ad6931fc87df (diff) | |
download | craftbukkit-82931a601d556de2396cb9f1b740e7cbbd329616.tar craftbukkit-82931a601d556de2396cb9f1b740e7cbbd329616.tar.gz craftbukkit-82931a601d556de2396cb9f1b740e7cbbd329616.tar.lz craftbukkit-82931a601d556de2396cb9f1b740e7cbbd329616.tar.xz craftbukkit-82931a601d556de2396cb9f1b740e7cbbd329616.zip |
Adding PLAYER_DROP_ITEM event hook
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityHuman.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index a72c046f..2e3e7177 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -4,9 +4,12 @@ import java.util.List; // CraftBukkit start import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.entity.CraftItemDrop; +import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerDropItemEvent; // CraftBukkit end public abstract class EntityHuman extends EntityLiving { @@ -216,6 +219,22 @@ public abstract class EntityHuman extends EntityLiving { entityitem.motZ += Math.sin((double) f1) * (double) f; } + // CraftBukkit start + Player player = (Player)this.getBukkitEntity(); + CraftServer server = ((WorldServer)world).getServer(); + CraftItemDrop drop = new CraftItemDrop(server, entityitem); + PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); + server.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + org.bukkit.inventory.ItemStack stack = drop.getItemStack(); + stack.setAmount(1); + player.getInventory().addItem(stack); + + return; + } + // CraftBukkit end + this.a(entityitem); } } |