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).
  • IgnoreCancelled supports 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.BlockPlaceBeforeEvent
Use
Cancelable placement hook. Payload includes player, world, position, block, item, consume flag, and from-item flag.
Kind
server.block.place
Payload
blockevent.BlockPlaceEvent
Use
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.BlockBreakBeforeEvent
Use
Cancelable break hook. Payload includes player, world, position, block, item, and mutable drop stack.
Kind
server.block.break
Payload
blockevent.BlockBreakEvent
Use
Published after break commit with player ID, world ID, position, block, item, drop, and collected count.
Kind
server.block.drop
Payload
blockevent.BlockDropEvent
Use
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.BlockRedstoneUpdateEvent
Use
Published when redstone power changes. Carries world ID, position, previous power, and next power.

Player Events

Kind
server.player.message.before
Payload
*playerevent.PlayerMessageBeforeEvent
Use
Cancelable player message hook. Payload carries player, message kind, title, and text.
Kind
server.player.message
Payload
playerevent.PlayerMessageEvent
Use
Published after message commit with player ID, message kind, title, and text.
Kind
server.player.kick.before
Payload
*playerevent.PlayerKickBeforeEvent
Use
Cancelable kick hook with player and reason.
Kind
server.player.kick
Payload
playerevent.PlayerKickEvent
Use
Published after kick commit with player ID and reason.
Kind
server.player.teleport.before
Payload
*playerevent.PlayerTeleportBeforeEvent
Use
Cancelable teleport hook with player, from position, and mutable target position.
Kind
server.player.teleport
Payload
playerevent.PlayerTeleportEvent
Use
Published after teleport commit with player ID, from position, and target position.
Kind
server.player.health.before
Payload
*playerevent.PlayerHealthBeforeEvent
Use
Cancelable health change hook with player, previous health, and mutable next health.
Kind
server.player.health
Payload
playerevent.PlayerHealthEvent
Use
Published after health commit with player ID, previous health, and current health.
Kind
server.player.max_health.before
Payload
*playerevent.PlayerMaxHealthBeforeEvent
Use
Cancelable max-health change hook with player, previous max health, and mutable next max health.
Kind
server.player.max_health
Payload
playerevent.PlayerMaxHealthEvent
Use
Published after max-health commit with player ID, previous max health, and current max health.
Kind
server.player.gamemode.before
Payload
*playerevent.PlayerGameModeBeforeEvent
Use
Cancelable game mode change hook with player, previous mode, and mutable next mode.
Kind
server.player.gamemode
Payload
playerevent.PlayerGameModeEvent
Use
Published after game mode commit with player ID, previous mode, and current mode.
Kind
server.player.abilities.before
Payload
*playerevent.PlayerAbilitiesBeforeEvent
Use
Cancelable abilities hook with player, allow-flight flag, and flying flag.
Kind
server.player.abilities
Payload
playerevent.PlayerAbilitiesEvent
Use
Published after ability commit with player ID, allow-flight flag, and flying flag.

Inventory Events

Kind
server.inventory.give.before
Payload
*inventoryevent.InventoryGiveBeforeEvent
Use
Cancelable give hook with player and mutable stack.
Kind
server.inventory.give
Payload
inventoryevent.InventoryGiveEvent
Use
Published after give commit with player ID, stack, and added count.
Kind
server.inventory.take.before
Payload
*inventoryevent.InventoryTakeBeforeEvent
Use
Cancelable take hook with player and mutable match stack.
Kind
server.inventory.take
Payload
inventoryevent.InventoryTakeEvent
Use
Published after take commit with player ID, match stack, and removed count.
Kind
server.container.open
Payload
inventoryevent.ContainerOpenEvent
Use
Published 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.EffectAddBeforeEvent
Use
Cancelable effect-add hook with player ID, entity ID, and effect spec.
Kind
server.effect.remove.before
Payload
*entityevent.EffectRemoveBeforeEvent
Use
Cancelable effect-remove hook with player ID, entity ID, and effect type.
Kind
server.effect.add
Payload
entityevent.EffectEvent
Use
Published after effect add with kind, player ID, entity ID, effect instance, replaced flag, and reason.
Kind
server.effect.remove
Payload
entityevent.EffectEvent
Use
Published after effect remove with the same shared effect payload.
Kind
server.effect.expire
Payload
entityevent.EffectEvent
Use
Published when an effect expires naturally. Uses the shared effect payload.

Task Events

Kind
server.task.accepted
Payload
task lifecycle event
Use
Published when bounded background work is accepted by the plugin task runner.
Kind
server.task.started
Payload
task lifecycle event
Use
Published when accepted work starts running.
Kind
server.task.completed
Payload
task lifecycle event
Use
Published when a task finishes successfully.
Kind
server.task.failed
Payload
task lifecycle event
Use
Published when a task returns or records an error.
Kind
server.task.canceled
Payload
task lifecycle event
Use
Published when task context cancellation stops work.