2018-09-01 06:56:57 +08:00
|
|
|
From ba92e8671f51c00dca93612905edd40b342da041 Mon Sep 17 00:00:00 2001
|
2017-11-11 12:46:55 +08:00
|
|
|
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
|
2018-09-01 06:56:57 +08:00
|
|
|
index 72a2164fdf..61af2621c5 100644
|
2017-11-11 12:46:55 +08:00
|
|
|
--- 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.Maps;
|
|
|
|
import java.util.Collection;
|
2018-08-27 02:11:49 +08:00
|
|
|
@@ -2083,6 +2084,13 @@ public abstract class EntityLiving extends Entity {
|
2017-11-11 12:46:55 +08:00
|
|
|
ItemStack itemstack1 = this.getEquipment(enumitemslot);
|
|
|
|
|
|
|
|
if (!ItemStack.matches(itemstack1, itemstack)) {
|
|
|
|
+ // Paper start - PlayerArmorChangeEvent
|
2017-11-11 13:07:45 +08:00
|
|
|
+ if (this instanceof EntityPlayer && enumitemslot.getType() == EnumItemSlot.Function.ARMOR && !itemstack.getItem().equals(itemstack1.getItem())) {
|
2017-11-11 12:46:55 +08:00
|
|
|
+ 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).getTracker().a((Entity) this, (Packet) (new PacketPlayOutEntityEquipment(this.getId(), enumitemslot, itemstack1)));
|
|
|
|
if (!itemstack.isEmpty()) {
|
|
|
|
this.getAttributeMap().a(itemstack.a(enumitemslot));
|
2017-11-11 13:07:45 +08:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EnumItemSlot.java b/src/main/java/net/minecraft/server/EnumItemSlot.java
|
2018-09-01 06:56:57 +08:00
|
|
|
index a90ac68c30..49592e5572 100644
|
2017-11-11 13:07:45 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/EnumItemSlot.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EnumItemSlot.java
|
2018-09-01 06:56:57 +08:00
|
|
|
@@ -20,6 +20,7 @@ public enum EnumItemSlot {
|
|
|
|
this.j = s1;
|
2017-11-11 13:07:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
+ public EnumItemSlot.Function getType() { return this.a(); } // Paper - OBFHELPER
|
|
|
|
public EnumItemSlot.Function a() {
|
|
|
|
return this.g;
|
|
|
|
}
|
2017-11-11 12:46:55 +08:00
|
|
|
--
|
2018-06-30 13:40:52 +08:00
|
|
|
2.18.0
|
2017-11-11 12:46:55 +08:00
|
|
|
|