From 4cbee1a6bbec8a01b93cf876a7744ef536d90bff Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 1 Oct 2023 07:29:47 -0400 Subject: [PATCH] Updated command system to use new generic type with attribute class. --- Source/Game/Chat/CommandAttribute.cs | 26 ++++++++++++++++++- Source/Game/Chat/Commands/DebugCommands.cs | 2 +- Source/Game/Chat/Commands/GuildCommands.cs | 2 +- Source/Game/Chat/Commands/InstanceCommands.cs | 2 +- Source/Game/Chat/Commands/TeleCommands.cs | 2 +- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Source/Game/Chat/CommandAttribute.cs b/Source/Game/Chat/CommandAttribute.cs index 703f1d824..0b3fa4931 100644 --- a/Source/Game/Chat/CommandAttribute.cs +++ b/Source/Game/Chat/CommandAttribute.cs @@ -3,6 +3,7 @@ using Framework.Constants; using System; +using System.Numerics; namespace Game.Chat { @@ -66,7 +67,6 @@ namespace Game.Chat [AttributeUsage(AttributeTargets.Parameter)] public class OptionalArgAttribute : Attribute { } - [AttributeUsage(AttributeTargets.Parameter)] public class VariantArgAttribute : Attribute { public Type[] Types { get; set; } @@ -76,4 +76,28 @@ namespace Game.Chat Types = types; } } + + [AttributeUsage(AttributeTargets.Parameter)] + public class VariantArg : VariantArgAttribute + { + public VariantArg() : base(typeof(T1)) { } + } + + [AttributeUsage(AttributeTargets.Parameter)] + public class VariantArg : VariantArgAttribute + { + public VariantArg() : base(typeof(T1), typeof(T2)) { } + } + + [AttributeUsage(AttributeTargets.Parameter)] + public class VariantArg : VariantArgAttribute + { + public VariantArg() : base(typeof(T1), typeof(T2), typeof(T3)) { } + } + + [AttributeUsage(AttributeTargets.Parameter)] + public class VariantArg : VariantArgAttribute + { + public VariantArg() : base(typeof(T1), typeof(T2), typeof(T3), typeof(T4)) { } + } } diff --git a/Source/Game/Chat/Commands/DebugCommands.cs b/Source/Game/Chat/Commands/DebugCommands.cs index 71df90929..6fd61a5c5 100644 --- a/Source/Game/Chat/Commands/DebugCommands.cs +++ b/Source/Game/Chat/Commands/DebugCommands.cs @@ -440,7 +440,7 @@ namespace Game.Chat } [Command("instancespawn", RBACPermissions.CommandDebug)] - static bool HandleDebugInstanceSpawns(CommandHandler handler, [VariantArg(typeof(uint), typeof(string))] object optArg) + static bool HandleDebugInstanceSpawns(CommandHandler handler, [VariantArg] object optArg) { Player player = handler.GetPlayer(); if (player == null) diff --git a/Source/Game/Chat/Commands/GuildCommands.cs b/Source/Game/Chat/Commands/GuildCommands.cs index 1945edd4b..cbc821069 100644 --- a/Source/Game/Chat/Commands/GuildCommands.cs +++ b/Source/Game/Chat/Commands/GuildCommands.cs @@ -167,7 +167,7 @@ namespace Game.Chat } [Command("info", RBACPermissions.CommandGuildInfo, true)] - static bool HandleGuildInfoCommand(CommandHandler handler, [OptionalArg][VariantArg(typeof(ulong), typeof(string))] dynamic guildIdentifier) + static bool HandleGuildInfoCommand(CommandHandler handler, [OptionalArg][VariantArg] dynamic guildIdentifier) { Guild guild = null; diff --git a/Source/Game/Chat/Commands/InstanceCommands.cs b/Source/Game/Chat/Commands/InstanceCommands.cs index 631213bde..c2cc799c3 100644 --- a/Source/Game/Chat/Commands/InstanceCommands.cs +++ b/Source/Game/Chat/Commands/InstanceCommands.cs @@ -141,7 +141,7 @@ namespace Game.Chat } [Command("unbind", RBACPermissions.CommandInstanceUnbind)] - static bool HandleInstanceUnbindCommand(CommandHandler handler, [VariantArg(typeof(uint), typeof(string))] object mapArg, uint? difficultyArg) + static bool HandleInstanceUnbindCommand(CommandHandler handler, [VariantArg] object mapArg, uint? difficultyArg) { Player player = handler.GetSelectedPlayer(); if (player == null) diff --git a/Source/Game/Chat/Commands/TeleCommands.cs b/Source/Game/Chat/Commands/TeleCommands.cs index f2f9e54d7..f6e47fedb 100644 --- a/Source/Game/Chat/Commands/TeleCommands.cs +++ b/Source/Game/Chat/Commands/TeleCommands.cs @@ -223,7 +223,7 @@ namespace Game.Chat class TeleNameCommands { [Command("", RBACPermissions.CommandTeleName, true)] - static bool HandleTeleNameCommand(CommandHandler handler, [OptionalArg] PlayerIdentifier player, [VariantArg(typeof(GameTele), typeof(string))] object where) + static bool HandleTeleNameCommand(CommandHandler handler, [OptionalArg] PlayerIdentifier player, [VariantArg] object where) { if (player == null) player = PlayerIdentifier.FromTargetOrSelf(handler);