-
-
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
base: dev/feature
Are you sure you want to change the base?
Changes from 20 commits
189cf10
c6c2fda
954e54f
bb3502f
6a360c1
d9b262c
1436588
d8aa095
7febfff
1fbf996
9246dbc
6c94d5c
b6343a0
6952919
baf6468
c4725a1
e7cc66b
d7380d2
63f0610
15dd43d
42c84c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| 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 org.bukkit.entity.Entity; | ||
| import org.skriptlang.skript.registration.SyntaxRegistry; | ||
|
|
||
| @Name("Has Gravity") | ||
| @Description("Checks whether or not an entity experiences gravity.") | ||
| @Example("send whether player has gravity") | ||
| @Since("INSERT VERSION") | ||
| public class CondHasGravity extends PropertyCondition<Entity> { | ||
|
|
||
| public static void register(SyntaxRegistry registry) { | ||
| registry.register( | ||
| SyntaxRegistry.CONDITION, | ||
| infoBuilder( | ||
| CondHasGravity.class, | ||
| PropertyType.HAVE, | ||
| "gravity", | ||
| "entities" | ||
| ) | ||
|
Comment on lines
+22
to
+25
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. has gravity is ok but |
||
| .supplier(CondHasGravity::new) | ||
| .build() | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean check(Entity entity) { | ||
| return entity.hasGravity(); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getPropertyName() { | ||
| return "gravity"; | ||
| } | ||
|
|
||
| } | ||
| 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 an 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"; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| 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.SyntaxRegistry; | ||
|
|
||
| @Name("Projectile Is Critical") | ||
| @Description(""" | ||
| Check whether a projectile is in its critical state. When in critical state the projectile will have a trail of particles and deal more damage. | ||
| Currently 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, | ||
| infoBuilder( | ||
| CondProjectileIsCritical.class, | ||
| PropertyType.BE, | ||
| "in (projectile|arrow) critical (state|mode)", | ||
| "projectiles" | ||
| ) | ||
|
Comment on lines
+34
to
+37
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. this is awkward |
||
| .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. Critical projectile state only applies to arrows and tridents."); | ||
|
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. Need to include what projectile it is in the message |
||
| return false; | ||
| } | ||
|
|
||
| protected String getPropertyName() { | ||
| return "projectile critical state"; | ||
| } | ||
|
|
||
| } | ||
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.
This needs to be more forceful and informative. Apply to all deprecation warnings