You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 1, 2025. It is now read-only.
Do things you would want to do before or after every command execute.
For example: Logging
Example
The check in BeforeCommandExecute in this example is not a good way to check for a requirement.
Better use Requirement checkers instead.
usingCustomCommandsSystem.Integration;publicvoidAddEvents(){Events.BeforeCommandExecute+=BeforeCommandExecute;Events.AfterCommandExecute+=AfterCommandExecute;}privatevoidBeforeCommandExecute(IPlayerplayer,UserInputDatauserInputData,object?[]args,CancelEventArgscancelEventArgs){// If we have only one kick method with one parameter and BeforeCommandExecute is triggered// the entry in args will be valid and must exist. So there has to be a player entry in args[0]if(userInputData.Command=="kick"&&args[0]isIPlayer{Name:"Bonus"}){player.SendChatMessage("You can't kick Bonus!!");cancelEventArgs.Cancel=true;return;}Console.WriteLine($"{player.Name} is executing command");}privatevoidAfterCommandExecute(IPlayerplayer,UserInputDatauserInputData,object?[]args){Console.WriteLine($"{player.Name} executed command {userInputData.Command}. The text the player wrote: \"{userInputData.Message}\"");}