Added hooks
This commit is contained in:
parent
c67d5cf152
commit
ffed36c6fd
1 changed files with 101 additions and 0 deletions
|
|
@ -119,6 +119,53 @@ namespace TShockAPI.Hooks
|
|||
public string CommandPrefix { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EventArgs used for the <see cref="PlayerHooks.PrePlayerCommand"/> event.
|
||||
/// </summary>
|
||||
public class PrePlayerCommandEventArgs : HandledEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The command entered by the player.
|
||||
/// </summary>
|
||||
public Command Command { get; }
|
||||
/// <summary>
|
||||
/// Command arguments.
|
||||
/// </summary>
|
||||
public CommandArgs Arguments { get; set; }
|
||||
|
||||
public PrePlayerCommandEventArgs(Command command, CommandArgs args)
|
||||
{
|
||||
Command = command;
|
||||
Arguments = args;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EventArgs used for the <see cref="PlayerHooks.PostPlayerCommand"/> event.
|
||||
/// </summary>
|
||||
public class PostPlayerCommandEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The command entered by the player.
|
||||
/// </summary>
|
||||
public Command Command { get; }
|
||||
/// <summary>
|
||||
/// Command arguments.
|
||||
/// </summary>
|
||||
public CommandArgs Arguments { get; }
|
||||
/// <summary>
|
||||
/// Is the command executed.
|
||||
/// </summary>
|
||||
public bool Handled { get; }
|
||||
|
||||
public PostPlayerCommandEventArgs(Command command, CommandArgs arguments, bool handled)
|
||||
{
|
||||
Command = command;
|
||||
Arguments = arguments;
|
||||
Handled = handled;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EventArgs used for the <see cref="PlayerHooks.PlayerChat"/> event.
|
||||
/// </summary>
|
||||
|
|
@ -343,6 +390,26 @@ namespace TShockAPI.Hooks
|
|||
/// </summary>
|
||||
public static event PlayerCommandD PlayerCommand;
|
||||
|
||||
/// <summary>
|
||||
/// The delegate of the <see cref="PrePlayerCommand"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The EventArgs for this event.</param>
|
||||
public delegate void PrePlayerCommandD(PrePlayerCommandEventArgs e);
|
||||
/// <summary>
|
||||
/// Fired before the command is run.
|
||||
/// </summary>
|
||||
public static event PrePlayerCommandD PrePlayerCommand;
|
||||
|
||||
/// <summary>
|
||||
/// The delegate of the <see cref="PostPlayerCommand"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The EventArgs for this event.</param>
|
||||
public delegate void PostPlayerCommandD(PostPlayerCommandEventArgs e);
|
||||
/// <summary>
|
||||
/// Fired after the command is run.
|
||||
/// </summary>
|
||||
public static event PostPlayerCommandD PostPlayerCommand;
|
||||
|
||||
/// <summary>
|
||||
/// The delegate of the <see cref="PlayerChat"/> event.
|
||||
/// </summary>
|
||||
|
|
@ -449,6 +516,40 @@ namespace TShockAPI.Hooks
|
|||
return playerCommandEventArgs.Handled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires the <see cref="PrePlayerCommand"/> event.
|
||||
/// </summary>
|
||||
/// <param name="cmd">Command to be executed</param>
|
||||
/// <param name="arguments">Command arguments</param>
|
||||
/// <returns>True if the event has been handled.</returns>
|
||||
public static bool OnPrePlayerCommand(Command cmd, ref CommandArgs arguments)
|
||||
{
|
||||
if (PrePlayerCommand == null)
|
||||
return false;
|
||||
|
||||
PrePlayerCommandEventArgs args = new PrePlayerCommandEventArgs(cmd, arguments);
|
||||
|
||||
PrePlayerCommand(args);
|
||||
|
||||
arguments = args.Arguments;
|
||||
return args.Handled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires the <see cref="PostPlayerCommand"/> event.
|
||||
/// </summary>
|
||||
/// <param name="cmd">Executed command.</param>
|
||||
/// <param name="arguments">Command arguments.</param>
|
||||
/// <param name="handled">Is the command executed.</param>
|
||||
public static void OnPostPlayerCommand(Command cmd, CommandArgs arguments, bool handled)
|
||||
{
|
||||
if (PostPlayerCommand == null)
|
||||
return;
|
||||
|
||||
PostPlayerCommandEventArgs args = new PostPlayerCommandEventArgs(cmd, arguments, handled);
|
||||
PostPlayerCommand(args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires the <see cref="PlayerPreLogin"/> event.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue