3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/Spigot-API-Patches/0146-Inventory-removeItemAnySlot.patch
Aikar 33bdd20193
[CI-SKIP] [Auto] Rebuild Patches
A recent commit has been made that caused patches to be out of order, rebuilding
2018-09-03 10:11:35 -04:00

48 Zeilen
1.9 KiB
Diff

From a973a74dfbdfd018a94e15f615d045b8b2f7b1f7 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 28 Aug 2018 23:04:06 -0400
Subject: [PATCH] Inventory#removeItemAnySlot
diff --git a/src/main/java/org/bukkit/inventory/Inventory.java b/src/main/java/org/bukkit/inventory/Inventory.java
index 2dbba0012..ec58e9727 100644
--- a/src/main/java/org/bukkit/inventory/Inventory.java
+++ b/src/main/java/org/bukkit/inventory/Inventory.java
@@ -117,6 +117,33 @@ public interface Inventory extends Iterable<ItemStack> {
*/
public HashMap<Integer, ItemStack> removeItem(ItemStack... items) throws IllegalArgumentException;
+ // Paper start
+ /**
+ * Searches all possible inventory slots in order to remove the given ItemStacks.
+ * <p>
+ * Similar to {@link Inventory#removeItem(ItemStack...)} in behavior, except this
+ * method will check all possible slots in the inventory, rather than just the main
+ * storage contents.
+ * <p>
+ * It will try to remove 'as much as possible' from the types and amounts
+ * you give as arguments.
+ * <p>
+ * The returned HashMap contains what it couldn't remove, where the key is
+ * the index of the parameter, and the value is the ItemStack at that
+ * index of the varargs parameter. If all the given ItemStacks are
+ * removed, it will return an empty HashMap.
+ * <p>
+ * It is known that in some implementations this method will also set the
+ * inputted argument amount to the number of that item not removed from
+ * slots.
+ *
+ * @param items The ItemStacks to remove
+ * @return A HashMap containing items that couldn't be removed.
+ * @throws IllegalArgumentException if items is null
+ */
+ public HashMap<Integer, ItemStack> removeItemAnySlot(ItemStack... items) throws IllegalArgumentException;
+ // Paper end
+
/**
* Returns all ItemStacks from the inventory
*
--
2.18.0