Skip to content

Plugin

Namespace Mc.Scripting · Kind class (abstract)

public abstract class Plugin : IPlugin

Convenience base class exposing the plugin’s scoped services.

Minimal plugin

using Mc.Scripting;
[PluginInfo("Hello", Version = "1.0.0", Author = "you")]
public sealed class Hello : Plugin
{
protected override void OnEnable()
{
Events.On((ref PlayerJoinEvent e) => Log.Info($"{e.Username.ToString()} joined"));
}
protected override void OnDisable() => Log.Info("bye");
}
Member Description
Plugin() Plugins have a parameterless constructor (implicit).
protected Plugin()

Plugins have a parameterless constructor (implicit). Do not do work in it; use OnEnable.

Member Description
BossBars BossBars { get; } Boss bars of this plugin (removed from every viewer when the plugin unloads).
ChannelRegistry Channels { get; } Plugin messaging channels: listen on a channel (ChannelRegistry.On).
ChunkTickets ChunkTickets { get; } Chunk tickets of this plugin: chunks it keeps loaded (released when the plugin unloads).
CommandRegistry Commands { get; } Commands of this plugin.
PluginConfig Config { get; } Configuration files and the data folder of this plugin.
PluginContext Context { get; } The plugin’s scoped services.
string DataFolder { get; } The plugin’s data folder (plugins/<id>/), created on first access.
Ecs Ecs { get; } ECS access (components, queries).
EventRegistry Events { get; } Event subscriptions of this plugin.
Holograms Holograms { get; } Holograms: text that floats in the world for the players (removed when the plugin unloads).
PluginMetadata Info { get; } What the plugin declares about itself (id, version, dependencies, …).
Logger Log { get; } The plugin’s logger.
Menus Menus { get; } Custom GUIs of this plugin (closed for every viewer when the plugin unloads).
Npcs Npcs { get; } NPCs: fake players with a skin, equipment and click events (removed when the plugin unloads).
PluginPermissions Permissions { get; } Permission nodes of this plugin and permission queries.
Scheduler Scheduler { get; } Scheduled tasks of this plugin.
ServiceManager Services { get; } Plugin-to-plugin services: register an implementation, look up another plugin’s.
Sidebars Sidebars { get; } Per-player sidebar scoreboards of this plugin (hidden when the plugin unloads).
SystemRegistry Systems { get; } ECS systems of this plugin.
public BossBars BossBars { get; }

Boss bars of this plugin (removed from every viewer when the plugin unloads).

public ChannelRegistry Channels { get; }

Plugin messaging channels: listen on a channel (ChannelRegistry.On).

public ChunkTickets ChunkTickets { get; }

Chunk tickets of this plugin: chunks it keeps loaded (released when the plugin unloads).

public CommandRegistry Commands { get; }

Commands of this plugin.

public PluginConfig Config { get; }

Configuration files and the data folder of this plugin.

public PluginContext Context { get; }

The plugin’s scoped services.

public string DataFolder { get; }

The plugin’s data folder (plugins/<id>/), created on first access.

public Ecs Ecs { get; }

ECS access (components, queries).

public EventRegistry Events { get; }

Event subscriptions of this plugin.

public Holograms Holograms { get; }

Holograms: text that floats in the world for the players (removed when the plugin unloads).

public PluginMetadata Info { get; }

What the plugin declares about itself (id, version, dependencies, …).

public Logger Log { get; }

The plugin’s logger.

public Menus Menus { get; }

Custom GUIs of this plugin (closed for every viewer when the plugin unloads).

public Npcs Npcs { get; }

NPCs: fake players with a skin, equipment and click events (removed when the plugin unloads).

public PluginPermissions Permissions { get; }

Permission nodes of this plugin and permission queries.

public Scheduler Scheduler { get; }

Scheduled tasks of this plugin.

public ServiceManager Services { get; }

Plugin-to-plugin services: register an implementation, look up another plugin’s.

public Sidebars Sidebars { get; }

Per-player sidebar scoreboards of this plugin (hidden when the plugin unloads).

public SystemRegistry Systems { get; }

ECS systems of this plugin.

Member Description
virtual void OnDisable() Optional cleanup; registrations are released automatically afterwards.
abstract void OnEnable() Register events, commands and systems here.
protected virtual void OnDisable()

Optional cleanup; registrations are released automatically afterwards.

protected abstract void OnEnable()

Register events, commands and systems here.

BossBars · ChannelRegistry · ChunkTickets · CommandRegistry · Ecs · EventRegistry · Holograms · IPlugin · Log · Logger · Menus · Npcs · PluginConfig · PluginContext · PluginMetadata · PluginPermissions · Scheduler · ServiceManager · Sidebars · SystemRegistry