Skip to content

@pumpkin-plugins/pumpkin-api API / host-plugin / HostPlugin

Abstract Class: HostPlugin ​

Defined in: host-plugin.ts:45

Base class for a Pumpkin plugin.

Subclasses provide metadata and register their handlers with the context during onLoad.

Example ​

typescript
import { Plugin, registerPlugin } from '@pumpkin-plugins/pumpkin-api';

class ExamplePlugin extends Plugin {
    metadata() {
        return {
            name: 'example', version: '1.0.0', authors: ['Example'],
            description: 'An example plugin', dependencies: [], permissions: []
        };
    }
}

registerPlugin(new ExamplePlugin());

Methods ​

cancelTask() ​

cancelTask(taskId): void

Defined in: 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.


handleIpcMessage() ​

handleIpcMessage(sender, message): IpcMessage

Defined in: 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 ​

CorePlugin.handleIpcMessage


metadata() ​

abstract metadata(): PluginMetadata

Defined in: core.ts:94

Return the manifest metadata supplied to the Pumpkin server.

Returns ​

PluginMetadata

Inherited from ​

CorePlugin.metadata


onLoad() ​

onLoad(context): void

Defined in: core.ts:97

Register startup handlers and perform plugin initialization.

Parameters ​

context ​

Context

Returns ​

void

Inherited from ​

CorePlugin.onLoad


onUnload() ​

onUnload(context): void

Defined in: core.ts:100

Save plugin state and release resources before unload.

Parameters ​

context ​

Context

Returns ​

void

Inherited from ​

CorePlugin.onUnload


registerAiGoal() ​

registerAiGoal(goal): number

Defined in: 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 ​

CorePlugin.registerAiGoal


registerChunkGenerator() ​

registerChunkGenerator(generator): number

Defined in: core.ts:189

Register a chunk generator and return its handler ID.

Parameters ​

generator ​

ChunkGenerator

Returns ​

number

Inherited from ​

CorePlugin.registerChunkGenerator


registerCommand() ​

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

Defined in: 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 ​

CorePlugin.registerCommand


registerCommandSuggestionHandler() ​

registerCommandSuggestionHandler(handler): number

Defined in: core.ts:170

Register a command suggestion callback and return its handler ID.

Parameters ​

handler ​

CommandSuggestionHandler

Returns ​

number

Inherited from ​

CorePlugin.registerCommandSuggestionHandler


registerEvent() ​

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

Defined in: 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 ​

CorePlugin.registerEvent


scheduleDelayedTask() ​

scheduleDelayedTask(delayTicks, handler): number

Defined in: 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.


scheduleRepeatingTask() ​

scheduleRepeatingTask(delayTicks, periodTicks, handler): number

Defined in: 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.

pumpkin-plugins documentation