mirror of
https://github.com/KAMKEEL/CustomNPC-Plus-API.git
synced 2026-11-19 09:39:11 +00:00
Player Abilities
This commit is contained in:
1 parent
06c9daf81b
commit
db6a68e430
7 files changed
+261
-28
No files matched your search
@@ -151,6 +151,28 @@ public interface IAbility {
|
||||
*/
|
||||
int getCurrentTick();
|
||||
|
||||
/**
|
||||
* Get the allowed user type for this ability.
|
||||
* @return 0=NPC_ONLY, 1=PLAYER_ONLY, 2=BOTH
|
||||
*/
|
||||
int getAllowedByType();
|
||||
|
||||
/**
|
||||
* Set the allowed user type for this ability.
|
||||
* @param type 0=NPC_ONLY, 1=PLAYER_ONLY, 2=BOTH
|
||||
*/
|
||||
void setAllowedByType(int type);
|
||||
|
||||
/**
|
||||
* Check if this ability ignores cooldowns.
|
||||
*/
|
||||
boolean isIgnoreCooldown();
|
||||
|
||||
/**
|
||||
* Set whether this ability ignores cooldowns.
|
||||
*/
|
||||
void setIgnoreCooldown(boolean ignore);
|
||||
|
||||
/**
|
||||
* Get this ability's data as NBT.
|
||||
*/
|
||||
|
||||
@@ -30,4 +30,22 @@ public interface IAbilityHandler {
|
||||
* Returns null if the type is not registered.
|
||||
*/
|
||||
IAbility create(String typeId);
|
||||
|
||||
/**
|
||||
* Register a pre-configured ability by name.
|
||||
* These abilities are resolved by name and can be referenced by NPCs and players.
|
||||
* Call during FMLInitializationEvent.
|
||||
*
|
||||
* @param name The unique name for the ability
|
||||
* @param ability The ability instance
|
||||
*/
|
||||
void registerAbility(String name, IAbility ability);
|
||||
|
||||
/**
|
||||
* Check if a registered ability exists by name.
|
||||
*
|
||||
* @param name The ability name
|
||||
* @return true if the ability exists
|
||||
*/
|
||||
boolean hasAbility(String name);
|
||||
}
|
||||
@@ -17,15 +17,20 @@ public interface IDataAbilities {
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Get all abilities assigned to this NPC.
|
||||
* Get all abilities assigned to this NPC (resolved from slots).
|
||||
*/
|
||||
IAbility[] getAbilities();
|
||||
|
||||
/**
|
||||
* Add an ability to this NPC.
|
||||
* Add an inline ability to this NPC.
|
||||
*/
|
||||
void addAbility(IAbility ability);
|
||||
|
||||
/**
|
||||
* Add a reference ability by key (built-in name or custom UUID).
|
||||
*/
|
||||
void addAbilityReference(String key);
|
||||
|
||||
/**
|
||||
* Remove an ability by ID.
|
||||
*/
|
||||
@@ -41,6 +46,17 @@ public interface IDataAbilities {
|
||||
*/
|
||||
boolean hasAbility(String abilityId);
|
||||
|
||||
/**
|
||||
* Check if a slot is a reference (by ability ID).
|
||||
*/
|
||||
boolean isAbilityReference(String abilityId);
|
||||
|
||||
/**
|
||||
* Convert a reference slot to inline (by ability ID).
|
||||
* Returns false if the reference cannot be resolved.
|
||||
*/
|
||||
boolean convertToInline(String abilityId);
|
||||
|
||||
/**
|
||||
* Clear all abilities from this NPC.
|
||||
*/
|
||||
@@ -96,25 +112,25 @@ public interface IDataAbilities {
|
||||
boolean forceStartAbility(String abilityId, Object target);
|
||||
|
||||
/**
|
||||
* Execute a preset ability on this NPC by preset name.
|
||||
* 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.
|
||||
*
|
||||
* @param presetName The name of the saved ability preset
|
||||
* @param key The ability key (built-in name or custom UUID)
|
||||
* @return true if the ability was started successfully
|
||||
*/
|
||||
boolean executePresetAbility(String presetName);
|
||||
boolean executeAbility(String key);
|
||||
|
||||
/**
|
||||
* Execute a preset ability on this NPC with a specific 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.
|
||||
*
|
||||
* @param presetName The name of the saved ability preset
|
||||
* @param key The ability key (built-in name or custom UUID)
|
||||
* @param target The target entity (can be null for self-targeted abilities)
|
||||
* @return true if the ability was started successfully
|
||||
*/
|
||||
boolean executePresetAbility(String presetName, Object target);
|
||||
boolean executeAbility(String key, Object target);
|
||||
|
||||
/**
|
||||
* Create a new ability instance by type ID.
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package noppes.npcs.api.ability;
|
||||
|
||||
/**
|
||||
* Interface for managing player abilities.
|
||||
* Players reference abilities by key (built-in names or custom UUIDs).
|
||||
* <p>
|
||||
* Access via IPlayerData.getAbilityData()
|
||||
*/
|
||||
public interface IPlayerAbilityData {
|
||||
|
||||
/**
|
||||
* Get all unlocked ability keys.
|
||||
*/
|
||||
String[] getUnlockedAbilities();
|
||||
|
||||
/**
|
||||
* Unlock an ability for this player.
|
||||
*
|
||||
* @param key The ability key (built-in name or custom UUID)
|
||||
*/
|
||||
void unlockAbility(String key);
|
||||
|
||||
/**
|
||||
* Lock (remove) an ability from this player.
|
||||
*/
|
||||
void lockAbility(String key);
|
||||
|
||||
/**
|
||||
* Check if the player has unlocked a specific ability.
|
||||
*/
|
||||
boolean hasUnlockedAbility(String key);
|
||||
|
||||
/**
|
||||
* Get the currently selected ability index.
|
||||
*/
|
||||
int getSelectedIndex();
|
||||
|
||||
/**
|
||||
* Set the selected ability index.
|
||||
*/
|
||||
void setSelectedIndex(int index);
|
||||
|
||||
/**
|
||||
* Get the key of the currently selected ability.
|
||||
*/
|
||||
String getSelectedAbilityKey();
|
||||
|
||||
/**
|
||||
* Select the next ability in the list.
|
||||
*/
|
||||
void selectNext();
|
||||
|
||||
/**
|
||||
* Select the previous ability in the list.
|
||||
*/
|
||||
void selectPrevious();
|
||||
|
||||
/**
|
||||
* Check if the player is currently executing an ability.
|
||||
*/
|
||||
boolean isExecutingAbility();
|
||||
|
||||
/**
|
||||
* Get the currently executing ability.
|
||||
*/
|
||||
IAbility getCurrentAbility();
|
||||
|
||||
/**
|
||||
* Interrupt the currently executing ability.
|
||||
*/
|
||||
void interruptCurrentAbility();
|
||||
|
||||
/**
|
||||
* Check if the player is on universal cooldown.
|
||||
*/
|
||||
boolean isOnCooldown();
|
||||
|
||||
/**
|
||||
* Check if a specific ability is on cooldown.
|
||||
*
|
||||
* @param key The ability key
|
||||
* @return true if on cooldown
|
||||
*/
|
||||
boolean isOnCooldown(String key);
|
||||
|
||||
/**
|
||||
* Reset the universal cooldown.
|
||||
*/
|
||||
void resetCooldown();
|
||||
|
||||
/**
|
||||
* Reset cooldown for a specific ability key.
|
||||
*
|
||||
* @param key The ability key
|
||||
*/
|
||||
void resetCooldown(String key);
|
||||
|
||||
/**
|
||||
* Reset all cooldowns.
|
||||
*/
|
||||
void resetAllCooldowns();
|
||||
|
||||
/**
|
||||
* Activate the currently selected ability.
|
||||
*/
|
||||
boolean activateAbility();
|
||||
|
||||
/**
|
||||
* Activate a specific ability by key.
|
||||
*/
|
||||
boolean activateAbility(String key);
|
||||
}
|
||||
Reference in new issue
Block a user