diff --git a/Bukkit-Patches/0005-PlayerItemDamageEvent.patch b/Bukkit-Patches/0005-PlayerItemDamageEvent.patch new file mode 100644 index 000000000..89fb3f682 --- /dev/null +++ b/Bukkit-Patches/0005-PlayerItemDamageEvent.patch @@ -0,0 +1,73 @@ +From 9df4bf49783c57d5e7e358a3a895f601bcf7aa30 Mon Sep 17 00:00:00 2001 +From: md_5 +Date: Mon, 4 Mar 2013 18:31:20 +1100 +Subject: [PATCH] PlayerItemDamageEvent + +--- + .../bukkit/event/player/PlayerItemDamageEvent.java | 54 ++++++++++++++++++++++ + 1 file changed, 54 insertions(+) + create mode 100644 src/main/java/org/bukkit/event/player/PlayerItemDamageEvent.java + +diff --git a/src/main/java/org/bukkit/event/player/PlayerItemDamageEvent.java b/src/main/java/org/bukkit/event/player/PlayerItemDamageEvent.java +new file mode 100644 +index 0000000..38a72ab +--- /dev/null ++++ b/src/main/java/org/bukkit/event/player/PlayerItemDamageEvent.java +@@ -0,0 +1,54 @@ ++package org.bukkit.event.player; ++ ++import org.bukkit.entity.Player; ++import org.bukkit.event.Cancellable; ++import org.bukkit.event.HandlerList; ++import org.bukkit.inventory.ItemStack; ++ ++public class PlayerItemDamageEvent extends PlayerEvent implements Cancellable { ++ ++ private static final HandlerList handlers = new HandlerList(); ++ private final ItemStack item; ++ private int damage; ++ private boolean cancelled = false; ++ ++ public PlayerItemDamageEvent(Player player, ItemStack what, int damage) { ++ super(player); ++ this.item = what; ++ this.damage = damage; ++ } ++ ++ public ItemStack getItem() { ++ return item; ++ } ++ ++ /** ++ * Gets the amount of durability damage this item will be taking. ++ * ++ * @return durability change ++ */ ++ public int getDamage() { ++ return damage; ++ } ++ ++ public void setDamage(int damage) { ++ this.damage = damage; ++ } ++ ++ public boolean isCancelled() { ++ return cancelled; ++ } ++ ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; ++ } ++ ++ @Override ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} +-- +1.8.1-rc2 + diff --git a/CraftBukkit-Patches/0041-PlayerItemDamageEvent.patch b/CraftBukkit-Patches/0041-PlayerItemDamageEvent.patch new file mode 100644 index 000000000..c4106e5df --- /dev/null +++ b/CraftBukkit-Patches/0041-PlayerItemDamageEvent.patch @@ -0,0 +1,34 @@ +From d1f056b206014ed99fcb565e8bc376d8dc88650c Mon Sep 17 00:00:00 2001 +From: md_5 +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..8925327 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, damage); ++ org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) return; ++ i = event.getDamage(); ++ } ++ // Spigot end ++ if (i <= 0 ) { + return; + } + } +-- +1.8.1-rc2 +