-
-
Notifications
You must be signed in to change notification settings - Fork 386
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
isCurrentEvent API changes #4884
isCurrentEvent API changes #4884
Conversation
…ocs explain everything. Added utility method for checking instanceof with several classes
Is this still in draft? Where are the methods mentioned? Why did you add instance checking of the events? Isn't the whole point of the isCurrentEvent to setup the getting method to instantly cast, as the init/isCurrentEvent does the instanceof checking? I agree with the new methods, deprecate the old ones and default isCurrentEvent to isAnyCurrentEvent. For ExprIP the boolean fields relating to the event can be removed and just use instanceof checking in the check/get method as the fields don't pose any use at that point for multiple event syntaxes. |
Talked with pickle in DMs about the changes, changed stuff around after that but forgot to edit the PR description. PR description is now accurate again. |
I'm still confused, this isn't going to fix addons. The original API idea changes should be applied for any and all? |
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.
Just the question, but LGTM
# Conflicts: # src/main/java/ch/njol/skript/expressions/ExprEnchantmentExpCosts.java
Description
A certain pattern was found a lot throughout Skript's source code, and likely also in many addons: in a syntax element, return false if !isCurrentEvent(SomeEvent.class), and cast to SomeEvent at runtime.
However, this pattern may lead to CCEs (see for example #4872), because there may be more than 1 currentEvent at parsetime. If the syntax element can handle only one of the currentEvents, but not another, this pattern will cause a CCE if the element is called with that other event type.
This should be fixed by adding runtime checks for the provided event, which is what most file changes in this PR are.
I've also added Javadocs to the isCurrentEvent methods, explaining the situation and what to do.
Target Minecraft Versions: any
Requirements: none
Related Issues: #4872