mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 02:25:28 +01:00
Implement PlayerItemDamageEvent. @Sleaker @Kainzo - if you could kindly tell me why you add code to prevent Heroes from running on a **now supported** platform, I would love to know, maybe we can resolve this once and for all. Unless of course it is simply part of your plan to make people use your rise against CraftBukkit fork with only 1 tiny feature which can and will be replicated in a plugin if need be.
This commit is contained in:
parent
c1b617ddc8
commit
2faef00909
73
Bukkit-Patches/0005-PlayerItemDamageEvent.patch
Normal file
73
Bukkit-Patches/0005-PlayerItemDamageEvent.patch
Normal file
@ -0,0 +1,73 @@
|
||||
From 9df4bf49783c57d5e7e358a3a895f601bcf7aa30 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
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
|
||||
|
34
CraftBukkit-Patches/0041-PlayerItemDamageEvent.patch
Normal file
34
CraftBukkit-Patches/0041-PlayerItemDamageEvent.patch
Normal file
@ -0,0 +1,34 @@
|
||||
From d1f056b206014ed99fcb565e8bc376d8dc88650c 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..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
|
||||
|
Loading…
Reference in New Issue
Block a user