mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-25 16:54:30 +00:00
Scripting for Attribute Handling on Players, Items, Totals, etc
This commit is contained in:
1 parent
7f5ba9a1c4
commit
9691c90ffc
13 files changed
+242
-46
No files matched your search
@@ -1,5 +1,7 @@
|
||||
package kamkeel.npcs.controllers.data.attribute;
|
||||
|
||||
import noppes.npcs.api.handler.data.ICustomAttribute;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -8,22 +10,18 @@ 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 final Map<AttributeDefinition, PlayerAttribute> map = new HashMap<>();
|
||||
|
||||
public ICustomAttribute registerAttribute(AttributeDefinition attribute, float baseValue) {
|
||||
public PlayerAttribute registerAttribute(AttributeDefinition attribute, float baseValue) {
|
||||
if (map.containsKey(attribute)) {
|
||||
throw new IllegalArgumentException("Attribute already registered: " + attribute.getKey());
|
||||
}
|
||||
ICustomAttribute instance = new PlayerAttribute(attribute, baseValue);
|
||||
PlayerAttribute instance = new PlayerAttribute(attribute, baseValue);
|
||||
map.put(attribute, instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ICustomAttribute getAttributeInstance(AttributeDefinition attribute) {
|
||||
public PlayerAttribute getAttributeInstance(AttributeDefinition attribute) {
|
||||
return map.get(attribute);
|
||||
}
|
||||
|
||||
public Collection<ICustomAttribute> getAllAttributes() {
|
||||
return map.values();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user