2020-04-02 23:07:06 +02:00
|
|
|
From 4971f3493441d4522d32bb68cc230904d169fd37 Mon Sep 17 00:00:00 2001
|
2017-11-11 05:46:55 +01: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
|
2020-04-02 23:07:06 +02:00
|
|
|
index c7b62872c4..fe0b082206 100644
|
2017-11-11 05:46:55 +01: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;
|
2019-04-28 01:23:53 +02:00
|
|
|
import com.google.common.collect.ImmutableList;
|
2019-12-12 00:43:22 +01:00
|
|
|
import com.google.common.collect.ImmutableSet;
|
2020-01-22 03:02:07 +01:00
|
|
|
@@ -2336,6 +2337,13 @@ public abstract class EntityLiving extends Entity {
|
2017-11-11 05:46:55 +01:00
|
|
|
ItemStack itemstack1 = this.getEquipment(enumitemslot);
|
|
|
|
|
|
|
|
if (!ItemStack.matches(itemstack1, itemstack)) {
|
|
|
|
+ // Paper start - PlayerArmorChangeEvent
|
2019-03-03 21:21:51 +01:00
|
|
|
+ if (this instanceof EntityPlayer && enumitemslot.getType() == EnumItemSlot.Function.ARMOR) {
|
2017-11-11 05:46:55 +01: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
|
2019-04-28 01:23:53 +02:00
|
|
|
((WorldServer) this.world).getChunkProvider().broadcast(this, new PacketPlayOutEntityEquipment(this.getId(), enumitemslot, itemstack1));
|
2017-11-11 05:46:55 +01:00
|
|
|
if (!itemstack.isEmpty()) {
|
|
|
|
this.getAttributeMap().a(itemstack.a(enumitemslot));
|
2017-11-11 06:07:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EnumItemSlot.java b/src/main/java/net/minecraft/server/EnumItemSlot.java
|
2020-04-02 23:07:06 +02:00
|
|
|
index 02a7ae6785..60b235f16f 100644
|
2017-11-11 06:07:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EnumItemSlot.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EnumItemSlot.java
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -16,6 +16,7 @@ public enum EnumItemSlot {
|
|
|
|
this.j = s;
|
2017-11-11 06:07:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+ public EnumItemSlot.Function getType() { return this.a(); } // Paper - OBFHELPER
|
|
|
|
public EnumItemSlot.Function a() {
|
|
|
|
return this.g;
|
|
|
|
}
|
2017-11-11 05:46:55 +01:00
|
|
|
--
|
2020-04-02 23:07:06 +02:00
|
|
|
2.25.1
|
2017-11-11 05:46:55 +01:00
|
|
|
|