mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 09:39:48 +00:00
Large Unused Attribute Push
This commit is contained in:
1 parent
4faa851078
commit
5818060656
13 files changed
+553
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package noppes.npcs.attribute;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Holds a collection of attribute instances (for a weapon, item, or aggregated for a player).
|
||||
*/
|
||||
public class CustomAttributeMap {
|
||||
private final Map<AttributeDefinition, IAttributeInstance> map = new HashMap<>();
|
||||
|
||||
public IAttributeInstance registerAttribute(AttributeDefinition attribute, double baseValue) {
|
||||
if (map.containsKey(attribute)) {
|
||||
throw new IllegalArgumentException("Attribute already registered: " + attribute.getKey());
|
||||
}
|
||||
IAttributeInstance instance = new ModifiableAttributeInstance(attribute, baseValue);
|
||||
map.put(attribute, instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public IAttributeInstance getAttributeInstance(AttributeDefinition attribute) {
|
||||
return map.get(attribute);
|
||||
}
|
||||
|
||||
public Collection<IAttributeInstance> getAllAttributes() {
|
||||
return map.values();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user