Class EntityAttributes
java.lang.Object
com.github.darksoulq.abyssallib.world.data.attribute.EntityAttributes
-
Method Summary
Modifier and TypeMethodDescription<T extends Number>
voidaddModifier(Attribute<T> attr, net.kyori.adventure.key.Key id, T modifier, AttributeOperation operation) Adds a modifier to an attribute, allowing for event-driven logic to override the application.<T extends Number>
TRetrieves the final calculated value of an attribute after applying all modifiers.Retrieves a map containing all raw attribute keys and values for this entity.<T extends Number>
TgetBaseValue(Attribute<T> attr) Retrieves the raw base value of an attribute without applying any modifiers.booleanChecks if a specific attribute has been defined or loaded for this entity.static voidinit()Initializes the global attribute database and ensures the table structure exists.static voidInitializes the SQLite table used for persistent attribute storage.voidload()Asynchronously loads all attribute data for this entity from the database.static EntityAttributesRetrieves the attribute container for a specific UUID.static EntityAttributesof(org.bukkit.entity.Entity entity) Retrieves the attribute container for a specific entity.<T extends Number>
voidremoveModifier(Attribute<T> attr, net.kyori.adventure.key.Key id) Removes a specific modifier from an attribute based on its unique Key.<T extends Number>
voidSets the base value of an attribute, triggering a change event and updating the database.
-
Method Details
-
init
public static void init()Initializes the global attribute database and ensures the table structure exists.- Throws:
RuntimeException- If the database connection or table initialization fails.
-
of
Retrieves the attribute container for a specific entity.- Parameters:
entity- TheEntityinstance.- Returns:
- The associated
EntityAttributesmanager.
-
of
Retrieves the attribute container for a specific UUID.- Parameters:
uuid- TheUUIDof the target entity.- Returns:
- The associated
EntityAttributesmanager.
-
set
Sets the base value of an attribute, triggering a change event and updating the database.- Type Parameters:
T- The numeric type of the attribute.- Parameters:
attr- TheAttributedefinition to update.value- The new base value to assign.
-
addModifier
public <T extends Number> void addModifier(Attribute<T> attr, net.kyori.adventure.key.Key id, T modifier, AttributeOperation operation) Adds a modifier to an attribute, allowing for event-driven logic to override the application.- Type Parameters:
T- The numeric type of the attribute and modifier.- Parameters:
attr- TheAttributeinstance to modify.id- The uniqueKeyidentifying this specific modifier.modifier- The value of the modifier.operation- TheAttributeOperationdetermining how the modifier is applied.
-
removeModifier
Removes a specific modifier from an attribute based on its unique Key.- Type Parameters:
T- The numeric type of the attribute.- Parameters:
attr- TheAttributeinstance to update.id- The uniqueKeyof the modifier to remove.
-
has
-
getBaseValue
-
get
Retrieves the final calculated value of an attribute after applying all modifiers.- Type Parameters:
T- The numeric type of the attribute.- Parameters:
attr- TheAttributeto retrieve.- Returns:
- The final calculated value, or null if the base value is missing.
-
getAllAttributes
-
load
public void load()Asynchronously loads all attribute data for this entity from the database. -
initTable
public static void initTable()Initializes the SQLite table used for persistent attribute storage.
-