fix: "attribute modifier already applied" error, close #348

feat/data-edit-commands
William 4 months ago
parent 8e9850dd19
commit 83b5209a75
No known key found for this signature in database

@ -643,7 +643,7 @@ public abstract class BukkitData implements Data {
instance.setBaseValue(attribute == null ? instance.getDefaultValue() : attribute.baseValue());
instance.getModifiers().forEach(instance::removeModifier);
if (attribute != null) {
attribute.modifiers().forEach(mod -> instance.addModifier(adapt(mod, plugin)));
attribute.modifiers().stream().distinct().forEach(mod -> instance.addModifier(adapt(mod, plugin)));
}
}

@ -366,7 +366,13 @@ public interface Data {
@Override
public boolean equals(Object obj) {
return obj instanceof Modifier modifier && modifier.uuid().equals(uuid());
if (obj instanceof Modifier other) {
if (uuid == null || other.uuid == null) {
return name.equals(other.name);
}
return uuid.equals(other.uuid);
}
return super.equals(obj);
}
public double modify(double value) {

Loading…
Cancel
Save