Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -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;

Expand DownExpand Up@@ -224,6 +226,10 @@ public static int removeItems(final Player player, final Predicate<ItemStack> 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;
}
Expand DownExpand Up@@ -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;
Expand DownExpand Up@@ -342,6 +352,10 @@ private static InventoryData parseInventoryData(final Inventory inventory, final
final HashMap<ItemStack, List<Integer>> partialSlots = new HashMap<>();

for (int i = 0; i < inventoryContents.length; i++) {
if (isContortedSlot(i)) {
continue;
}

if (!includeArmor && isArmorSlot(i)) {
continue;
}
Expand DownExpand Up@@ -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;
}
Expand Down