Package noppes.npcs.api.ability
Interface IDataAbilities
-
public interface IDataAbilitiesInterface for an NPC's ability data manager. Provides access to the NPC's abilities and execution state.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddAbility(IAbility ability)Add an inline ability to this NPC.voidaddAbilityReference(String key)Add a reference ability by key (built-in name or custom UUID).voidclearAbilities()Clear all abilities from this NPC.voidcompleteCurrentAbility()Signal the current ability to complete immediately.booleanconvertToInline(String abilityId)Convert a reference slot to inline (by ability ID).IAbilitycreateAbility(String typeId)Create a new ability instance by type ID.booleanexecuteAbility(String key)Execute an ability on this NPC by key (built-in name or custom UUID).booleanexecuteAbility(String key, Object target)Execute an ability on this NPC with a specific target.booleanforceStartAbility(String abilityId)Force start an ability on this NPC.booleanforceStartAbility(String abilityId, Object target)Force start an ability on this NPC with a specific target.IAbility[]getAbilities()Get all abilities assigned to this NPC (resolved from slots).IAbilitygetAbility(String abilityId)Get an ability by ID.IAbilitygetCurrentAbility()Get the currently executing ability, or null if none.intgetGlobalCooldown()Get the global cooldown timer in ticks.IAbilitygetSourceAbility(String abilityId)Get the live source reference of an ability by ID.IAbilitygetSourceCurrentAbility()Get the live source reference of the currently executing ability.booleanhasAbility(String abilityId)Check if the NPC has an ability with the given ID.voidinterruptCurrentAbility()Interrupt the current ability if one is executing.booleanisAbilityReference(String abilityId)Check if a slot is a reference (by ability ID).booleanisEnabled()Check if the ability system is enabled for this NPC.booleanisExecutingAbility()Check if any ability is currently executing.voidremoveAbility(String abilityId)Remove an ability by ID.voidresetCooldowns()Reset all ability cooldowns.voidsetEnabled(boolean enabled)Enable or disable the ability system for this NPC.voidsetGlobalCooldown(int ticks)Set the global cooldown timer in ticks.
-
-
-
Method Detail
-
isEnabled
boolean isEnabled()
Check if the ability system is enabled for this NPC.- Returns:
- true if enabled
-
setEnabled
void setEnabled(boolean enabled)
Enable or disable the ability system for this NPC.- Parameters:
enabled- whether to enable
-
getAbilities
IAbility[] getAbilities()
Get all abilities assigned to this NPC (resolved from slots). Returns safe deep copies. UsegetSourceAbility(String)for live references.- Returns:
- array of abilities
-
addAbility
void addAbility(IAbility ability)
Add an inline ability to this NPC.- Parameters:
ability- the ability to add
-
addAbilityReference
void addAbilityReference(String key)
Add a reference ability by key (built-in name or custom UUID).- Parameters:
key- the ability reference key
-
removeAbility
void removeAbility(String abilityId)
Remove an ability by ID.- Parameters:
abilityId- the ability ID to remove
-
getAbility
IAbility getAbility(String abilityId)
Get an ability by ID. Returns a safe deep copy. UsegetSourceAbility(String)for the live reference.- Parameters:
abilityId- the ability ID- Returns:
- the ability, or null
-
hasAbility
boolean hasAbility(String abilityId)
Check if the NPC has an ability with the given ID.- Parameters:
abilityId- the ability ID- Returns:
- true if found
-
isAbilityReference
boolean isAbilityReference(String abilityId)
Check if a slot is a reference (by ability ID).- Parameters:
abilityId- the ability ID- Returns:
- true if reference
-
convertToInline
boolean convertToInline(String abilityId)
Convert a reference slot to inline (by ability ID). Returns false if the reference cannot be resolved.- Parameters:
abilityId- the ability ID- Returns:
- true if converted successfully
-
clearAbilities
void clearAbilities()
Clear all abilities from this NPC.
-
getCurrentAbility
IAbility getCurrentAbility()
Get the currently executing ability, or null if none. Returns a safe deep copy. UsegetSourceCurrentAbility()for the live reference.- Returns:
- the current ability, or null
-
isExecutingAbility
boolean isExecutingAbility()
Check if any ability is currently executing.- Returns:
- true if executing
-
interruptCurrentAbility
void interruptCurrentAbility()
Interrupt the current ability if one is executing.
-
completeCurrentAbility
void completeCurrentAbility()
Signal the current ability to complete immediately.
-
getGlobalCooldown
int getGlobalCooldown()
Get the global cooldown timer in ticks.- Returns:
- cooldown in ticks
-
setGlobalCooldown
void setGlobalCooldown(int ticks)
Set the global cooldown timer in ticks.- Parameters:
ticks- cooldown in ticks
-
resetCooldowns
void resetCooldowns()
Reset all ability cooldowns.
-
forceStartAbility
boolean forceStartAbility(String abilityId)
Force start an ability on this NPC. If an ability is currently executing, it will be cancelled.- Parameters:
abilityId- The ID of the ability to start- Returns:
- true if the ability was started successfully
-
forceStartAbility
boolean forceStartAbility(String abilityId, Object target)
Force start an ability on this NPC with a specific target. If an ability is currently executing, it will be cancelled.- Parameters:
abilityId- The ID of the ability to starttarget- The target entity (can be null for self-targeted abilities)- Returns:
- true if the ability was started successfully
-
executeAbility
boolean executeAbility(String key)
Execute an ability on this NPC by key (built-in name or custom UUID). The NPC does NOT need to have this ability assigned. If an ability is currently executing, it will be cancelled.- Parameters:
key- The ability key (built-in name or custom UUID)- Returns:
- true if the ability was started successfully
-
executeAbility
boolean executeAbility(String key, Object target)
Execute an ability on this NPC with a specific target. The NPC does NOT need to have this ability assigned. If an ability is currently executing, it will be cancelled.- Parameters:
key- The ability key (built-in name or custom UUID)target- The target entity (can be null for self-targeted abilities)- Returns:
- true if the ability was started successfully
-
createAbility
IAbility createAbility(String typeId)
Create a new ability instance by type ID. The ability is not assigned to this NPC - use addAbility() to assign it.- Parameters:
typeId- The type ID (e.g., "cnpc:slam", "cnpc:projectile")- Returns:
- The new ability, or null if the type is unknown
-
getSourceAbility
IAbility getSourceAbility(String abilityId)
Get the live source reference of an ability by ID. UnlikegetAbility(String)which returns a safe copy, this returns the actual ability object. Modifications will permanently affect the NPC's ability configuration.- Parameters:
abilityId- The ID of the ability- Returns:
- The live ability reference, or null if not found
-
getSourceCurrentAbility
IAbility getSourceCurrentAbility()
Get the live source reference of the currently executing ability. UnlikegetCurrentAbility()which returns a safe copy, this returns the actual ability object. Modifications will permanently affect the NPC's ability configuration.- Returns:
- The live ability reference, or null if no ability is executing
-
-