PlayerCommandEventArgs passes the command prefix
Fix tab space conflict in PlayerHooks.cs
This commit is contained in:
parent
02564b5f9c
commit
32218f9be0
2 changed files with 67 additions and 66 deletions
|
|
@ -623,7 +623,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
IEnumerable<Command> cmds = ChatCommands.FindAll(c => c.HasAlias(cmdName));
|
IEnumerable<Command> cmds = ChatCommands.FindAll(c => c.HasAlias(cmdName));
|
||||||
|
|
||||||
if (Hooks.PlayerHooks.OnPlayerCommand(player, cmdName, cmdText, args, ref cmds))
|
if (Hooks.PlayerHooks.OnPlayerCommand(player, cmdName, cmdText, args, ref cmds, cmdPrefix))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (cmds.Count() == 0)
|
if (cmds.Count() == 0)
|
||||||
|
|
|
||||||
|
|
@ -21,30 +21,31 @@ using System.ComponentModel;
|
||||||
|
|
||||||
namespace TShockAPI.Hooks
|
namespace TShockAPI.Hooks
|
||||||
{
|
{
|
||||||
public class PlayerPostLoginEventArgs
|
public class PlayerPostLoginEventArgs
|
||||||
{
|
{
|
||||||
public TSPlayer Player { get; set; }
|
public TSPlayer Player { get; set; }
|
||||||
public PlayerPostLoginEventArgs(TSPlayer ply)
|
public PlayerPostLoginEventArgs(TSPlayer ply)
|
||||||
{
|
{
|
||||||
Player = ply;
|
Player = ply;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlayerPreLoginEventArgs : HandledEventArgs
|
public class PlayerPreLoginEventArgs : HandledEventArgs
|
||||||
{
|
{
|
||||||
public TSPlayer Player { get; set; }
|
public TSPlayer Player { get; set; }
|
||||||
public string LoginName { get; set; }
|
public string LoginName { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlayerCommandEventArgs : HandledEventArgs
|
public class PlayerCommandEventArgs : HandledEventArgs
|
||||||
{
|
{
|
||||||
public TSPlayer Player { get; set; }
|
public TSPlayer Player { get; set; }
|
||||||
public string CommandName { get; set; }
|
public string CommandName { get; set; }
|
||||||
public string CommandText { get; set; }
|
public string CommandText { get; set; }
|
||||||
public List<string> Parameters { get; set; }
|
public List<string> Parameters { get; set; }
|
||||||
public IEnumerable<Command> CommandList { get; set; }
|
public IEnumerable<Command> CommandList { get; set; }
|
||||||
}
|
public string CommandPrefix { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class PlayerChatEventArgs : HandledEventArgs
|
public class PlayerChatEventArgs : HandledEventArgs
|
||||||
{
|
{
|
||||||
|
|
@ -53,59 +54,59 @@ namespace TShockAPI.Hooks
|
||||||
public string TShockFormattedText { get; set; }
|
public string TShockFormattedText { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PlayerHooks
|
public static class PlayerHooks
|
||||||
{
|
{
|
||||||
public delegate void PlayerPostLoginD(PlayerPostLoginEventArgs e);
|
public delegate void PlayerPostLoginD(PlayerPostLoginEventArgs e);
|
||||||
public static event PlayerPostLoginD PlayerPostLogin;
|
public static event PlayerPostLoginD PlayerPostLogin;
|
||||||
|
|
||||||
public delegate void PlayerPreLoginD(PlayerPreLoginEventArgs e);
|
public delegate void PlayerPreLoginD(PlayerPreLoginEventArgs e);
|
||||||
public static event PlayerPreLoginD PlayerPreLogin;
|
public static event PlayerPreLoginD PlayerPreLogin;
|
||||||
|
|
||||||
public delegate void PlayerCommandD(PlayerCommandEventArgs e);
|
public delegate void PlayerCommandD(PlayerCommandEventArgs e);
|
||||||
public static event PlayerCommandD PlayerCommand;
|
public static event PlayerCommandD PlayerCommand;
|
||||||
|
|
||||||
public delegate void PlayerChatD(PlayerChatEventArgs e);
|
public delegate void PlayerChatD(PlayerChatEventArgs e);
|
||||||
public static event PlayerChatD PlayerChat;
|
public static event PlayerChatD PlayerChat;
|
||||||
|
|
||||||
public static void OnPlayerPostLogin(TSPlayer ply)
|
public static void OnPlayerPostLogin(TSPlayer ply)
|
||||||
{
|
{
|
||||||
if (PlayerPostLogin == null)
|
if (PlayerPostLogin == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerPostLoginEventArgs args = new PlayerPostLoginEventArgs(ply);
|
PlayerPostLoginEventArgs args = new PlayerPostLoginEventArgs(ply);
|
||||||
PlayerPostLogin(args);
|
PlayerPostLogin(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool OnPlayerCommand(TSPlayer player, string cmdName, string cmdText, List<string> args, ref IEnumerable<Command> commands)
|
public static bool OnPlayerCommand(TSPlayer player, string cmdName, string cmdText, List<string> args, ref IEnumerable<Command> commands, string cmdPrefix)
|
||||||
{
|
{
|
||||||
if (PlayerCommand == null)
|
if (PlayerCommand == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlayerCommandEventArgs playerCommandEventArgs = new PlayerCommandEventArgs()
|
PlayerCommandEventArgs playerCommandEventArgs = new PlayerCommandEventArgs()
|
||||||
{
|
{
|
||||||
Player = player,
|
Player = player,
|
||||||
CommandName = cmdName,
|
CommandName = cmdName,
|
||||||
CommandText = cmdText,
|
CommandText = cmdText,
|
||||||
Parameters = args,
|
Parameters = args,
|
||||||
CommandList = commands
|
CommandList = commands,
|
||||||
};
|
CommandPrefix = cmdPrefix,
|
||||||
PlayerCommand(playerCommandEventArgs);
|
};
|
||||||
commands = playerCommandEventArgs.CommandList;
|
PlayerCommand(playerCommandEventArgs);
|
||||||
return playerCommandEventArgs.Handled;
|
return playerCommandEventArgs.Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool OnPlayerPreLogin(TSPlayer ply, string name, string pass)
|
public static bool OnPlayerPreLogin(TSPlayer ply, string name, string pass)
|
||||||
{
|
{
|
||||||
if (PlayerPreLogin == null)
|
if (PlayerPreLogin == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var args = new PlayerPreLoginEventArgs {Player = ply, LoginName = name, Password = pass};
|
var args = new PlayerPreLoginEventArgs {Player = ply, LoginName = name, Password = pass};
|
||||||
PlayerPreLogin(args);
|
PlayerPreLogin(args);
|
||||||
return args.Handled;
|
return args.Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnPlayerChat(TSPlayer ply, string rawtext, ref string tshockText)
|
public static void OnPlayerChat(TSPlayer ply, string rawtext, ref string tshockText)
|
||||||
{
|
{
|
||||||
|
|
@ -116,5 +117,5 @@ namespace TShockAPI.Hooks
|
||||||
PlayerChat(args);
|
PlayerChat(args);
|
||||||
tshockText = args.TShockFormattedText;
|
tshockText = args.TShockFormattedText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue