Paper/Spigot-Server-Patches/0185-Add-PlayerArmorChangeEvent.patch
2019-05-13 21:20:58 -05:00

47 lines
2.3 KiB
Diff

From 4b68adef0da9d19e413ba0179905f856b9418e42 Mon Sep 17 00:00:00 2001
From: pkt77 <parkerkt77@gmail.com>
Date: Fri, 10 Nov 2017 23:46:34 -0500
Subject: [PATCH] Add PlayerArmorChangeEvent
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index e2921de48..864204078 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -1,5 +1,6 @@
package net.minecraft.server;
+import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
@@ -2269,6 +2270,13 @@ public abstract class EntityLiving extends Entity {
ItemStack itemstack1 = this.getEquipment(enumitemslot);
if (!ItemStack.matches(itemstack1, itemstack)) {
+ // Paper start - PlayerArmorChangeEvent
+ if (this instanceof EntityPlayer && enumitemslot.getType() == EnumItemSlot.Function.ARMOR) {
+ final org.bukkit.inventory.ItemStack oldItem = CraftItemStack.asBukkitCopy(itemstack);
+ final org.bukkit.inventory.ItemStack newItem = CraftItemStack.asBukkitCopy(itemstack1);
+ new PlayerArmorChangeEvent((Player) this.getBukkitEntity(), PlayerArmorChangeEvent.SlotType.valueOf(enumitemslot.name()), oldItem, newItem).callEvent();
+ }
+ // Paper end
((WorldServer) this.world).getChunkProvider().broadcast(this, new PacketPlayOutEntityEquipment(this.getId(), enumitemslot, itemstack1));
if (!itemstack.isEmpty()) {
this.getAttributeMap().a(itemstack.a(enumitemslot));
diff --git a/src/main/java/net/minecraft/server/EnumItemSlot.java b/src/main/java/net/minecraft/server/EnumItemSlot.java
index 02a7ae678..60b235f16 100644
--- a/src/main/java/net/minecraft/server/EnumItemSlot.java
+++ b/src/main/java/net/minecraft/server/EnumItemSlot.java
@@ -16,6 +16,7 @@ public enum EnumItemSlot {
this.j = s;
}
+ public EnumItemSlot.Function getType() { return this.a(); } // Paper - OBFHELPER
public EnumItemSlot.Function a() {
return this.g;
}
--
2.21.0