Events (v0.2)
Event bus, priority options, and before/after event behaviour for gameplay.
In this section
Related section pages:
Events
ctx.On(...), ctx.OnPriority(...), and ctx.OnWithOptions(...) subscribe gameplay events from ctx.Events().
events-v02.go
ctx.OnWithOptions( blockevent.EventBlockPlaceBefore, coreevent.SubscribeOptions{Priority: coreevent.PriorityHigh, IgnoreCancelled: true}, func(event coreevent.Event) { before, ok := event.(*blockevent.BlockPlaceBeforeEvent) if !ok { return } before.Cancel("permission denied") },)- Priority order is controlled by coreevent priorities (Highest / Lowest).
IgnoreCancelledsupports skipping handlers for already-cancelled before-events.- Before-event handlers may mutate payload fields before the operation is committed.
Block Events
Kind
server.block.place.before
Payload
*blockevent.BlockPlaceBeforeEventUse
Cancelable placement hook. Payload includes player, world, position, block, item, consume flag, and from-item flag.
Kind
server.block.place
Payload
blockevent.BlockPlaceEventUse
Published after a block is placed. Carries player ID, world ID, position, block, item, consumed flag, and from-item flag.
Kind
server.block.break.before
Payload
*blockevent.BlockBreakBeforeEventUse
Cancelable break hook. Payload includes player, world, position, block, item, and mutable drop stack.
Kind
server.block.break
Payload
blockevent.BlockBreakEventUse
Published after break commit with player ID, world ID, position, block, item, drop, and collected count.
Kind
server.block.drop
Payload
blockevent.BlockDropEventUse
Published when a block drop is produced or collected. Carries player ID, world ID, position, block, drop, and collected count.
Kind
server.block.redstone.update
Payload
blockevent.BlockRedstoneUpdateEventUse
Published when redstone power changes. Carries world ID, position, previous power, and next power.
Kind
Payload
Use
server.block.place.before
*blockevent.BlockPlaceBeforeEventCancelable placement hook. Payload includes player, world, position, block, item, consume flag, and from-item flag.
server.block.place
blockevent.BlockPlaceEventPublished after a block is placed. Carries player ID, world ID, position, block, item, consumed flag, and from-item flag.
server.block.break.before
*blockevent.BlockBreakBeforeEventCancelable break hook. Payload includes player, world, position, block, item, and mutable drop stack.
server.block.break
blockevent.BlockBreakEventPublished after break commit with player ID, world ID, position, block, item, drop, and collected count.
server.block.drop
blockevent.BlockDropEventPublished when a block drop is produced or collected. Carries player ID, world ID, position, block, drop, and collected count.
server.block.redstone.update
blockevent.BlockRedstoneUpdateEventPublished when redstone power changes. Carries world ID, position, previous power, and next power.
Player Events
Kind
server.player.message.before
Payload
*playerevent.PlayerMessageBeforeEventUse
Cancelable player message hook. Payload carries player, message kind, title, and text.
Kind
server.player.message
Payload
playerevent.PlayerMessageEventUse
Published after message commit with player ID, message kind, title, and text.
Kind
server.player.kick.before
Payload
*playerevent.PlayerKickBeforeEventUse
Cancelable kick hook with player and reason.
Kind
server.player.kick
Payload
playerevent.PlayerKickEventUse
Published after kick commit with player ID and reason.
Kind
server.player.teleport.before
Payload
*playerevent.PlayerTeleportBeforeEventUse
Cancelable teleport hook with player, from position, and mutable target position.
Kind
server.player.teleport
Payload
playerevent.PlayerTeleportEventUse
Published after teleport commit with player ID, from position, and target position.
Kind
server.player.health.before
Payload
*playerevent.PlayerHealthBeforeEventUse
Cancelable health change hook with player, previous health, and mutable next health.
Kind
server.player.health
Payload
playerevent.PlayerHealthEventUse
Published after health commit with player ID, previous health, and current health.
Kind
server.player.max_health.before
Payload
*playerevent.PlayerMaxHealthBeforeEventUse
Cancelable max-health change hook with player, previous max health, and mutable next max health.
Kind
server.player.max_health
Payload
playerevent.PlayerMaxHealthEventUse
Published after max-health commit with player ID, previous max health, and current max health.
Kind
server.player.gamemode.before
Payload
*playerevent.PlayerGameModeBeforeEventUse
Cancelable game mode change hook with player, previous mode, and mutable next mode.
Kind
server.player.gamemode
Payload
playerevent.PlayerGameModeEventUse
Published after game mode commit with player ID, previous mode, and current mode.
Kind
server.player.abilities.before
Payload
*playerevent.PlayerAbilitiesBeforeEventUse
Cancelable abilities hook with player, allow-flight flag, and flying flag.
Kind
server.player.abilities
Payload
playerevent.PlayerAbilitiesEventUse
Published after ability commit with player ID, allow-flight flag, and flying flag.
Kind
Payload
Use
server.player.message.before
*playerevent.PlayerMessageBeforeEventCancelable player message hook. Payload carries player, message kind, title, and text.
server.player.message
playerevent.PlayerMessageEventPublished after message commit with player ID, message kind, title, and text.
server.player.kick.before
*playerevent.PlayerKickBeforeEventCancelable kick hook with player and reason.
server.player.kick
playerevent.PlayerKickEventPublished after kick commit with player ID and reason.
server.player.teleport.before
*playerevent.PlayerTeleportBeforeEventCancelable teleport hook with player, from position, and mutable target position.
server.player.teleport
playerevent.PlayerTeleportEventPublished after teleport commit with player ID, from position, and target position.
server.player.health.before
*playerevent.PlayerHealthBeforeEventCancelable health change hook with player, previous health, and mutable next health.
server.player.health
playerevent.PlayerHealthEventPublished after health commit with player ID, previous health, and current health.
server.player.max_health.before
*playerevent.PlayerMaxHealthBeforeEventCancelable max-health change hook with player, previous max health, and mutable next max health.
server.player.max_health
playerevent.PlayerMaxHealthEventPublished after max-health commit with player ID, previous max health, and current max health.
server.player.gamemode.before
*playerevent.PlayerGameModeBeforeEventCancelable game mode change hook with player, previous mode, and mutable next mode.
server.player.gamemode
playerevent.PlayerGameModeEventPublished after game mode commit with player ID, previous mode, and current mode.
server.player.abilities.before
*playerevent.PlayerAbilitiesBeforeEventCancelable abilities hook with player, allow-flight flag, and flying flag.
server.player.abilities
playerevent.PlayerAbilitiesEventPublished after ability commit with player ID, allow-flight flag, and flying flag.
Inventory Events
Kind
server.inventory.give.before
Payload
*inventoryevent.InventoryGiveBeforeEventUse
Cancelable give hook with player and mutable stack.
Kind
server.inventory.give
Payload
inventoryevent.InventoryGiveEventUse
Published after give commit with player ID, stack, and added count.
Kind
server.inventory.take.before
Payload
*inventoryevent.InventoryTakeBeforeEventUse
Cancelable take hook with player and mutable match stack.
Kind
server.inventory.take
Payload
inventoryevent.InventoryTakeEventUse
Published after take commit with player ID, match stack, and removed count.
Kind
server.container.open
Payload
inventoryevent.ContainerOpenEventUse
Published when a block container opens for a player. Carries player ID, world ID, position, container ID, and container type.
Kind
Payload
Use
server.inventory.give.before
*inventoryevent.InventoryGiveBeforeEventCancelable give hook with player and mutable stack.
server.inventory.give
inventoryevent.InventoryGiveEventPublished after give commit with player ID, stack, and added count.
server.inventory.take.before
*inventoryevent.InventoryTakeBeforeEventCancelable take hook with player and mutable match stack.
server.inventory.take
inventoryevent.InventoryTakeEventPublished after take commit with player ID, match stack, and removed count.
server.container.open
inventoryevent.ContainerOpenEventPublished when a block container opens for a player. Carries player ID, world ID, position, container ID, and container type.
Entity And Effect Events
Kind
server.effect.add.before
Payload
*entityevent.EffectAddBeforeEventUse
Cancelable effect-add hook with player ID, entity ID, and effect spec.
Kind
server.effect.remove.before
Payload
*entityevent.EffectRemoveBeforeEventUse
Cancelable effect-remove hook with player ID, entity ID, and effect type.
Kind
server.effect.add
Payload
entityevent.EffectEventUse
Published after effect add with kind, player ID, entity ID, effect instance, replaced flag, and reason.
Kind
server.effect.remove
Payload
entityevent.EffectEventUse
Published after effect remove with the same shared effect payload.
Kind
server.effect.expire
Payload
entityevent.EffectEventUse
Published when an effect expires naturally. Uses the shared effect payload.
Kind
Payload
Use
server.effect.add.before
*entityevent.EffectAddBeforeEventCancelable effect-add hook with player ID, entity ID, and effect spec.
server.effect.remove.before
*entityevent.EffectRemoveBeforeEventCancelable effect-remove hook with player ID, entity ID, and effect type.
server.effect.add
entityevent.EffectEventPublished after effect add with kind, player ID, entity ID, effect instance, replaced flag, and reason.
server.effect.remove
entityevent.EffectEventPublished after effect remove with the same shared effect payload.
server.effect.expire
entityevent.EffectEventPublished when an effect expires naturally. Uses the shared effect payload.
Task Events
Kind
server.task.accepted
Payload
task lifecycle eventUse
Published when bounded background work is accepted by the plugin task runner.
Kind
server.task.started
Payload
task lifecycle eventUse
Published when accepted work starts running.
Kind
server.task.completed
Payload
task lifecycle eventUse
Published when a task finishes successfully.
Kind
server.task.failed
Payload
task lifecycle eventUse
Published when a task returns or records an error.
Kind
server.task.canceled
Payload
task lifecycle eventUse
Published when task context cancellation stops work.
Kind
Payload
Use
server.task.accepted
task lifecycle eventPublished when bounded background work is accepted by the plugin task runner.
server.task.started
task lifecycle eventPublished when accepted work starts running.
server.task.completed
task lifecycle eventPublished when a task finishes successfully.
server.task.failed
task lifecycle eventPublished when a task returns or records an error.
server.task.canceled
task lifecycle eventPublished when task context cancellation stops work.