mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-02 17:32:03 +01:00
SPIGOT-7895: PlayerItemBreakEvent not firing
By: md_5 <git@md-5.net>
This commit is contained in:
parent
deb7197a64
commit
b7359583f2
2 changed files with 13 additions and 13 deletions
|
@ -302,18 +302,18 @@
|
||||||
if (i <= 0) {
|
if (i <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -480,6 +694,11 @@
|
@@ -458,6 +672,11 @@
|
||||||
}
|
this.setDamageValue(j);
|
||||||
|
if (j >= this.getMaxDamage()) {
|
||||||
|
Item item = this.getItem();
|
||||||
|
+ // CraftBukkit start - Check for item breaking
|
||||||
|
+ if (this.count == 1) {
|
||||||
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(entityplayer, this);
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
|
||||||
this.hurtAndBreak(i, worldserver, entityplayer, (item) -> {
|
this.shrink(1);
|
||||||
+ // CraftBukkit start - Check for item breaking
|
consumer.accept(item);
|
||||||
+ if (this.count == 1 && entityliving instanceof EntityHuman) {
|
|
||||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((EntityHuman) entityliving, this);
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
|
||||||
entityliving.onEquippedItemBroken(item, enumitemslot);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -693,6 +912,12 @@
|
@@ -693,6 +912,12 @@
|
||||||
return this.getItem().useOnRelease(this);
|
return this.getItem().useOnRelease(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1365,9 +1365,9 @@ public class CraftEventFactory {
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callPlayerItemBreakEvent(EntityHuman human, ItemStack brokenItem) {
|
public static void callPlayerItemBreakEvent(EntityPlayer human, ItemStack brokenItem) {
|
||||||
CraftItemStack item = CraftItemStack.asCraftMirror(brokenItem);
|
CraftItemStack item = CraftItemStack.asCraftMirror(brokenItem);
|
||||||
PlayerItemBreakEvent event = new PlayerItemBreakEvent((Player) human.getBukkitEntity(), item);
|
PlayerItemBreakEvent event = new PlayerItemBreakEvent(human.getBukkitEntity(), item);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue