diff --git a/Essentials/src/main/java/com/earth2me/essentials/craftbukkit/Inventories.java b/Essentials/src/main/java/com/earth2me/essentials/craftbukkit/Inventories.java index fffccf9ca94..d88ed26d612 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/craftbukkit/Inventories.java +++ b/Essentials/src/main/java/com/earth2me/essentials/craftbukkit/Inventories.java @@ -19,6 +19,8 @@ public final class Inventories { private static final int CHEST_SLOT = 38; private static final int LEG_SLOT = 37; private static final int BOOT_SLOT = 36; + private static final int BODY_SLOT = 41; + private static final int SADDLE_SLOT = 42; private static final boolean HAS_OFFHAND = VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_9_R01); private static final int INVENTORY_SIZE = HAS_OFFHAND ? 41 : 40; @@ -224,6 +226,10 @@ public static int removeItems(final Player player, final Predicate re int removedAmount = 0; final ItemStack[] items = player.getInventory().getContents(); for (int i = 0; i < items.length; i++) { + if (isContortedSlot(i)) { + continue; + } + if (!includeArmor && isArmorSlot(i)) { continue; } @@ -251,6 +257,10 @@ public static boolean removeItemAmount(final Player player, final ItemStack toRe final ItemStack[] items = player.getInventory().getContents(); for (int i = 0; i < items.length; i++) { + if (isContortedSlot(i)) { + continue; + } + final ItemStack item = items[i]; if (isEmpty(item)) { continue; @@ -342,6 +352,10 @@ private static InventoryData parseInventoryData(final Inventory inventory, final final HashMap> partialSlots = new HashMap<>(); for (int i = 0; i < inventoryContents.length; i++) { + if (isContortedSlot(i)) { + continue; + } + if (!includeArmor && isArmorSlot(i)) { continue; } @@ -403,6 +417,10 @@ private static boolean isEmpty(final ItemStack stack) { return stack == null || MaterialUtil.isAir(stack.getType()); } + public static boolean isContortedSlot(final int slot) { + return slot == BODY_SLOT || slot == SADDLE_SLOT; + } + private static boolean isArmorSlot(final int slot) { return slot == HELM_SLOT || slot == CHEST_SLOT || slot == LEG_SLOT || slot == BOOT_SLOT; }