@pumpkin-plugins/tab-display API / plugin / Plugin
Abstract Class: Plugin
Defined in: tools/pumpkin-api/src/host-plugin.ts:45
Base class for a Pumpkin plugin.
Subclasses provide metadata and register their handlers with the context during onLoad.
Example
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());Extends
Plugin
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.
handleIpcMessage()
handleIpcMessage(
sender,message):IpcMessage
Defined in: tools/pumpkin-api/src/core.ts:91
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()
abstractmetadata():PluginMetadata
Defined in: tools/pumpkin-api/src/core.ts:75
Return the manifest metadata supplied to the Pumpkin server.
Returns
PluginMetadata
Inherited from
CorePlugin.metadata
onLoad()
onLoad(
context):void
Defined in: tools/pumpkin-api/src/core.ts:78
Register startup handlers and perform plugin initialization.
Parameters
context
Context
Returns
void
Inherited from
CorePlugin.onLoad
onUnload()
onUnload(
context):void
Defined in: tools/pumpkin-api/src/core.ts:81
Save plugin state and release resources before unload.
Parameters
context
Context
Returns
void
Inherited from
CorePlugin.onUnload
registerAiGoal()
registerAiGoal(
goal):number
Defined in: tools/pumpkin-api/src/core.ts:159
Register a custom entity AI goal and return its handler ID.
Parameters
goal
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: tools/pumpkin-api/src/core.ts:166
Register a chunk generator and return its handler ID.
Parameters
generator
Returns
number
Inherited from
CorePlugin.registerChunkGenerator
registerCommand()
registerCommand(
context,command,handler,permission?):void
Defined in: tools/pumpkin-api/src/core.ts:134
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
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: tools/pumpkin-api/src/core.ts:147
Register a command suggestion callback and return its handler ID.
Parameters
handler
Returns
number
Inherited from
CorePlugin.registerCommandSuggestionHandler
registerEvent()
registerEvent<
T>(context,eventType,handler,priority?,blocking?):void
Defined in: tools/pumpkin-api/src/core.ts:106
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
Callback for the event payload.
priority?
EventPriority = 'normal'
Dispatch priority; defaults to normal.
blocking?
boolean = true
Whether this handler may block event processing; defaults to true.
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: 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
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: 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
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.