Skip to main content

Overview

IDalamudPluginInterface is your plugin’s main gateway to Dalamud functionality. It’s automatically injected into your plugin’s constructor and provides access to:
  • UI building and drawing
  • Configuration management
  • Plugin metadata and state
  • Inter-plugin communication (IPC)
  • Service creation and injection
  • Dalamud system information
See the full interface definition in Dalamud/Plugin/IDalamudPluginInterface.cs:25-335.

Basic Usage

Receive the interface via constructor injection:
public class Plugin : IDalamudPlugin
{
    private readonly IDalamudPluginInterface pluginInterface;

    public Plugin(IDalamudPluginInterface pluginInterface)
    {
        this.pluginInterface = pluginInterface;
        
        // Access interface members
        var reason = pluginInterface.Reason;
        var configDir = pluginInterface.ConfigDirectory;
    }
}

Properties

Plugin Information

InternalName
string
The current internal plugin name.
var name = pluginInterface.InternalName;
// "MyPlugin"
See IDalamudPluginInterface.cs:70
Manifest
IPluginManifest
The plugin’s manifest containing all metadata.
var manifest = pluginInterface.Manifest;
var author = manifest.Author;
var version = manifest.AssemblyVersion;
var description = manifest.Description;
See IDalamudPluginInterface.cs:76
Reason
PluginLoadReason
The reason this plugin was loaded.
var reason = pluginInterface.Reason;

if (reason.HasFlag(PluginLoadReason.Boot))
{
    // First load on game start
}
else if (reason.HasFlag(PluginLoadReason.Update))
{
    // Plugin was just updated
}
Possible values (see PluginLoadReason.cs:8-33):
  • Unknown: Unknown reason
  • Installer: Installed via plugin installer
  • Update: Just updated
  • Reload: Developer reload
  • Boot: Game started or Dalamud reinjected
See IDalamudPluginInterface.cs:52
IsDev
bool
Whether this is a dev plugin.
if (pluginInterface.IsDev)
{
    // Enable debug features
}
See IDalamudPluginInterface.cs:81
IsTesting
bool
Whether this is a testing release of a plugin.
if (pluginInterface.IsTesting)
{
    // Running beta version
}
See IDalamudPluginInterface.cs:89
SourceRepository
string
The repository from which this plugin was installed.Official plugins return SpecialPluginSource.MainRepo. Dev plugins return SpecialPluginSource.DevPlugin.
var repo = pluginInterface.SourceRepository;
See IDalamudPluginInterface.cs:66

Timing Information

LoadTime
DateTime
The local time when this plugin was loaded.
var loadTime = pluginInterface.LoadTime;
See IDalamudPluginInterface.cs:94
LoadTimeUTC
DateTime
The UTC time when this plugin was loaded.
var loadTimeUtc = pluginInterface.LoadTimeUTC;
See IDalamudPluginInterface.cs:99
LoadTimeDelta
TimeSpan
The time elapsed since this plugin was loaded.
var elapsed = pluginInterface.LoadTimeDelta;
Console.WriteLine($"Plugin has been running for {elapsed.TotalMinutes:F2} minutes");
See IDalamudPluginInterface.cs:104

Directories and Files

DalamudAssetDirectory
DirectoryInfo
The directory where Dalamud assets are stored.
var assetDir = pluginInterface.DalamudAssetDirectory;
var iconPath = Path.Combine(assetDir.FullName, "UIRes", "icon.png");
See IDalamudPluginInterface.cs:109
AssemblyLocation
FileInfo
The location of your plugin assembly.
var dllPath = pluginInterface.AssemblyLocation;
var pluginDir = dllPath.Directory;
See IDalamudPluginInterface.cs:114
ConfigDirectory
DirectoryInfo
The directory where your plugin configurations are stored.
var configDir = pluginInterface.ConfigDirectory;
var customFile = Path.Combine(configDir.FullName, "custom.json");
See IDalamudPluginInterface.cs:119
ConfigFile
FileInfo
The default config file for your plugin.
var configFile = pluginInterface.ConfigFile;
// Typically: %AppData%/XIVLauncher/pluginConfig/MyPlugin/MyPlugin.json
See IDalamudPluginInterface.cs:124

UI and System State

UiBuilder
IUiBuilder
The UI builder instance for drawing ImGui interfaces.
var uiBuilder = pluginInterface.UiBuilder;

// Register draw handler
uiBuilder.Draw += DrawUI;

// Register config UI handler
uiBuilder.OpenConfigUi += () => configWindow.IsOpen = true;

// Access fonts
var defaultFont = uiBuilder.DefaultFontHandle;
var iconFont = uiBuilder.IconFontHandle;
See IDalamudPluginInterface.cs:129 and UiBuilder.cs:28-335
IsDevMenuOpen
bool
Whether Dalamud is running in Debug mode or the /xldev menu is open.
if (pluginInterface.IsDevMenuOpen)
{
    // Show debug information
}
See IDalamudPluginInterface.cs:134
IsDebugging
bool
Whether a debugger is attached.
if (pluginInterface.IsDebugging)
{
    // Enable additional logging
}
See IDalamudPluginInterface.cs:139
UiLanguage
string
The current UI language in two-letter ISO format.
var lang = pluginInterface.UiLanguage;
// "en", "ja", "de", "fr"

var greeting = lang switch
{
    "ja" => "こんにちは",
    "de" => "Hallo",
    "fr" => "Bonjour",
    _ => "Hello"
};
See IDalamudPluginInterface.cs:144
IsAutoUpdateComplete
bool
Whether auto-updates have completed this session.
if (pluginInterface.IsAutoUpdateComplete)
{
    // All plugins have finished updating
}
See IDalamudPluginInterface.cs:57

Utilities

Sanitizer
ISanitizer
Serializer class with functions to remove special characters from strings.
var sanitizer = pluginInterface.Sanitizer;
var clean = sanitizer.Sanitize("Text with <special> chars");
See IDalamudPluginInterface.cs:149
GeneralChatType
XivChatType
The chat type used by default for plugin messages.
var chatType = pluginInterface.GeneralChatType;
See IDalamudPluginInterface.cs:154
InstalledPlugins
IEnumerable<IExposedPlugin>
A list of installed plugins along with their current state.
foreach (var plugin in pluginInterface.InstalledPlugins)
{
    Console.WriteLine($"{plugin.Name} - {plugin.IsLoaded}");
}
See IDalamudPluginInterface.cs:159

Events

LanguageChanged
event LanguageChangedDelegate
Event fired when the UI language changes.
pluginInterface.LanguageChanged += OnLanguageChanged;

private void OnLanguageChanged(string langCode)
{
    // Reload localization
    LoadTranslations(langCode);
}

// Don't forget to unsubscribe in Dispose!
pluginInterface.LanguageChanged -= OnLanguageChanged;
See IDalamudPluginInterface.cs:42
ActivePluginsChanged
event ActivePluginsChangedDelegate
Event fired when the active list of plugins changes.
pluginInterface.ActivePluginsChanged += OnActivePluginsChanged;

private void OnActivePluginsChanged(IActivePluginsChangedEventArgs args)
{
    // Handle plugin state changes
}

// Unsubscribe in Dispose
pluginInterface.ActivePluginsChanged -= OnActivePluginsChanged;
See IDalamudPluginInterface.cs:47

Configuration Methods

SavePluginConfig
void (IPluginConfiguration?)
Save a plugin configuration that inherits IPluginConfiguration.
public class MyConfig : IPluginConfiguration
{
    public int Version { get; set; } = 1;
    public bool Enabled { get; set; } = true;
}

var config = new MyConfig();
pluginInterface.SavePluginConfig(config);
See IDalamudPluginInterface.cs:284
GetPluginConfig
IPluginConfiguration?
Get a previously saved plugin configuration or null if none exists.
var config = pluginInterface.GetPluginConfig() as MyConfig ?? new MyConfig();
See IDalamudPluginInterface.cs:290
GetPluginConfigDirectory
string
Get the config directory path.
var dir = pluginInterface.GetPluginConfigDirectory();
// %AppData%/XIVLauncher/pluginConfig/MyPlugin
See IDalamudPluginInterface.cs:296
GetPluginLocDirectory
string
Get the localization directory path.
var locDir = pluginInterface.GetPluginLocDirectory();
// %AppData%/XIVLauncher/pluginConfig/MyPlugin/loc

var langFile = Path.Combine(locDir, $"{langCode}.json");
See IDalamudPluginInterface.cs:302

UI Integration

OpenPluginInstallerTo
bool (PluginInstallerOpenKind, string?)
Opens the plugin installer window.
// Open to all plugins
pluginInterface.OpenPluginInstallerTo();

// Open with search
pluginInterface.OpenPluginInstallerTo(
    PluginInstallerOpenKind.AllPlugins,
    "crafting");

// Open to installed plugins
pluginInterface.OpenPluginInstallerTo(
    PluginInstallerOpenKind.InstalledPlugins);
See IDalamudPluginInterface.cs:167
OpenDalamudSettingsTo
bool (SettingsOpenKind, string?)
Opens the Dalamud settings window.
// Open to general settings
pluginInterface.OpenDalamudSettingsTo();

// Open with search
pluginInterface.OpenDalamudSettingsTo(
    SettingsOpenKind.General,
    "auto update");
See IDalamudPluginInterface.cs:175
OpenDeveloperMenu
bool
Opens the dev menu bar.
pluginInterface.OpenDeveloperMenu();
See IDalamudPluginInterface.cs:181

Plugin Queries

GetPlugin
IExposedPlugin? (Assembly|AssemblyLoadContext)
Gets information about which plugin an assembly or load context belongs to.
// Get plugin from assembly
var assembly = typeof(SomeType).Assembly;
var plugin = pluginInterface.GetPlugin(assembly);

// Get plugin from context
var context = AssemblyLoadContext.GetLoadContext(assembly);
var plugin2 = pluginInterface.GetPlugin(context);

if (plugin != null)
{
    Console.WriteLine($"Belongs to: {plugin.Name}");
}
See IDalamudPluginInterface.cs:188, 195
GetDalamudVersion
IDalamudVersionInfo
Gets information about the version of Dalamud this plugin is loaded into.
var version = pluginInterface.GetDalamudVersion();
Console.WriteLine($"Dalamud version: {version.Version}");
See IDalamudPluginInterface.cs:201

Data Sharing

Share data between plugins using tag-based storage:
GetOrCreateData<T>
T (string, Func<T>)
Gets existing data or creates it if it doesn’t exist.
var sharedData = pluginInterface.GetOrCreateData(
    "MySharedData",
    () => new MyDataClass());
See IDalamudPluginInterface.cs:204
TryGetData<T>
bool (string, out T?)
Tries to get existing data.
if (pluginInterface.TryGetData<MyDataClass>("MySharedData", out var data))
{
    // Data exists, use it
}
See IDalamudPluginInterface.cs:210
GetData<T>
T?
Gets existing data or null.
var data = pluginInterface.GetData<MyDataClass>("MySharedData");
See IDalamudPluginInterface.cs:213
RelinquishData
void (string)
Releases shared data.
pluginInterface.RelinquishData("MySharedData");
See IDalamudPluginInterface.cs:207

Inter-Plugin Communication (IPC)

See the IPC guide for detailed information.

Provider Methods

Create IPC providers to expose functionality:
// Action with no return
var provider = pluginInterface.GetIpcProvider<string, object>("MyPlugin.DoSomething");
provider.RegisterAction((message) => 
{
    Console.WriteLine($"Received: {message}");
});

// Function with return value
var funcProvider = pluginInterface.GetIpcProvider<int, int, int>("MyPlugin.Add");
funcProvider.RegisterFunc((a, b) => a + b);
Supported overloads (see IDalamudPluginInterface.cs:222-247):
  • GetIpcProvider<TRet>(name)
  • GetIpcProvider<T1, TRet>(name)
  • GetIpcProvider<T1, T2, TRet>(name)
  • … up to 8 type parameters

Subscriber Methods

Subscribe to other plugins’ IPC:
// Subscribe to action
var subscriber = pluginInterface.GetIpcSubscriber<string, object>("OtherPlugin.Event");
subscriber.Subscribe((message) => 
{
    Console.WriteLine($"Event fired: {message}");
});

// Call function
var funcSub = pluginInterface.GetIpcSubscriber<int, int, int>("OtherPlugin.Add");
var result = funcSub.InvokeFunc(5, 3); // returns 8
Supported overloads (see IDalamudPluginInterface.cs:254-279):
  • GetIpcSubscriber<TRet>(name)
  • GetIpcSubscriber<T1, TRet>(name)
  • GetIpcSubscriber<T1, T2, TRet>(name)
  • … up to 8 type parameters

Dependency Injection

Create and inject instances with dependencies:
Create<T>
T? (params object[])
Create a new object with dependency injection.
public class MyService
{
    public MyService(IChatGui chatGui, ICommandManager commands)
    {
        // Dependencies are injected
    }
}

var service = pluginInterface.Create<MyService>();

// With scoped objects
var service2 = pluginInterface.Create<MyService>(customDependency);
See IDalamudPluginInterface.cs:310
CreateAsync<T>
Task<T> (params object[])
Asynchronously create a new object with dependency injection.
var service = await pluginInterface.CreateAsync<MyService>();
See IDalamudPluginInterface.cs:318
Inject
bool (object, params object[])
Inject services into an existing object’s properties.
public class MyClass
{
    [PluginService] public IChatGui ChatGui { get; set; } = null!;
}

var obj = new MyClass();
pluginInterface.Inject(obj);
// obj.ChatGui is now injected
See IDalamudPluginInterface.cs:326
InjectAsync
Task (object, params object[])
Asynchronously inject services into an existing object.
var obj = new MyClass();
await pluginInterface.InjectAsync(obj);
See IDalamudPluginInterface.cs:334

Complete Example

Here’s a comprehensive example using many interface features:
Plugin.cs
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using Dalamud.Game.Command;

namespace MyPlugin;

public class Plugin : IDalamudPlugin
{
    private readonly IDalamudPluginInterface pluginInterface;
    private readonly ICommandManager commandManager;
    private readonly IChatGui chatGui;
    private readonly Configuration config;
    private readonly PluginUI ui;

    public Plugin(
        IDalamudPluginInterface pluginInterface,
        ICommandManager commandManager,
        IChatGui chatGui)
    {
        this.pluginInterface = pluginInterface;
        this.commandManager = commandManager;
        this.chatGui = chatGui;

        // Load configuration
        this.config = pluginInterface.GetPluginConfig() as Configuration 
                      ?? new Configuration();

        // Log load information
        var reason = pluginInterface.Reason;
        chatGui.Print($"Loaded via: {reason}");
        
        if (pluginInterface.IsDev)
        {
            chatGui.Print("Running as dev plugin");
        }

        // Create UI
        this.ui = new PluginUI(this);
        pluginInterface.UiBuilder.Draw += ui.Draw;
        pluginInterface.UiBuilder.OpenConfigUi += () => ui.IsVisible = true;

        // Register commands
        commandManager.AddHandler("/myplugin", new CommandInfo(OnCommand)
        {
            HelpMessage = "Opens My Plugin"
        });

        // Listen for language changes
        pluginInterface.LanguageChanged += OnLanguageChanged;

        // Set up IPC
        var ipcProvider = pluginInterface.GetIpcProvider<string, object>("MyPlugin.Event");
        ipcProvider.RegisterAction(message => 
        {
            chatGui.Print($"IPC: {message}");
        });
    }

    private void OnCommand(string command, string args)
    {
        ui.IsVisible = !ui.IsVisible;
    }

    private void OnLanguageChanged(string langCode)
    {
        chatGui.Print($"Language changed to: {langCode}");
        ui.ReloadTranslations(langCode);
    }

    public void Dispose()
    {
        // Save configuration
        pluginInterface.SavePluginConfig(config);

        // Unregister events
        pluginInterface.LanguageChanged -= OnLanguageChanged;
        pluginInterface.UiBuilder.Draw -= ui.Draw;

        // Remove commands
        commandManager.RemoveHandler("/myplugin");

        // Clean up UI
        ui.Dispose();
    }
}

Best Practices

Always Unsubscribe

Always unsubscribe from events in Dispose(). Failing to do so causes memory leaks.

Check for Nulls

Some properties may be null. Always check before using them.

Use IPC Carefully

IPC calls can throw exceptions if the other plugin isn’t loaded. Wrap in try-catch.

Respect Load Reason

Use Reason to adjust behavior. Don’t show welcome messages on every reload.

Next Steps

UI Builder

Learn how to create rich user interfaces with ImGui

IPC Overview

Master inter-plugin communication

Services

Explore all available Dalamud services

Debugging

Learn how to debug your plugin effectively

Build docs developers (and LLMs) love