Skip to content

PluginContext

Namespace Mc.Scripting · Kind class (sealed)

public sealed class PluginContext

Per-plugin services. Everything registered through it is released automatically when the plugin unloads or hot-reloads.

Plugins normally use the same members through the Plugin base class properties (Events, Commands, …). Use the context directly when your code lives outside the plugin class: pass it to helper classes so everything they register is released with the plugin.

Member Description
string AssemblyPath { get; } Path of the plugin assembly.
BossBars BossBars { get; } Boss bars.
ChannelRegistry Channels { get; } Plugin messaging channels of this plugin (ChannelRegistry).
ChunkTickets ChunkTickets { get; } Chunk tickets.
CommandRegistry Commands { get; } Commands.
PluginConfig Config { get; } Configuration files and the data folder.
Ecs Ecs { get; } ECS access.
EventRegistry Events { get; } Event subscriptions.
Holograms Holograms { get; } Holograms (text displays).
int Id { get; } Stable plugin id (kept across hot reloads).
PluginMetadata Info { get; } What the plugin declares about itself (plugin.json or PluginInfoAttribute).
bool IsUnloaded { get; } Whether the plugin was unloaded.
Logger Log { get; } The plugin’s logger.
Menus Menus { get; } Custom GUIs (menus) owned by this plugin.
string Name { get; } The plugin name.
Npcs Npcs { get; } NPCs (fake players).
PluginPermissions Permissions { get; } Permissions.
Scheduler Scheduler { get; } Scheduler.
ServiceManager Services { get; } Plugin-to-plugin services.
Sidebars Sidebars { get; } Sidebars.
SystemRegistry Systems { get; } Systems.
string Version { get; } The plugin version.
public string AssemblyPath { get; }

Path of the plugin assembly.

public BossBars BossBars { get; }

Boss bars.

public ChannelRegistry Channels { get; }

Plugin messaging channels of this plugin (ChannelRegistry).

public ChunkTickets ChunkTickets { get; }

Chunk tickets.

public CommandRegistry Commands { get; }

Commands.

public PluginConfig Config { get; }

Configuration files and the data folder.

public Ecs Ecs { get; }

ECS access.

public EventRegistry Events { get; }

Event subscriptions.

public Holograms Holograms { get; }

Holograms (text displays).

public int Id { get; }

Stable plugin id (kept across hot reloads).

public PluginMetadata Info { get; }

What the plugin declares about itself (plugin.json or PluginInfoAttribute).

public bool IsUnloaded { get; }

Whether the plugin was unloaded.

public Logger Log { get; }

The plugin’s logger.

public Menus Menus { get; }

Custom GUIs (menus) owned by this plugin.

public string Name { get; }

The plugin name.

public Npcs Npcs { get; }

NPCs (fake players).

public PluginPermissions Permissions { get; }

Permissions.

public Scheduler Scheduler { get; }

Scheduler.

public ServiceManager Services { get; }

Plugin-to-plugin services.

public Sidebars Sidebars { get; }

Sidebars.

public SystemRegistry Systems { get; }

Systems.

public string Version { get; }

The plugin version.

Member Description
void Track(IPluginResource resource) Registers an arbitrary resource to be disposed on unload.
public void Track(IPluginResource resource)

Registers an arbitrary resource to be disposed on unload.

Parameters

Name Type Description
resource IPluginResource

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