testserver/CraftBukkit-Patches/0040-PlayerItemDamageEvent....

35 lines
1.4 KiB
Diff

From ac384dd63995c6eb516756b2b0c0b93712038c84 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Mon, 4 Mar 2013 18:45:52 +1100
Subject: [PATCH] PlayerItemDamageEvent
---
src/main/java/net/minecraft/server/ItemStack.java | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
index 3043db9..e3db554 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -161,7 +161,16 @@ public final class ItemStack {
}
i -= k;
- if (i <= 0) {
+ // Spigot start
+ if (entityliving instanceof EntityPlayer) {
+ org.bukkit.craftbukkit.inventory.CraftItemStack item = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this);
+ org.bukkit.event.player.PlayerItemDamageEvent event = new org.bukkit.event.player.PlayerItemDamageEvent((org.bukkit.entity.Player) entityliving.getBukkitEntity(), item, i);
+ org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) return;
+ i = event.getDamage();
+ }
+ // Spigot end
+ if (i <= 0 ) {
return;
}
}
--
1.8.1-rc2