From 8d77687e7a069b2934406959b69806ef321f7c5f Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Thu, 18 Apr 2013 13:08:16 -0400 Subject: [PATCH] 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. --- .../bukkit/craftbukkit/inventory/CraftInventory.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index 411090a642..6748465da6 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -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); + } }