feat: add new events#565
Closed
RozyGay wants to merge 10 commits into
Closed
Conversation
## Description **Describe the changes** **What is the current behavior?** (You can also link to an open issue here) **What is the new behavior?** (if this is a feature change) **Does this PR introduce a breaking change?** (What changes might users need to make in their application due to this PR?) **Other information**: <br /> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentations <br /> ## Submission checklist <!--- Put an `x` in all the boxes that apply: --> - [ ] I have checked the project can be compiled - [ ] I have tested my changes and it worked as expected ### Patches (if there are any changes related to Harmony patches) - [ ] I have checked no IL patching errors in the console ### Other - [ ] Still requires more testing
- Introduced new event args classes: `ExecutingRemoteAdminCommandEventArgs` and `ExecutingClientCommandEventArgs` in `Exiled.Events.EventArgs.Player` to handle Remote Admin and Client command execution events. - Added `PlayerCommands` event handler class in `Exiled.Events.Handlers` to define `ExecutingRemoteAdminCommand` and `ExecutingClientCommand` events. - Implemented Harmony transpiler patches in `Exiled.Events.Patches.Events.Player`: - `ExecutingRemoteAdminCommand` patches `CommandProcessor.ProcessQuery` to trigger the event before Remote Admin command execution. - `ExecutingClientCommand` patches `QueryProcessor.ProcessGameConsoleQuery` to trigger the event before Client command execution. - Patches use pattern-matching for robust instruction insertion, allowing plugins to monitor, modify, or cancel command execution via the `IsAllowed` property. - Follows EXILED conventions for documentation, licensing, and code structure. This addition enhances plugin flexibility by providing fine-grained control over command execution in SCP:SL.
|
This is a breaking change, and you should mark it as such in the box provided for that purpose. It will break 80% of plugins. |
VALERA771
requested changes
Jun 15, 2025
VALERA771
left a comment
There was a problem hiding this comment.
- Duplicate events (executing commands). Also I didn't find such event for GameConsole handler and personally I don't think that this is neccecary to separate these events while we just can have a property that will indicate which handler is used
- Duplicate calling RoundStarted event (handler + patch)
- We already have a SendingCommand event and yours seems like duplicate of it
|
Also I forgot to mention some breaking changes. Because of them we will be able to merge your PR only on major release |
louis1706
requested changes
Jun 19, 2025
Comment on lines
+106
to
+108
| CharacterClassManager.OnRoundStarted -= () => Handlers.Server.OnRoundStarted(new RoundStartedEventArgs( | ||
| DateTime.UtcNow, | ||
| Player.List.Where(p => !p.IsNPC && !p.IsHost).Count(), |
louis1706
reviewed
Jun 19, 2025
louis1706
left a comment
There was a problem hiding this comment.
We already have this event in PlayerEventArgs
Comment on lines
+73
to
+76
| CharacterClassManager.OnRoundStarted += () => Handlers.Server.OnRoundStarted(new RoundStartedEventArgs( | ||
| DateTime.UtcNow, | ||
| Player.List.Where(p => !p.IsNPC && !p.IsHost).Count(), | ||
| !ConfigFile.ServerConfig.GetBool("end_round_on_one_player", false))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Describe the changes
This pull request enhances the
Server.RoundStartedevent by introducingRoundStartedEventArgs, replacing the parameterlessEventwith one that provides useful context. It updatesServer.csto use the new event args and adds a transpiler patch inRoundStartPatch.csforRoundSummary.Start. It also builds on earlier command-related event improvements. Changes include:RoundStartedEventArgs.csinExiled.Events/EventArgs/Serverwith properties:RoundStartTime: UTC time when the round started.PlayerCount: Number of non-NPC, non-host players (viaPlayer.List.Where(p => !p.IsNPC && !p.IsHost).Count()).KeepRoundOnOne: Inverted value ofServerConfig.GetBool("end_round_on_one_player", false).Server.csinExiled.Events/Handlersto useEvent<RoundStartedEventArgs>and updatedOnRoundStartedto acceptRoundStartedEventArgs.RoundStartPatch.csinExiled.Events/Patches/Events/Serverwith a transpiler forRoundSummary.Start, injectingOnRoundStartedbeforeKeepRoundOnOneassignment (IL_0033).Previous command-related enhancements:
ExecutingClientCommandEventArgs.csinExiled.Events/EventArgs/Serverto improve client-side command handling (e.g.,.help,.sp), providing plugins with issuer and argument details.ExecutingRemoteAdminCommandEventArgs.csinExiled.Events/EventArgs/Serverto enhance Remote Admin (RA) command handling (e.g.,kick,ban), offering richer context for RA command execution.ExecutingCommandevent inServer.csto provideExecutingCommandEventArgs, allowing plugins to intercept and modify general server commands.What is the current behavior?
Server.RoundStartedevent is a parameterlessEvent, offering no round start details, limiting plugin functionality.ExecutingCommandpreviously had basic functionality, with limited support for client-side or RA-specific commands.What is the new behavior?
Server.RoundStartedevent now providesRoundStartedEventArgs, enabling plugins to access:KeepRoundOnOneconfig value (!ServerConfig.GetBool("end_round_on_one_player", false)).The transpiler ensures the event triggers early in
RoundSummary.Start.ExecutingClientCommandEventArgsfor client commands, with issuer and argument data.ExecutingRemoteAdminCommandEventArgsfor RA commands, with detailed execution context.ExecutingCommandEventArgsfor general command handling, improving plugin flexibility.Does this PR introduce a breaking change?
No breaking changes. Existing plugins using
Server.RoundStarted,ExecutingCommand, or other command events without args remain compatible viaInvokeSafely.Other information:
end_round_on_one_playerset totrueandfalse.ban(RA) and.help(client).RoundStartedEventArgswithRoundStartTime,PlayerCount, andKeepRoundOnOne. UpdatedServer.RoundStartedwith transpiler patch.”ExecutingClientCommandEventArgsandExecutingRemoteAdminCommandEventArgsfor enhanced command handling.”Types of changes
Submission checklist
Patches (if there are any changes related to Harmony patches)
Other