-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommand.cs
More file actions
32 lines (27 loc) · 817 Bytes
/
Command.cs
File metadata and controls
32 lines (27 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
namespace Network
{
class Command
{
public int argNumber = 0;
public Type[] argTypes;
public Action<Client, string[]> Execute;
public bool ValidateArgs(string[] args)
{
if (argNumber == -1)
return true;
if (argNumber != args.Length)
{
Console.WriteLine(argNumber + " arguments needed");
return false;
}
for (int i = 0; i < argNumber; i++)
if (Convert.ChangeType(args[i], argTypes[i]) == null)
{
Console.WriteLine(args[i] + " must be of type " + argTypes[i]);
return false;
}
return true;
}
}
}