From 34a7ea020b380358c5f64a2e6d371f343942c6ef Mon Sep 17 00:00:00 2001 From: Kam Date: Tue, 24 Feb 2026 21:23:39 -0500 Subject: [PATCH] Scripting Ability Handling Improvement and Copy Data --- .../npcs/api/ability/IDataAbilities.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/java/noppes/npcs/api/ability/IDataAbilities.java b/java/noppes/npcs/api/ability/IDataAbilities.java index 7e8b94f..081400a 100644 --- a/java/noppes/npcs/api/ability/IDataAbilities.java +++ b/java/noppes/npcs/api/ability/IDataAbilities.java @@ -18,6 +18,7 @@ public interface IDataAbilities { /** * Get all abilities assigned to this NPC (resolved from slots). + * Returns safe deep copies. Use {@link #getSourceAbility(String)} for live references. */ IAbility[] getAbilities(); @@ -38,6 +39,7 @@ public interface IDataAbilities { /** * Get an ability by ID. + * Returns a safe deep copy. Use {@link #getSourceAbility(String)} for the live reference. */ IAbility getAbility(String abilityId); @@ -64,6 +66,7 @@ public interface IDataAbilities { /** * Get the currently executing ability, or null if none. + * Returns a safe deep copy. Use {@link #getSourceCurrentAbility()} for the live reference. */ IAbility getCurrentAbility(); @@ -140,4 +143,25 @@ public interface IDataAbilities { * @return The new ability, or null if the type is unknown */ IAbility createAbility(String typeId); + + /** + * Get the live source reference of an ability by ID. + * Unlike {@link #getAbility(String)} which returns a safe copy, + * this returns the actual ability object. Modifications will permanently + * affect the NPC's ability configuration. + * + * @param abilityId The ID of the ability + * @return The live ability reference, or null if not found + */ + IAbility getSourceAbility(String abilityId); + + /** + * Get the live source reference of the currently executing ability. + * Unlike {@link #getCurrentAbility()} which returns a safe copy, + * this returns the actual ability object. Modifications will permanently + * affect the NPC's ability configuration. + * + * @return The live ability reference, or null if no ability is executing + */ + IAbility getSourceCurrentAbility(); }