Skip to content

@pumpkin-plugins/plugin-kit API / plugin / PluginBase

Abstract Class: PluginBase ​

Defined in: tools/plugin-kit/src/plugin.ts:11

Base class for plugins, keeping metadata, lifecycle hooks, logging and update checks consistent.

Extends ​

  • HostPlugin

Properties ​

info ​

readonly info: PluginInfo

Defined in: tools/plugin-kit/src/plugin.ts:13

The plugin's README and metadata declaration.

Methods ​

cancelTask() ​

cancelTask(taskId): void

Defined in: tools/pumpkin-api/src/host-plugin.ts:97

Cancel a task scheduled through this facade and release its callback.

Parameters ​

taskId ​

number

ID returned by a scheduling helper. Completed or unknown IDs are ignored.

Returns ​

void

Throws ​

Propagates host cancellation errors; the callback remains registered on failure.

Remarks ​

Use this helper instead of the raw scheduler to release captured resources promptly.

Inherited from ​

Plugin.cancelTask


handleIpcMessage() ​

handleIpcMessage(sender, message): IpcMessage

Defined in: tools/pumpkin-api/src/core.ts:110

Handle a message sent by another plugin.

Parameters ​

sender ​

string

ID of the sending plugin.

message ​

IpcMessage

Message payload.

Returns ​

IpcMessage

The reply sent to the caller.

Throws ​

When the plugin does not implement IPC message handling.

Inherited from ​

Plugin.handleIpcMessage


metadata() ​

metadata(): PluginMetadata

Defined in: tools/plugin-kit/src/plugin.ts:25

Builds Pumpkin's plugin metadata from the shared info declaration.

Returns ​

PluginMetadata

Overrides ​

Plugin.metadata


onLoad() ​

onLoad(ctx): void

Defined in: tools/plugin-kit/src/plugin.ts:30

Runs onPluginLoad when Pumpkin loads the plugin.

Parameters ​

ctx ​

Context

Returns ​

void

Overrides ​

Plugin.onLoad


onUnload() ​

onUnload(ctx): void

Defined in: tools/plugin-kit/src/plugin.ts:39

Runs onPluginUnload when Pumpkin unloads the plugin. The Pumpkin API clears its event, command and task handlers after this returns, so the hook can still use them.

Parameters ​

ctx ​

Context

Returns ​

void

Overrides ​

Plugin.onUnload


registerAiGoal() ​

registerAiGoal(goal): number

Defined in: tools/pumpkin-api/src/core.ts:182

Register a custom entity AI goal and return its handler ID.

Parameters ​

goal ​

AiGoal

Returns ​

number

Remarks ​

Pumpkin 0.2.0+26.3-26.51 does not start custom WASM goals because its host returns false from both goal eligibility methods.

Inherited from ​

Plugin.registerAiGoal


registerChunkGenerator() ​

registerChunkGenerator(generator): number

Defined in: tools/pumpkin-api/src/core.ts:189

Register a chunk generator and return its handler ID.

Parameters ​

generator ​

ChunkGenerator

Returns ​

number

Inherited from ​

Plugin.registerChunkGenerator


registerCommand() ​

registerCommand(context, command, handler, permission?): void

Defined in: tools/pumpkin-api/src/core.ts:157

Register a command callback.

Parameters ​

context ​

Context

Plugin context used to register the command.

command ​

Command

Command tree configured with Pumpkin's command API.

handler ​

CommandHandler

Callback invoked for the command.

permission? ​

string = ''

Permission required to run the command; defaults to no permission.

Returns ​

void

Remarks ​

If assigning the handler ID or registering with the host fails, the callback is removed from the dispatch registry. The command resource has no method to unset an assigned ID, so it may retain that ID after a failed registration.

Inherited from ​

Plugin.registerCommand


registerCommandSuggestionHandler() ​

registerCommandSuggestionHandler(handler): number

Defined in: tools/pumpkin-api/src/core.ts:170

Register a command suggestion callback and return its handler ID.

Parameters ​

handler ​

CommandSuggestionHandler

Returns ​

number

Inherited from ​

Plugin.registerCommandSuggestionHandler


registerEvent() ​

registerEvent<T>(context, eventType, handler, priority?, blocking?): void

Defined in: tools/pumpkin-api/src/core.ts:129

Register an event callback with the Pumpkin server.

Type Parameters ​

T ​

T extends EventType

Event discriminator that determines the callback payload.

Parameters ​

context ​

Context

Plugin context used to register the handler.

eventType ​

T

Event to receive.

handler ​

EventHandler<EventPayload<T>>

Callback for the event payload.

priority? ​

EventPriority = 'normal'

Dispatch priority; defaults to normal. It can only order handlers within the blocking or non-blocking group. Pumpkin 0.2.0+26.3-26.51 stores it but does not sort by it, so handlers in a group run in registration order.

blocking? ​

boolean = true

Whether Pumpkin applies the payload the handler returns; defaults to true. Pumpkin runs every blocking handler before any non-blocking one and ignores what non-blocking handlers return, so only blocking handlers can modify or cancel the event.

Returns ​

void

Remarks ​

The event type determines the payload type accepted by the callback.

Inherited from ​

Plugin.registerEvent


scheduleDelayedTask() ​

scheduleDelayedTask(delayTicks, handler): number

Defined in: tools/pumpkin-api/src/host-plugin.ts:54

Schedule a task after a delay.

Parameters ​

delayTicks ​

number | bigint

Non-negative delay in server ticks, as a safe integer or u64 bigint.

handler ​

TaskHandler

Callback invoked when the delay expires.

Returns ​

number

The task ID returned by Pumpkin.

Throws ​

When the delay is negative or is not a safe integer number or unsigned 64-bit bigint.

Inherited from ​

Plugin.scheduleDelayedTask


scheduleRepeatingTask() ​

scheduleRepeatingTask(delayTicks, periodTicks, handler): number

Defined in: tools/pumpkin-api/src/host-plugin.ts:76

Schedule a repeating task.

Parameters ​

delayTicks ​

number | bigint

Non-negative delay before the first invocation, as a safe integer or u64 bigint.

periodTicks ​

number | bigint

Positive interval between invocations, as a safe integer or u64 bigint.

handler ​

TaskHandler

Callback invoked on each scheduled tick.

Returns ​

number

The task ID returned by Pumpkin.

Throws ​

When either tick count is invalid or the period is not positive.

Inherited from ​

Plugin.scheduleRepeatingTask

pumpkin-plugins documentation