KairoStartupBeforeEvent
import { router } from '@kairo-js/router'
The event object for router.beforeEvents.startup. Not directly instantiable.
Fires before Minecraft's worldLoad. Registering APIs, declaring hooks, registering custom commands, registering custom components, and subscribing to addon events are only valid inside this event handler.
Properties
addonApi
readonly addonApi: ApiRegistration
Register APIs and hooks.
addonEvents
readonly addonEvents: AddonEventRegistration
Subscribe to addon events emitted through router.emit().
blockComponentRegistry
readonly blockComponentRegistry: BlockComponentRegistry
Register Minecraft block custom components.
customCommandRegistry
readonly customCommandRegistry: KairoCustomCommandRegistry
Register custom commands.
itemComponentRegistry
readonly itemComponentRegistry: ItemComponentRegistry
Register Minecraft item custom components.
api
readonly api: ApiRegistration
Deprecated alias for addonApi.
events
readonly events: AddonEventRegistration
Deprecated alias for addonEvents.
Examples
import { router } from '@kairo-js/router'
router.beforeEvents.startup.subscribe((ev) => {
// Register an API
ev.addonApi.register<{ playerId: string }, { balance: number }>(
'economy/getBalance',
async ({ playerId }) => {
return { balance: getBalance(playerId) }
},
)
// Subscribe to another addon's event
ev.addonEvents.on('other-addon', 'someEvent', (payload) => {
console.log('Event received:', payload)
})
// Register Minecraft custom components
ev.itemComponentRegistry.registerCustomComponent('my:addon_item', {
onUse(event) {
console.log(event.source?.name)
},
})
// Register a custom command
ev.customCommandRegistry.registerCommand(
{ name: 'mycommand', description: 'My command' },
(origin) => {
console.log('Command executed')
},
)
})