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.
This commit is contained in:
Jeremy Wood 2013-04-18 13:08:16 -04:00 committed by Travis Watkins
parent 434f15c847
commit 8d77687e7a

View File

@ -468,4 +468,14 @@ public class CraftInventory implements Inventory {
public void setMaxStackSize(int size) { public void setMaxStackSize(int size) {
inventory.setMaxStackSize(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);
}
} }