-
-
Notifications
You must be signed in to change notification settings - Fork 370
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
Secspressions! #7037
Secspressions! #7037
Conversation
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.
Looks good but i'd like to see more documentation on the new classes
} | ||
|
||
@ApiStatus.Internal | ||
protected boolean canInitSafely() { |
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.
Is this used anywhere?
Sovde displayed poor judgement when merging!
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.
Looking good
src/main/java/ch/njol/skript/expressions/base/SectionExpression.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/base/SectionExpression.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Patrick Miller <[email protected]>
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.
A few final touches
src/main/java/ch/njol/skript/expressions/base/SectionExpression.java
Outdated
Show resolved
Hide resolved
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.
Should be good to go now
Description
Adds a special type of expression, the SectionExpression!
SectionExpressions are like simple expressions, but they are allowed to start a section when used in a compatible effect.
This means that a regular effect can be followed by a section iff it contains a section expression.
The expression is allowed to determine the parsing/loading of the following section.
Its only difference from a regular expression is that it may be given a (nullable)
SectionNode
andList<TriggerItem>
duringinit
as an EffectSection would.Note: this is just API, no new syntax is included in this PR.
More Info
Q: Does this change any existing syntax?
A: No.
Q: Does a section expression need to have a section?
A: No, like an EffectSection it could be used as a regular expression, but this is up to the implementation.
Q: What are the possible uses of this?
A: It's mainly offered for addons, but potentially future syntax. You can easily create 'lambda'-style things like below:
Note: these are just examples of what people might do with the API. None are included in this pull request.
Q: What happens if I use a section expression inside a line that's already a section header, like a condition/
loop
/while
? E.g.loop <my section expression>:
A: This will produce a parse-time error.
Q: What happens if I use multiple section expressions in one line? E.g.
teleport <my section expression> to <my section expression>:
A: This will produce a parse-time error.
Q: What happens if I add a colon
:
and indent code, but have no section expression/condition/regular section before it?A: This will produce a parse-time error.
Q: Is there a restriction on where I can use section expressions?
A: Technically no, as long as: A) it's not in a regular section line, B) there isn't already a section expression in the line. Obviously they look better in some lines (
set
) than others (teleport
or whatever) but there is deliberately no restriction on this so that addons can implement them how they like.Q: Is code in the section automatically run?
A: No. Everything is left up to the expression, as in an
EffectSection
. That means you can run the code when the expression is requested, run it later, never run it, or even have something that isn't code in the section. You get the rawSectionNode
duringinit
, and complete freedom how to process it.Target Minecraft Versions: any
Requirements: none
Related Issues: #6536, closes #4472