Updated command system to use new generic type with attribute class.
This commit is contained in:
@@ -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<T1> : VariantArgAttribute
|
||||
{
|
||||
public VariantArg() : base(typeof(T1)) { }
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
public class VariantArg<T1, T2> : VariantArgAttribute
|
||||
{
|
||||
public VariantArg() : base(typeof(T1), typeof(T2)) { }
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
public class VariantArg<T1, T2, T3> : VariantArgAttribute
|
||||
{
|
||||
public VariantArg() : base(typeof(T1), typeof(T2), typeof(T3)) { }
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
public class VariantArg<T1, T2, T3, T4> : VariantArgAttribute
|
||||
{
|
||||
public VariantArg() : base(typeof(T1), typeof(T2), typeof(T3), typeof(T4)) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<uint, string>] object optArg)
|
||||
{
|
||||
Player player = handler.GetPlayer();
|
||||
if (player == null)
|
||||
|
||||
@@ -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<ulong, string>] dynamic guildIdentifier)
|
||||
{
|
||||
Guild guild = null;
|
||||
|
||||
|
||||
@@ -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<uint, string>] object mapArg, uint? difficultyArg)
|
||||
{
|
||||
Player player = handler.GetSelectedPlayer();
|
||||
if (player == null)
|
||||
|
||||
@@ -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<GameTele, string>] object where)
|
||||
{
|
||||
if (player == null)
|
||||
player = PlayerIdentifier.FromTargetOrSelf(handler);
|
||||
|
||||
Reference in New Issue
Block a user