Skip to content

Commit

Permalink
ItemCreator AttributeModifier hotfix 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubix327 committed Jun 19, 2022
1 parent 3e64e3e commit bc2c548
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/main/java/org/mineacademy/fo/menu/model/ItemCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ public ItemCreator flags(CompItemFlag... flags) {
* If no {@link EquipmentSlot EquipmentSlots} specified, all available will be used.
*/
public ItemCreator attributeModifier(CompAttribute attribute, double amount){
attributeModifier(attribute, amount, AttributeModifier.Operation.ADD_NUMBER);
if (MinecraftVersion.atLeast(V.v1_9)){
attributeModifier(attribute, amount, AttributeModifier.Operation.ADD_NUMBER);
}

return this;
}
Expand All @@ -322,12 +324,14 @@ public ItemCreator attributeModifier(CompAttribute attribute, double amount){
* If no {@link EquipmentSlot EquipmentSlots} specified, all available will be used.
*/
public ItemCreator attributeModifier(CompAttribute attribute, double amount, AttributeModifier.Operation operation){
List<AttributeModifier> modifiers = new ArrayList<>();
if (this.attributeModifiers.containsKey(attribute)){
modifiers.addAll(this.attributeModifiers.get(attribute));
if (MinecraftVersion.atLeast(V.v1_9)) {
List<AttributeModifier> modifiers = new ArrayList<>();
if (this.attributeModifiers.containsKey(attribute)) {
modifiers.addAll(this.attributeModifiers.get(attribute));
}
modifiers.add(new AttributeModifier("", amount, operation));
this.attributeModifiers.put(attribute, modifiers);
}
modifiers.add(new AttributeModifier("", amount, operation));
this.attributeModifiers.put(attribute, modifiers);

return this;
}
Expand All @@ -337,14 +341,16 @@ public ItemCreator attributeModifier(CompAttribute attribute, double amount, Att
*/
public ItemCreator attributeModifier(
CompAttribute attribute, double amount, AttributeModifier.Operation operation, EquipmentSlot... slots){
List<AttributeModifier> modifiers = new ArrayList<>();
if (this.attributeModifiers.containsKey(attribute)){
modifiers.addAll(this.attributeModifiers.get(attribute));
}
for (EquipmentSlot slot: slots){
modifiers.add(new AttributeModifier(UUID.randomUUID(), "", amount, operation, slot));
if (MinecraftVersion.atLeast(V.v1_9)) {
List<AttributeModifier> modifiers = new ArrayList<>();
if (this.attributeModifiers.containsKey(attribute)) {
modifiers.addAll(this.attributeModifiers.get(attribute));
}
for (EquipmentSlot slot : slots) {
modifiers.add(new AttributeModifier(UUID.randomUUID(), "", amount, operation, slot));
}
this.attributeModifiers.put(attribute, modifiers);
}
this.attributeModifiers.put(attribute, modifiers);

return this;
}
Expand Down

0 comments on commit bc2c548

Please sign in to comment.