mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 19:54:26 +00:00
Better Reorganization
This commit is contained in:
1 parent
a328a635d7
commit
da0489296e
38 files changed
+151
-144
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package kamkeel.npcs.controllers.data.attribute;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* CustomAttributeMap holds a set of attribute instances for an entity (or item).
|
||||
*/
|
||||
public class PlayerAttributeMap {
|
||||
private final Map<AttributeDefinition, ICustomAttribute> map = new HashMap<>();
|
||||
|
||||
public ICustomAttribute registerAttribute(AttributeDefinition attribute, float baseValue) {
|
||||
if (map.containsKey(attribute)) {
|
||||
throw new IllegalArgumentException("Attribute already registered: " + attribute.getKey());
|
||||
}
|
||||
ICustomAttribute instance = new PlayerAttribute(attribute, baseValue);
|
||||
map.put(attribute, instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ICustomAttribute getAttributeInstance(AttributeDefinition attribute) {
|
||||
return map.get(attribute);
|
||||
}
|
||||
|
||||
public Collection<ICustomAttribute> getAllAttributes() {
|
||||
return map.values();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user