diff --git a/Dalamud/Game/Command/CommandInfo.cs b/Dalamud/Game/Command/CommandInfo.cs index 055c1d125..32413b510 100644 --- a/Dalamud/Game/Command/CommandInfo.cs +++ b/Dalamud/Game/Command/CommandInfo.cs @@ -3,20 +3,20 @@ namespace Dalamud.Game.Command; /// /// This class describes a registered command. /// -public sealed class CommandInfo : ICommandInfo +public sealed class CommandInfo : IReadOnlyCommandInfo { /// /// Initializes a new instance of the class. /// Create a new CommandInfo with the provided handler. /// /// The method to call when the command is run. - public CommandInfo(ICommandInfo.HandlerDelegate handler) + public CommandInfo(IReadOnlyCommandInfo.HandlerDelegate handler) { this.Handler = handler; } /// - public ICommandInfo.HandlerDelegate Handler { get; } + public IReadOnlyCommandInfo.HandlerDelegate Handler { get; } /// public string HelpMessage { get; set; } = string.Empty; @@ -28,7 +28,7 @@ public sealed class CommandInfo : ICommandInfo /// /// Interface representing a registered command. /// -public interface ICommandInfo +public interface IReadOnlyCommandInfo { /// /// The function to be executed when the command is dispatched. @@ -43,12 +43,12 @@ public interface ICommandInfo HandlerDelegate Handler { get; } /// - /// Gets or sets the help message for this command. + /// Gets the help message for this command. /// - string HelpMessage { get; set; } + string HelpMessage { get; } /// - /// Gets or sets a value indicating whether if this command should be shown in the help output. + /// Gets a value indicating whether if this command should be shown in the help output. /// - bool ShowInHelp { get; set; } + bool ShowInHelp { get; } } diff --git a/Dalamud/Game/Command/CommandManager.cs b/Dalamud/Game/Command/CommandManager.cs index c74f66d6e..dd0a8346d 100644 --- a/Dalamud/Game/Command/CommandManager.cs +++ b/Dalamud/Game/Command/CommandManager.cs @@ -24,8 +24,8 @@ internal sealed class CommandManager : IInternalDisposableService, ICommandManag { private static readonly ModuleLog Log = new("Command"); - private readonly ConcurrentDictionary commandMap = new(); - private readonly ConcurrentDictionary<(string, ICommandInfo), string> commandAssemblyNameMap = new(); + private readonly ConcurrentDictionary commandMap = new(); + private readonly ConcurrentDictionary<(string, IReadOnlyCommandInfo), string> commandAssemblyNameMap = new(); private readonly Regex commandRegexEn = new(@"^The command (?.+) does not exist\.$", RegexOptions.Compiled); private readonly Regex commandRegexJp = new(@"^そのコマンドはありません。: (?.+)$", RegexOptions.Compiled); private readonly Regex commandRegexDe = new(@"^„(?.+)“ existiert nicht als Textkommando\.$", RegexOptions.Compiled); @@ -56,7 +56,7 @@ internal sealed class CommandManager : IInternalDisposableService, ICommandManag } /// - public ReadOnlyDictionary Commands => new(this.commandMap); + public ReadOnlyDictionary Commands => new(this.commandMap); /// public bool ProcessCommand(string content) @@ -102,7 +102,7 @@ internal sealed class CommandManager : IInternalDisposableService, ICommandManag } /// - public void DispatchCommand(string command, string argument, ICommandInfo info) + public void DispatchCommand(string command, string argument, IReadOnlyCommandInfo info) { try { @@ -115,7 +115,7 @@ internal sealed class CommandManager : IInternalDisposableService, ICommandManag } /// - public bool AddHandler(string command, ICommandInfo info, string loaderAssemblyName = "") + public bool AddHandler(string command, CommandInfo info, string loaderAssemblyName = "") { if (info == null) throw new ArgumentNullException(nameof(info), "Command handler is null."); @@ -137,7 +137,7 @@ internal sealed class CommandManager : IInternalDisposableService, ICommandManag } /// - public bool AddHandler(string command, ICommandInfo info) + public bool AddHandler(string command, CommandInfo info) { if (info == null) throw new ArgumentNullException(nameof(info), "Command handler is null."); @@ -163,7 +163,7 @@ internal sealed class CommandManager : IInternalDisposableService, ICommandManag /// The command. /// A ICommandInfo object. /// The name of the assembly. - public string GetHandlerAssemblyName(string command, ICommandInfo commandInfo) + public string GetHandlerAssemblyName(string command, IReadOnlyCommandInfo commandInfo) { if (this.commandAssemblyNameMap.TryGetValue((command, commandInfo), out var assemblyName)) { @@ -178,7 +178,7 @@ internal sealed class CommandManager : IInternalDisposableService, ICommandManag /// /// The name of the assembly. /// A list of commands and their associated activation string. - public List> GetHandlersByAssemblyName(string assemblyName) + public List> GetHandlersByAssemblyName(string assemblyName) { return this.commandAssemblyNameMap.Where(c => c.Value == assemblyName).ToList(); } @@ -249,7 +249,7 @@ internal class CommandManagerPluginScoped : IInternalDisposableService, ICommand } /// - public ReadOnlyDictionary Commands => this.commandManagerService.Commands; + public ReadOnlyDictionary Commands => this.commandManagerService.Commands; /// void IInternalDisposableService.DisposeService() @@ -267,11 +267,11 @@ internal class CommandManagerPluginScoped : IInternalDisposableService, ICommand => this.commandManagerService.ProcessCommand(content); /// - public void DispatchCommand(string command, string argument, ICommandInfo info) + public void DispatchCommand(string command, string argument, IReadOnlyCommandInfo info) => this.commandManagerService.DispatchCommand(command, argument, info); /// - public bool AddHandler(string command, ICommandInfo info) + public bool AddHandler(string command, CommandInfo info) { if (!this.pluginRegisteredCommands.Contains(command)) { diff --git a/Dalamud/Plugin/Services/ICommandManager.cs b/Dalamud/Plugin/Services/ICommandManager.cs index 5816fb2e8..a6bc4763f 100644 --- a/Dalamud/Plugin/Services/ICommandManager.cs +++ b/Dalamud/Plugin/Services/ICommandManager.cs @@ -12,7 +12,7 @@ public interface ICommandManager /// /// Gets a read-only list of all registered commands. /// - public ReadOnlyDictionary Commands { get; } + public ReadOnlyDictionary Commands { get; } /// /// Process a command in full. @@ -27,7 +27,7 @@ public interface ICommandManager /// The command to dispatch. /// The provided arguments. /// A object describing this command. - public void DispatchCommand(string command, string argument, CommandInfo info); + public void DispatchCommand(string command, string argument, IReadOnlyCommandInfo info); /// /// Add a command handler, which you can use to add your own custom commands to the in-game chat.