Skip to content

Commit d7482b9

Browse files
committed
add factory-like methods for AttributeModifier creation
1 parent 70f38fe commit d7482b9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/main/java/org/spongepowered/api/entity/attribute/AttributeModifier.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package org.spongepowered.api.entity.attribute;
2626

27+
import org.spongepowered.api.ResourceKey;
2728
import org.spongepowered.api.ResourceKeyed;
2829
import org.spongepowered.api.Sponge;
2930
import org.spongepowered.api.item.inventory.ItemStack;
@@ -38,6 +39,30 @@
3839
*/
3940
public interface AttributeModifier extends ResourceKeyed {
4041

42+
/**
43+
* Creates an attribute modifier with the given values.
44+
*
45+
* @param key The resource key
46+
* @param operation The attribute operation
47+
* @param amount The amount
48+
* @return The attribute modifier
49+
*/
50+
static AttributeModifier of(final ResourceKey key, final Supplier<? extends AttributeOperation> operation, final double amount) {
51+
return AttributeModifier.builder().key(key).operation(operation).amount(amount).build();
52+
}
53+
54+
/**
55+
* Creates an attribute modifier with the given values.
56+
*
57+
* @param key The resource key
58+
* @param operation The attribute operation
59+
* @param amount The amount
60+
* @return The attribute modifier
61+
*/
62+
static AttributeModifier of(final ResourceKey key, final AttributeOperation operation, final double amount) {
63+
return AttributeModifier.builder().key(key).operation(operation).amount(amount).build();
64+
}
65+
4166
/**
4267
* Creates a new {@link Builder} to create an {@link AttributeModifier}.
4368
*

0 commit comments

Comments
 (0)