Plugin basics

The plugin lifecycle - on_load, on_enable, on_disable - and the logger.

Every plugin is a class that extends Plugin and overrides the lifecycle methods the server calls for you. This page covers those three states and the logger you use throughout.

The lifecycle

The server drives each plugin through three states, which map to the methods you override:

src/endstone_my_plugin/my_plugin.py
from endstone.plugin import Plugin

class MyPlugin(Plugin):
    api_version = "0.11"

    def on_load(self) -> None:
        # read configuration and prepare state; the world isn't up yet
        self.logger.info("Loading...")

    def on_enable(self) -> None:
        # register commands and listeners, start tasks - the game is live
        self.logger.info("Enabled!")

    def on_disable(self) -> None:
        # flush anything unsaved and release what you acquired
        self.logger.info("Disabled.")
  • on_load - the server isn't fully up, so prepare internal state but don't touch the world.
  • on_enable - register commands and event listeners, start scheduled tasks, anything that touches the now-live game.
  • on_disable - on stop or reload, flush unsaved data and release resources.

Every plugin is loaded before any is enabled, so by the time on_enable runs you can rely on the plugins you depend on being present.

Logging

Every plugin has a self.logger that writes to the server console with your plugin's name attached:

self.logger.info("Ready.")
self.logger.warning("Config missing 'greeting', using default.")
self.logger.error("Failed to load data.")

Use it instead of print so your output is timestamped, level-tagged, and traceable to your plugin.

On this page