Reference

API reference

A list of the interfaces and methods addons can use.

On this page

FoundryAPI

Package: me.that1koda.foundry.api. Foundry passes this API to an addon when it starts the addon.

PropertyTypePurpose
pluginPluginThe Foundry plugin.
abilitiesAbilityRegistryAdd, find, list, and remove abilities.
abilityServiceAbilityServiceRun a registered ability by its ID.
playerAbilitiesPlayerAbilityServiceAssign, get, remove, or clear a player's action assignments.
itemAbilitiesItemAbilityServiceSave, 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

MemberSignature / defaultBehavior
idval id: StringThe ability's ID. It cannot be blank or already in use.
cooldownSecondsval cooldownSeconds: Long = 0LSeconds a player must wait after using the ability. 0 means no wait.
actionsval actions: Set<Action> = emptySet()Actions listed by this ability. Foundry does not use this list yet.
activatefun activate(context: AbilityContext)The code Foundry runs when the ability is used.
AbilityContext.playerPlayerThe player using the ability.
AbilityContext.idStringThe ID passed to AbilityService.activate().

Registry and services

InterfaceMethods
AbilityRegistryregister(base), unregister(id): Boolean, get(id): Ability?, getAll(): Collection<Ability>, isRegistered(id): Boolean
AbilityServiceactivate(id, context): Boolean
PlayerAbilityServiceassign(player, action, abilityId), remove(player, action), get(player, action): String?, clear(player)
ItemAbilityServiceassign(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.