summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorJeremy Wood <farachan@gmail.com>2013-04-18 13:08:16 -0400
committerTravis Watkins <amaranth@ubuntu.com>2014-04-02 17:26:11 -0500
commit8d77687e7a069b2934406959b69806ef321f7c5f (patch)
treecf735686531c9c7a73a9113ec91b82b8e5c3289b /src/main
parent434f15c847e43992cc1c2aa8feeefe283a6be8b6 (diff)
downloadcraftbukkit-8d77687e7a069b2934406959b69806ef321f7c5f.tar
craftbukkit-8d77687e7a069b2934406959b69806ef321f7c5f.tar.gz
craftbukkit-8d77687e7a069b2934406959b69806ef321f7c5f.tar.lz
craftbukkit-8d77687e7a069b2934406959b69806ef321f7c5f.tar.xz
craftbukkit-8d77687e7a069b2934406959b69806ef321f7c5f.zip
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.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
index 411090a6..6748465d 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);
+ }
}