summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorNathan Wolf <nathan@elmakers.com>2018-09-26 18:09:13 -0700
committermd_5 <git@md-5.net>2018-09-27 20:58:51 +1000
commit39ce5d3a8ab15140d51a186670f8d31f18d31fae (patch)
treea50189d2afa5bcc49b77a21b18e2ed86d178a3ba /src/main/java/org
parent0812ce2ccec4dce83fe382965242e35ec4022fac (diff)
downloadbukkit-39ce5d3a8ab15140d51a186670f8d31f18d31fae.tar
bukkit-39ce5d3a8ab15140d51a186670f8d31f18d31fae.tar.gz
bukkit-39ce5d3a8ab15140d51a186670f8d31f18d31fae.tar.lz
bukkit-39ce5d3a8ab15140d51a186670f8d31f18d31fae.tar.xz
bukkit-39ce5d3a8ab15140d51a186670f8d31f18d31fae.zip
SPIGOT-4399: ItemMeta.equals broken with AttributeModifiers
Fix equality check in AttributeModifier Add hashCode method to AttributeModifier This is necessary for contains() checks in ItemMeta to function properly
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/attribute/AttributeModifier.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/attribute/AttributeModifier.java b/src/main/java/org/bukkit/attribute/AttributeModifier.java
index a3a69ffa..2bc9878f 100644
--- a/src/main/java/org/bukkit/attribute/AttributeModifier.java
+++ b/src/main/java/org/bukkit/attribute/AttributeModifier.java
@@ -2,6 +2,7 @@ package org.bukkit.attribute;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import java.util.UUID;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
@@ -103,11 +104,22 @@ public class AttributeModifier implements ConfigurationSerializable {
return false;
}
AttributeModifier mod = (AttributeModifier) other;
- boolean slots = (this.slot != null ? (this.slot == mod.slot) : mod.slot != null);
+ boolean slots = (this.slot != null ? (this.slot == mod.slot) : mod.slot == null);
return this.uuid.equals(mod.uuid) && this.name.equals(mod.name) && this.amount == mod.amount && this.operation == mod.operation && slots;
}
@Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 17 * hash + Objects.hashCode(this.uuid);
+ hash = 17 * hash + Objects.hashCode(this.name);
+ hash = 17 * hash + (int) (Double.doubleToLongBits(this.amount) ^ (Double.doubleToLongBits(this.amount) >>> 32));
+ hash = 17 * hash + Objects.hashCode(this.operation);
+ hash = 17 * hash + Objects.hashCode(this.slot);
+ return hash;
+ }
+
+ @Override
public String toString() {
return "AttributeModifier{"
+ "uuid=" + this.uuid.toString()