mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-20 23:46:57 +01:00
Add equals for CraftInventory objects. Adds BUKKIT-4110
When working with inventories you regularly end up with different Inventory objects that have the same underlying Minecraft inventory. Currently, even those these point to the same thing, they are not considered equal. With this commit comparing any Inventory object that represents the same inventory will result in equals(Object) returning true. By: Jeremy Wood <farachan@gmail.com>
This commit is contained in:
parent
6de31b61d5
commit
ee523c5095
1 changed files with 10 additions and 0 deletions
|
@ -468,4 +468,14 @@ public class CraftInventory implements Inventory {
|
|||
public void setMaxStackSize(int size) {
|
||||
inventory.setMaxStackSize(size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return inventory.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
return obj instanceof CraftInventory && ((CraftInventory) obj).inventory.equals(this.inventory);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue