-
-
Notifications
You must be signed in to change notification settings - Fork 477
Fixes #3655 - prevent duplicate command registration #4313
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
base: master
Are you sure you want to change the base?
Fixes #3655 - prevent duplicate command registration #4313
Conversation
I am against this PR, there are valid reasons to bind multiple functions to a single command. |
Should be configurable at the very least |
I agree that sometimes multiple functions may need to be bound to the same command, but this can be handled better by combining them inside a single handler instead of registering several handlers for the same command which is bad practice in most cases. Making this configurable per server is a good idea, and I can adjust the PR to support that. Thanks for the feedback, I’ll make improvements. |
Please make it configurable as this is trying to solve a problem that doesn't exist, imo. I used to have a chatbox resource that, if I remember correctly, made use of multiple command handlers per command. Also there are cases in which you want the same command to be handled clientside and also serverside (idk if this PR considers this). |
A warning on duplicate command handlers could be useful, I agree. |
82b5f22
to
2bd4d7e
Compare
Thank you for all the feedback ✅ Final Outcome: Configurable Duplicate Command Handler BehaviorA new server configuration option has been added: <allow_multi_command_handlers>1</allow_multi_command_handlers> This option controls how the system handles multiple Available Levels:
Default Behavior:
Any other feedback would be appreciated. |
Nice |
• Removed Hungarian notation • Switched to enum class • Marked funcs noexcept, moved to header • Used nullptr instead of NULL • Added BitStream.Can check • Minor cleanup: braces, naming • Updated config templates • throwing error when blocking duplicate command handlers instead of a warning
• Removed Hungarian notation • Switched to enum class • Marked funcs noexcept, moved to header • Used nullptr instead of NULL • Added BitStream.Can check • Minor cleanup: braces, naming • Updated config templates • throwing error when blocking duplicate command handlers instead of a warning
…CodeX/mtasa-blue into commandhandler-controlling
Fixes #3655
⚠️ Heads up: any existing resources with duplicate commands will now fail to register them so devs may need to audit and rename conflicting ones.

This PR makes addCommandHandler reject any duplicate command names whether they're in the same resource or across different ones. So if a command like "test" is already registered in one resource, trying to register it again (even in the same resource) will fail with a warning in debugscript 3. For example, if Resource A registers "kick", Resource B (or even A again) won’t be able to override it. It's a solid security improvement that ensures predictable command behavior and prevents hijacking or conflicts with minimal changes.