Clone ItemStack before adding to player inventory.
Spigot is at it again with another breaking change to the API where the JavaDocs have been retrofitted to match the new, ancient way of writing software. The addItem and removeItem methods originally just added or removed whatever they could when called, and returned a map of items that failed due to lack of space/items. Now, with the breaking API change, these methods actually *mutate their arguments* - a practice that has been heavily discouraged for decades in modern software development, and something you usually only see in C these days. This change, like many others in the same vein, show the complete recklessness, incompetence, and lack of awareness from an otherwise talented team of developers. Hopefully, they will continue to hone their skills so that we can eventually have a stable API again.
This commit is contained in:
@@ -13,12 +13,12 @@ public class ItemStackThing implements Thing {
|
||||
|
||||
@Override
|
||||
public boolean giveTo(Player player) {
|
||||
return player.getInventory().addItem(stack).isEmpty();
|
||||
return player.getInventory().addItem(stack.clone()).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean takeFrom(Player player) {
|
||||
return player.getInventory().removeItem(stack).isEmpty();
|
||||
return player.getInventory().removeItem(stack.clone()).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user