Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 20:40:08 +01:00
CraftInventory.remove shouldn't care about amount (BUKKIT-138)
Dieser Commit ist enthalten in:
Ursprung
dbd3ff71fc
Commit
8363eadcab
@ -160,12 +160,24 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int first(ItemStack item) {
|
public int first(ItemStack item) {
|
||||||
|
return first(item, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int first(ItemStack item, boolean withAmount) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ItemStack[] inventory = getContents();
|
ItemStack[] inventory = getContents();
|
||||||
for (int i = 0; i < inventory.length; i++) {
|
for (int i = 0; i < inventory.length; i++) {
|
||||||
if (item.equals(inventory[i])) {
|
boolean equals = false;
|
||||||
|
|
||||||
|
if (withAmount) {
|
||||||
|
equals = item.equals(inventory[i]);
|
||||||
|
} else {
|
||||||
|
equals = item.getTypeId() == inventory[i].getTypeId() && item.getDurability() == inventory[i].getDurability() && item.getEnchantments().equals(inventory[i].getEnchantments());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (equals) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,7 +294,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
|
|||||||
int toDelete = item.getAmount();
|
int toDelete = item.getAmount();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int first = first(item);
|
int first = first(item, false);
|
||||||
|
|
||||||
// Drat! we don't have this type in the inventory
|
// Drat! we don't have this type in the inventory
|
||||||
if (first == -1) {
|
if (first == -1) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren