Files
dalamud-plugin-template/src/Plugin.cs
T
JonKazama-Hellion 6e9a4abd8a
CI / build (push) Failing after 18s
Merge official Dalamud sample plugin into template
- Replace Plugin.cs/ConfigWindow.cs skeleton with working sample code
- Add MainWindow.cs (goat-image demo + PlayerState/Lumina queries)
- Rename src/PluginConfiguration.cs → src/Configuration.cs (sample naming)
- Add Data/goat.png sample asset
- Add src/packages.lock.json (NuGet lockfile from sample)
- Add PluginNameTemplate.sln solution file
- Bump csproj from Dalamud.NET.Sdk 13.0.0 → 15.0.0
- Bump yaml dalamud_api_level: 13 → 15
- Update README with sample-removal walkthrough and SDK-bump section

Template now builds end-to-end out of the box. Goat demo
intact for verification; strip per README when implementing
the real plugin.
2026-05-09 17:15:26 +02:00

86 lines
3.3 KiB
C#

using Dalamud.Game.Command;
using Dalamud.IoC;
using Dalamud.Plugin;
using System.IO;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin.Services;
using PluginNameTemplate.Windows;
namespace PluginNameTemplate;
public sealed class Plugin : IDalamudPlugin
{
[PluginService] internal static IDalamudPluginInterface PluginInterface { get; private set; } = null!;
[PluginService] internal static ITextureProvider TextureProvider { get; private set; } = null!;
[PluginService] internal static ICommandManager CommandManager { get; private set; } = null!;
[PluginService] internal static IClientState ClientState { get; private set; } = null!;
[PluginService] internal static IPlayerState PlayerState { get; private set; } = null!;
[PluginService] internal static IDataManager DataManager { get; private set; } = null!;
[PluginService] internal static IPluginLog Log { get; private set; } = null!;
private const string CommandName = "/pmycommand";
public Configuration Configuration { get; init; }
public readonly WindowSystem WindowSystem = new("PluginNameTemplate");
private ConfigWindow ConfigWindow { get; init; }
private MainWindow MainWindow { get; init; }
public Plugin()
{
Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
// You might normally want to embed resources and load them from the manifest stream
var goatImagePath = Path.Combine(PluginInterface.AssemblyLocation.Directory?.FullName!, "goat.png");
ConfigWindow = new ConfigWindow(this);
MainWindow = new MainWindow(this, goatImagePath);
WindowSystem.AddWindow(ConfigWindow);
WindowSystem.AddWindow(MainWindow);
CommandManager.AddHandler(CommandName, new CommandInfo(OnCommand)
{
HelpMessage = "A useful message to display in /xlhelp"
});
// Tell the UI system that we want our windows to be drawn through the window system
PluginInterface.UiBuilder.Draw += WindowSystem.Draw;
// This adds a button to the plugin installer entry of this plugin which allows
// toggling the display status of the configuration ui
PluginInterface.UiBuilder.OpenConfigUi += ToggleConfigUi;
// Adds another button doing the same but for the main ui of the plugin
PluginInterface.UiBuilder.OpenMainUi += ToggleMainUi;
// Add a simple message to the log with level set to information
// Use /xllog to open the log window in-game
Log.Information($"===A cool log message from {PluginInterface.Manifest.Name}===");
}
public void Dispose()
{
// Unregister all actions to not leak anything during disposal of plugin
PluginInterface.UiBuilder.Draw -= WindowSystem.Draw;
PluginInterface.UiBuilder.OpenConfigUi -= ToggleConfigUi;
PluginInterface.UiBuilder.OpenMainUi -= ToggleMainUi;
WindowSystem.RemoveAllWindows();
ConfigWindow.Dispose();
MainWindow.Dispose();
CommandManager.RemoveHandler(CommandName);
}
private void OnCommand(string command, string args)
{
// In response to the slash command, toggle the display status of our main ui
MainWindow.Toggle();
}
public void ToggleConfigUi() => ConfigWindow.Toggle();
public void ToggleMainUi() => MainWindow.Toggle();
}