-
-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New two hooks PrePlayerCommand and PostPlayerCommand #2960
base: general-devel
Are you sure you want to change the base?
Conversation
The overload executes the CommandArgs you want.
If there are already two |
You can get the command you need using Although yes, you're right. It was inappropriate to include this example in the description of my changes. |
Then how about marking the old hook (PlayerCommand) as obsolete? |
@sgkoishi Is everything correct now? |
TShockAPI/Hooks/PlayerHooks.cs
Outdated
/// <summary> | ||
/// Is the command executed. | ||
/// </summary> | ||
public bool Handled { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this class should inherit from HandledEventArgs
instead of redefining Handled
TShockAPI/Hooks/PlayerHooks.cs
Outdated
@@ -341,8 +389,29 @@ public static class PlayerHooks | |||
/// <summary> | |||
/// Fired by players when using a command. | |||
/// </summary> | |||
[Obsolete("There is an alternative to PlayerHooks.PrePlayerCommand")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The obsolete message says PlayerCommand
is an alternative, rather than use PrePlayerCommand
Co-authored-by: Arthri <[email protected]>
Co-authored-by: Arthri <[email protected]>
There is a hook
PlayerHooks.PlayerCommand
which is called before using a command. In my personal opinion, this hook is obsolete because it could be used before calling a command (cmd.Run
inHandleCommand
). This would make it easier to work with commands because you wouldn't have to look for a command that might not exist inCommands.ChatCommands
. That's why I added thePlayerHooks.PrePlayerCommand
hook.Also, the
PlayerCommand
hook does not implement the ability to handle commands after they are used, so I added thePostPlayerCommand
hook.If you would like to add "invisible" commands, which can be done with PlayerCommand, we already have a similar alternative (TSPlayer.AwaitingResponse).
Now some examples of how to use hooks: