mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 17:19:05 +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,32 @@
|
||||
package noppes.npcs.attribute;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Central registry for valid attribute definitions.
|
||||
* Other mods can register new attributes here so that items only need to store a
|
||||
* small namespaced key.
|
||||
*/
|
||||
public class AttributeController {
|
||||
private static final Map<String, AttributeDefinition> definitions = new HashMap<>();
|
||||
private static int nextId = 0;
|
||||
|
||||
public static AttributeDefinition registerAttribute(String key, String displayName, Operation op) {
|
||||
if (definitions.containsKey(key)) {
|
||||
return definitions.get(key);
|
||||
}
|
||||
AttributeDefinition def = new AttributeDefinition(nextId++, key, displayName, op);
|
||||
definitions.put(key, def);
|
||||
return def;
|
||||
}
|
||||
|
||||
public static AttributeDefinition getAttribute(String key) {
|
||||
return definitions.get(key);
|
||||
}
|
||||
|
||||
public static Collection<AttributeDefinition> getAllAttributes() {
|
||||
return definitions.values();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user