From 5a47beb9cd77c0f924f952221d6c0da34bbeb6d6 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sat, 13 Jun 2020 20:56:32 +1000 Subject: [PATCH] SPIGOT-2623: Add EntityEquipment methods to get/set ItemStacks by slot. By: blablubbabc --- .../inventory/CraftEntityEquipment.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java index 3eb2402e77..76691563a0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java @@ -1,10 +1,13 @@ package org.bukkit.craftbukkit.inventory; +import com.google.common.base.Preconditions; import net.minecraft.server.EntityInsentient; import net.minecraft.server.EnumItemSlot; +import org.bukkit.craftbukkit.CraftEquipmentSlot; import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.entity.Entity; import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; public class CraftEntityEquipment implements EntityEquipment { @@ -15,6 +18,20 @@ public class CraftEntityEquipment implements EntityEquipment { this.entity = entity; } + @Override + public void setItem(EquipmentSlot slot, ItemStack item) { + Preconditions.checkArgument(slot != null, "slot must not be null"); + EnumItemSlot nmsSlot = CraftEquipmentSlot.getNMS(slot); + setEquipment(nmsSlot, item); + } + + @Override + public ItemStack getItem(EquipmentSlot slot) { + Preconditions.checkArgument(slot != null, "slot must not be null"); + EnumItemSlot nmsSlot = CraftEquipmentSlot.getNMS(slot); + return getEquipment(nmsSlot); + } + @Override public ItemStack getItemInMainHand() { return getEquipment(EnumItemSlot.MAINHAND);