mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 00:07:56 +01:00
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 By: Nathan Wolf <nathan@elmakers.com>
This commit is contained in:
parent
260ae5cb5c
commit
07b3c001ff
@ -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,10 +104,21 @@ 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{"
|
||||
|
Loading…
Reference in New Issue
Block a user