FoundryAPI
Package: me.that1koda.foundry.api. Foundry passes this API to an addon when it starts the addon.
| Property | Type | Purpose |
|---|---|---|
| plugin | Plugin | The Foundry plugin. |
| abilities | AbilityRegistry | Add, find, list, and remove abilities. |
| abilityService | AbilityService | Run a registered ability by its ID. |
| playerAbilities | PlayerAbilityService | Assign, get, remove, or clear a player's action assignments. |
| itemAbilities | ItemAbilityService | Save, get, or remove an ability ID on an item. |
FoundryAddon
Package: me.that1koda.foundry.api.addon. An addon must provide an id, a version, and an onEnable(api) function. The onDisable() function is not called when the server shuts down yet; see the addon guide.
Ability and AbilityContext
| Member | Signature / default | Behavior |
|---|---|---|
| id | val id: String | The ability's ID. It cannot be blank or already in use. |
| cooldownSeconds | val cooldownSeconds: Long = 0L | Seconds a player must wait after using the ability. 0 means no wait. |
| actions | val actions: Set<Action> = emptySet() | Actions listed by this ability. Foundry does not use this list yet. |
| activate | fun activate(context: AbilityContext) | The code Foundry runs when the ability is used. |
| AbilityContext.player | Player | The player using the ability. |
| AbilityContext.id | String | The ID passed to AbilityService.activate(). |
Registry and services
| Interface | Methods |
|---|---|
| AbilityRegistry | register(base), unregister(id): Boolean, get(id): Ability?, getAll(): Collection<Ability>, isRegistered(id): Boolean |
| AbilityService | activate(id, context): Boolean |
| PlayerAbilityService | assign(player, action, abilityId), remove(player, action), get(player, action): String?, clear(player) |
| ItemAbilityService | assign(item, abilityId), remove(item), get(item): String? |
Action enum
Package: me.that1koda.foundry.api.activation. Actions are LEFT_CLICK, RIGHT_CLICK, SHIFT_LEFT_CLICK, SHIFT_RIGHT_CLICK, OFFHAND_LEFT_CLICK, OFFHAND_RIGHT_CLICK, OFFHAND_SHIFT_LEFT_CLICK, and OFFHAND_SHIFT_RIGHT_CLICK. SHIFT means the player is sneaking; OFFHAND means they used their other hand.