Started work on revamping command system for permissions, but I'm out for the night, cya tomorrow
This commit is contained in:
parent
3774c30f7d
commit
8344801128
6 changed files with 70 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ namespace TShockAPI
|
|||
public class Commands
|
||||
{
|
||||
public delegate void CommandDelegate(CommandArgs args);
|
||||
public static Command[] commands;
|
||||
|
||||
public struct CommandArgs
|
||||
{
|
||||
|
|
@ -24,6 +25,37 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
public class Command
|
||||
{
|
||||
private string name;
|
||||
private string permission;
|
||||
CommandDelegate command;
|
||||
|
||||
public Command(string cmdName, string permissionNeeded, CommandDelegate cmd)
|
||||
{
|
||||
name = cmdName;
|
||||
permission = permissionNeeded;
|
||||
command = cmd;
|
||||
}
|
||||
|
||||
public bool Run(string msg, TSPlayer ply)
|
||||
{
|
||||
if (!ply.group.HasPermission(permission))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CommandArgs args = new CommandArgs();
|
||||
args.Message = msg;
|
||||
args.PlayerX = (int)ply.GetPlayer().position.X;
|
||||
args.PlayerY = (int)ply.GetPlayer().position.Y;
|
||||
args.PlayerID = ply.GetPlayerID();
|
||||
|
||||
command(args);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitCommands()
|
||||
{
|
||||
TShock.admincommandList.Add("kick", new CommandDelegate(Kick));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue