-
-
Notifications
You must be signed in to change notification settings - Fork 446
Deprecate boolean expressions #8619
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
Open
Phill310
wants to merge
21
commits into
SkriptLang:dev/feature
Choose a base branch
from
Phill310:deprecate-boolean-expressions
base: dev/feature
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
189cf10
Create AI effect and mark AI expression as deprecated
Phill310 c6c2fda
Create glowing effect and condition. Mark glow expression as deprecated
Phill310 954e54f
Create gravity effect. Mark gravity expression as deprecated
Phill310 bb3502f
Create projectile critical state effect and condition. Mark projectil…
Phill310 6a360c1
Register new syntax
Phill310 d9b262c
Add runtime warning when effect is used on a non-compatible projectile
Phill310 1436588
Use entity instead of living entity everywhere
Phill310 d8aa095
Allow deprecation warning to be suppressed
Phill310 7febfff
Improve syntax
Phill310 1fbf996
Merge branch 'dev/feature' into deprecate-boolean-expressions
Phill310 9246dbc
Use the infoBuilder and allow for multiple projectiles
Phill310 6c94d5c
Allow all entities to glow instead of just living entities
Phill310 b6343a0
Add condition for gravity
Phill310 6952919
Add tests
Phill310 baf6468
Merge remote-tracking branch 'upstream/dev/feature' into deprecate-bo…
Phill310 c4725a1
Merge remote-tracking branch 'origin/deprecate-boolean-expressions' i…
Phill310 e7cc66b
Update src/main/java/org/skriptlang/skript/bukkit/entity/elements/eff…
Phill310 d7380d2
Improve description
Phill310 63f0610
Merge remote-tracking branch 'origin/deprecate-boolean-expressions' i…
Phill310 15dd43d
Deprecate Flight Mode expression
Phill310 42c84c6
Apply suggestions from code review
Phill310 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
45 changes: 45 additions & 0 deletions
45
src/main/java/org/skriptlang/skript/bukkit/entity/elements/conditions/CondIsGlowing.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package org.skriptlang.skript.bukkit.entity.elements.conditions; | ||
|
|
||
| import ch.njol.skript.conditions.base.PropertyCondition; | ||
| import ch.njol.skript.doc.*; | ||
| import org.bukkit.entity.Entity; | ||
| import org.skriptlang.skript.registration.SyntaxRegistry; | ||
|
|
||
| @Name("Is Glowing") | ||
| @Description("Checks whether or not a living entity is glowing.") | ||
| @Example(""" | ||
| command /glow: | ||
| trigger: | ||
| if player is glowing: | ||
| make player stop glowing | ||
| else: | ||
| make player glow | ||
| """) | ||
| @Since("INSERT VERSION") | ||
| public class CondIsGlowing extends PropertyCondition<Entity> { | ||
|
|
||
| public static void register(SyntaxRegistry registry) { | ||
| registry.register( | ||
| SyntaxRegistry.CONDITION, | ||
| infoBuilder( | ||
| CondIsGlowing.class, | ||
| PropertyType.BE, | ||
| "glowing", | ||
| "entities" | ||
| ) | ||
| .supplier(CondIsGlowing::new) | ||
| .build() | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean check(Entity entity) { | ||
| return entity.isGlowing(); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getPropertyName() { | ||
| return "glowing"; | ||
| } | ||
|
|
||
| } |
58 changes: 58 additions & 0 deletions
58
...ava/org/skriptlang/skript/bukkit/entity/elements/conditions/CondProjectileIsCritical.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package org.skriptlang.skript.bukkit.entity.elements.conditions; | ||
|
|
||
| import ch.njol.skript.conditions.base.PropertyCondition; | ||
| import ch.njol.skript.doc.Description; | ||
| import ch.njol.skript.doc.Example; | ||
| import ch.njol.skript.doc.Name; | ||
| import ch.njol.skript.doc.Since; | ||
| import ch.njol.skript.lang.Expression; | ||
| import ch.njol.skript.lang.SkriptParser; | ||
| import ch.njol.util.Kleenean; | ||
| import org.bukkit.entity.AbstractArrow; | ||
| import org.bukkit.entity.Projectile; | ||
| import org.skriptlang.skript.log.runtime.RuntimeErrorProducer; | ||
| import org.skriptlang.skript.registration.SyntaxInfo; | ||
| import org.skriptlang.skript.registration.SyntaxRegistry; | ||
|
|
||
| @Name("Projectile Is Critical") | ||
| @Description("Checks whether or not a projectile is in critical state. As of now this only applies to arrows and tridents.") | ||
| @Example(""" | ||
| on shoot: | ||
| if event-projectile is not in projectile critical state: | ||
| enable projectile critical state of event-projectile | ||
| """) | ||
| @Since("INSERT VERSION") | ||
| public class CondProjectileIsCritical extends PropertyCondition<Projectile> implements RuntimeErrorProducer { | ||
|
|
||
| public static void register(SyntaxRegistry registry) { | ||
| registry.register( | ||
| SyntaxRegistry.CONDITION, | ||
| SyntaxInfo.builder(CondProjectileIsCritical.class) | ||
| .addPatterns( | ||
| "%projectile% is in (projectile|arrow) critical (state|mode)", | ||
| "%projectile% (is not|isn't) in (projectile|arrow) critical (state|mode)") | ||
|
Phill310 marked this conversation as resolved.
Outdated
|
||
| .supplier(CondProjectileIsCritical::new) | ||
| .build() | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { | ||
| setNegated(matchedPattern == 1); | ||
| return super.init(exprs, matchedPattern, isDelayed, parseResult); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean check(Projectile projectile) { | ||
| if (projectile instanceof AbstractArrow abstractArrow) { | ||
| return abstractArrow.isCritical(); | ||
| } | ||
| warning("This projectile is not supported. This only applies to arrows and tridents."); | ||
| return false; | ||
| } | ||
|
|
||
| protected String getPropertyName() { | ||
| return "projectile critical state"; | ||
| } | ||
|
|
||
| } | ||
65 changes: 65 additions & 0 deletions
65
src/main/java/org/skriptlang/skript/bukkit/entity/elements/effects/EffAI.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package org.skriptlang.skript.bukkit.entity.elements.effects; | ||
|
|
||
| import ch.njol.skript.doc.Description; | ||
| import ch.njol.skript.doc.Example; | ||
| import ch.njol.skript.doc.Name; | ||
| import ch.njol.skript.doc.Since; | ||
| import ch.njol.skript.lang.Effect; | ||
| import ch.njol.skript.lang.Expression; | ||
| import ch.njol.skript.lang.SkriptParser; | ||
| import ch.njol.skript.lang.SyntaxStringBuilder; | ||
| import ch.njol.util.Kleenean; | ||
| import org.bukkit.entity.LivingEntity; | ||
| import org.bukkit.event.Event; | ||
| import org.jetbrains.annotations.Nullable; | ||
| import org.skriptlang.skript.registration.SyntaxInfo; | ||
| import org.skriptlang.skript.registration.SyntaxRegistry; | ||
|
|
||
| @Name("Entity AI") | ||
| @Description("Change whether an entity has AI.") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more description. what does it mean to have or not have ai? |
||
| @Example("enable artificial intelligence of target entity") | ||
| @Example("disable ai of last spawned entity") | ||
| @Since("INSERT VERSION") | ||
| public class EffAI extends Effect { | ||
|
|
||
| public static void register(SyntaxRegistry registry) { | ||
| registry.register( | ||
| SyntaxRegistry.EFFECT, | ||
| SyntaxInfo.builder(EffAI.class) | ||
| .addPatterns( | ||
| "(enable|:disable) (ai|artificial intelligence) of %livingentities%", | ||
|
Phill310 marked this conversation as resolved.
Outdated
|
||
| "(enable|:disable) %livingentities%'s (ai|artificial intelligence)" | ||
| ) | ||
| .supplier(EffAI::new) | ||
| .build() | ||
| ); | ||
| } | ||
|
|
||
| private Expression<LivingEntity> entities; | ||
| private boolean negated; | ||
|
|
||
| @Override | ||
| public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { | ||
| //noinspection unchecked | ||
| entities = (Expression<LivingEntity>) expressions[0]; | ||
| negated = parseResult.hasTag("disable"); | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected void execute(Event event) { | ||
| for (LivingEntity entity : entities.getArray(event)) { | ||
| entity.setAI(!negated); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String toString(@Nullable Event event, boolean debug) { | ||
| return new SyntaxStringBuilder(event, debug) | ||
| .appendIf(!negated, "enable") | ||
| .appendIf(negated, "disable") | ||
|
Phill310 marked this conversation as resolved.
Outdated
|
||
| .append("ai of", entities) | ||
| .toString(); | ||
| } | ||
|
|
||
| } | ||
65 changes: 65 additions & 0 deletions
65
src/main/java/org/skriptlang/skript/bukkit/entity/elements/effects/EffGlowing.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package org.skriptlang.skript.bukkit.entity.elements.effects; | ||
|
|
||
| import ch.njol.skript.doc.Description; | ||
| import ch.njol.skript.doc.Example; | ||
| import ch.njol.skript.doc.Name; | ||
| import ch.njol.skript.doc.Since; | ||
| import ch.njol.skript.lang.Effect; | ||
| import ch.njol.skript.lang.Expression; | ||
| import ch.njol.skript.lang.SkriptParser; | ||
| import ch.njol.skript.lang.SyntaxStringBuilder; | ||
| import ch.njol.util.Kleenean; | ||
| import org.bukkit.entity.LivingEntity; | ||
| import org.bukkit.event.Event; | ||
| import org.jetbrains.annotations.Nullable; | ||
| import org.skriptlang.skript.registration.SyntaxInfo; | ||
| import org.skriptlang.skript.registration.SyntaxRegistry; | ||
|
|
||
| @Name("Entity Glow") | ||
| @Description("Change whether an entity is glowing.") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more description |
||
| @Example("make target entity glow") | ||
| @Example("make player stop glowing") | ||
| @Since("INSERT VERSION") | ||
| public class EffGlowing extends Effect { | ||
|
|
||
| public static void register(SyntaxRegistry registry) { | ||
| registry.register( | ||
| SyntaxRegistry.EFFECT, | ||
| SyntaxInfo.builder(EffGlowing.class) | ||
| .addPatterns( | ||
| "make %entities% [negate:not] glow", | ||
| "make %entities% (negate:stop|start) glowing" | ||
|
Phill310 marked this conversation as resolved.
Outdated
|
||
| ) | ||
| .supplier(EffGlowing::new) | ||
| .build() | ||
| ); | ||
| } | ||
|
|
||
| private Expression<LivingEntity> entities; | ||
| private boolean negated; | ||
|
|
||
| @Override | ||
| public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { | ||
| //noinspection unchecked | ||
| entities = (Expression<LivingEntity>) expressions[0]; | ||
| negated = parseResult.hasTag("negate"); | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected void execute(Event event) { | ||
| for (LivingEntity entity : entities.getArray(event)) { | ||
| entity.setGlowing(!negated); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String toString(@Nullable Event event, boolean debug) { | ||
| return new SyntaxStringBuilder(event, debug) | ||
| .append("make", entities) | ||
| .appendIf(negated, "not") | ||
| .append("glow") | ||
| .toString(); | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.