Correct duplicate attribute check (#10901)

Brackets got lost during the update, leading to an incorrect
precondition call.
This commit is contained in:
Bjarne Koll 2024-06-18 11:11:14 +02:00
parent 59da9d1a80
commit 8d4decb590
2 changed files with 2 additions and 2 deletions

View File

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.checkAttributeList(); this.checkAttributeList();
for (Map.Entry<Attribute, AttributeModifier> entry : this.attributeModifiers.entries()) { for (Map.Entry<Attribute, AttributeModifier> entry : this.attributeModifiers.entries()) {
- Preconditions.checkArgument(!entry.getValue().getKey().equals(modifier.getKey()), "Cannot register AttributeModifier. Modifier is already applied! %s", modifier); - Preconditions.checkArgument(!entry.getValue().getKey().equals(modifier.getKey()), "Cannot register AttributeModifier. Modifier is already applied! %s", modifier);
+ Preconditions.checkArgument(!entry.getValue().getKey().equals(modifier.getKey()) && entry.getKey() == attribute, "Cannot register AttributeModifier. Modifier is already applied! %s", modifier); // Paper - attribute modifiers with same namespaced key but on different attributes are fine + Preconditions.checkArgument(!(entry.getValue().getKey().equals(modifier.getKey()) && entry.getKey() == attribute), "Cannot register AttributeModifier. Modifier is already applied! %s", modifier); // Paper - attribute modifiers with same namespaced key but on different attributes are fine
} }
return this.attributeModifiers.put(attribute, modifier); return this.attributeModifiers.put(attribute, modifier);
} }

View File

@ -982,7 +982,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- this.checkAttributeList(); - this.checkAttributeList();
+ if (this.attributeModifiers != null) { // Paper + if (this.attributeModifiers != null) { // Paper
for (Map.Entry<Attribute, AttributeModifier> entry : this.attributeModifiers.entries()) { for (Map.Entry<Attribute, AttributeModifier> entry : this.attributeModifiers.entries()) {
Preconditions.checkArgument(!entry.getValue().getKey().equals(modifier.getKey()) && entry.getKey() == attribute, "Cannot register AttributeModifier. Modifier is already applied! %s", modifier); // Paper - attribute modifiers with same namespaced key but on different attributes are fine Preconditions.checkArgument(!(entry.getValue().getKey().equals(modifier.getKey()) && entry.getKey() == attribute), "Cannot register AttributeModifier. Modifier is already applied! %s", modifier); // Paper - attribute modifiers with same namespaced key but on different attributes are fine
} }
+ } // Paper + } // Paper
+ this.checkAttributeList(); // Paper - moved down + this.checkAttributeList(); // Paper - moved down