Non-matching hook names #545
Open
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.
After reviewing the entire list of hooks (for OxideMod/Oxide.Core#103 ), I discovered that some hooks have names that do not correspond correctly to their purpose.
This pull request is intended to resolve these inconsistencies before they turn into a confusing mess. The sooner this is addressed, the fewer plugins will be affected. All new names have been verified, do not exist and will not cause conflicts.
1. Can hooks that are actually On hooks.
Can hooks(bool) essentially ask plugins whether an action is allowed or not and based on the returned true or false, the action is either performed or denied(only considering non-null values). The methods that invoke these hooks contain no additional logic beyond checking the return value. This distinguishes them from On(non-object) hooks, which also expect a bool return but serve a different purpose.
However, for some reason, certain hooks use Can instead of On, which creates confusion.
2. On hooks that are actually Can hooks.
3. Simple renaming of hooks for better understanding of their purpose.
4. Changes to ReturnBehavior.
From ExitWhenValidType to ExitWhenNonNull.
For hooks that are in void methods:
For hooks that are in bool methods, allowing the method to exit on any non-null value:
5. Other changes.
The OnItemResearch hook has been moved to the place of the CanResearchItem hook and the CanResearchItem hook has been removed, as it is essentially a regular On object hook. Having both hooks was simply duplicating the call.
The CanLockerAcceptItem hook has been removed because it is immediately followed by the CanContainerAcceptItem(OnItemFilter) hook in the ItemFilter method, which uses the same arguments.