Plugin
Namespace Mc.Scripting · Kind class (abstract)
public abstract class Plugin : IPluginConvenience base class exposing the plugin’s scoped services.
Examples
Section titled “Examples”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");}Constructors
Section titled “Constructors”| Member | Description |
|---|---|
Plugin() |
Plugins have a parameterless constructor (implicit). |
Constructor
Section titled “Constructor”protected Plugin()Plugins have a parameterless constructor (implicit). Do not do work in it; use OnEnable.
Properties
Section titled “Properties”| 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. |
BossBars
Section titled “BossBars”public BossBars BossBars { get; }Boss bars of this plugin (removed from every viewer when the plugin unloads).
Channels
Section titled “Channels”public ChannelRegistry Channels { get; }Plugin messaging channels: listen on a channel (ChannelRegistry.On).
ChunkTickets
Section titled “ChunkTickets”public ChunkTickets ChunkTickets { get; }Chunk tickets of this plugin: chunks it keeps loaded (released when the plugin unloads).
Commands
Section titled “Commands”public CommandRegistry Commands { get; }Commands of this plugin.
Config
Section titled “Config”public PluginConfig Config { get; }Configuration files and the data folder of this plugin.
Context
Section titled “Context”public PluginContext Context { get; }The plugin’s scoped services.
DataFolder
Section titled “DataFolder”public string DataFolder { get; }The plugin’s data folder (plugins/<id>/), created on first access.
public Ecs Ecs { get; }ECS access (components, queries).
Events
Section titled “Events”public EventRegistry Events { get; }Event subscriptions of this plugin.
Holograms
Section titled “Holograms”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).
Permissions
Section titled “Permissions”public PluginPermissions Permissions { get; }Permission nodes of this plugin and permission queries.
Scheduler
Section titled “Scheduler”public Scheduler Scheduler { get; }Scheduled tasks of this plugin.
Services
Section titled “Services”public ServiceManager Services { get; }Plugin-to-plugin services: register an implementation, look up another plugin’s.
Sidebars
Section titled “Sidebars”public Sidebars Sidebars { get; }Per-player sidebar scoreboards of this plugin (hidden when the plugin unloads).
Systems
Section titled “Systems”public SystemRegistry Systems { get; }ECS systems of this plugin.
Methods
Section titled “Methods”| Member | Description |
|---|---|
virtual void OnDisable() |
Optional cleanup; registrations are released automatically afterwards. |
abstract void OnEnable() |
Register events, commands and systems here. |
OnDisable
Section titled “OnDisable”protected virtual void OnDisable()Optional cleanup; registrations are released automatically afterwards.
OnEnable
Section titled “OnEnable”protected abstract void OnEnable()Register events, commands and systems here.
See also
Section titled “See also”BossBars · ChannelRegistry · ChunkTickets · CommandRegistry · Ecs · EventRegistry · Holograms · IPlugin · Log · Logger · Menus · Npcs · PluginConfig · PluginContext · PluginMetadata · PluginPermissions · Scheduler · ServiceManager · Sidebars · SystemRegistry