Skip to content

Changeable Conditions#8707

Open
APickledWalrus wants to merge 6 commits into
dev/featurefrom
feature/changeable-conditions
Open

Changeable Conditions#8707
APickledWalrus wants to merge 6 commits into
dev/featurefrom
feature/changeable-conditions

Conversation

@APickledWalrus

Copy link
Copy Markdown
Member

Problem

For some time, we have been recommending a combination of Condition+Effect in favor of a boolean Expression. However, there is some loss of ease of use:

  • Losing support for EffToggle: toggle the player's gliding state
  • Losing support for one-line changing: set the player's gliding state to {_boolean}

If Conditions were to support changing, these features could be restored in some manner, preserving the ease of use options provided by boolean Expressions.

Solution

This PR proposes a simple API for changing the values represented by conditions. This API is further extended by PropertyCondition to make implementing even easier.

I decided to allow any changer to be used, though some modes are likely pointless. We could instead have specific methods for whether SET or RESET are allowed (as an example as those are probably the only realistic modes to support). I'd like opinions to tweak this.

This API is then used by ExprWhether to allow changing conditions:

  • toggle whether player is gliding
  • set whether the player is gliding to {_boolean}

There is a large number of files changed as I implemented this for most conditions where it made sense.

Testing Completed

Some in-game testing. I added at least 40 new tests covering many of the updated conditions.

Supporting Information

n/a


Completes: none
Related: none
AI assistance: none

@APickledWalrus APickledWalrus requested review from a team as code owners June 16, 2026 21:22
@APickledWalrus APickledWalrus requested review from UnderscoreTud and erenkarakal and removed request for a team June 16, 2026 21:22
@skriptlang-automation skriptlang-automation Bot added needs reviews A PR that needs additional reviews needs triage An issue that hasn't been classified or verified yet labels Jun 16, 2026
@skriptlang-automation

This comment has been minimized.

@skriptlang-automation skriptlang-automation Bot added feature Pull request adding a new feature. and removed needs triage An issue that hasn't been classified or verified yet labels Jun 16, 2026
@APickledWalrus APickledWalrus requested a review from sovdeeth June 16, 2026 21:23
@skriptlang-automation skriptlang-automation Bot moved this to In Review in 2.16 Releases Jun 16, 2026
@ShaneBeee

Copy link
Copy Markdown
Contributor

So just to verify...
You guys didn't like expressions for booleans, so you double'd up the code by adding conditions and effects.
Then added a whether expression, to use the conditions as expressions.
And now adding a changer to the whether expression, to bring back to the original expressions y'all didn't like?

Feels messy. Feels redundant.
Is SkriptLang doing what's best for its users or what's best for the team?
I feel like it's the latter.

With all due respect, I think you guys need to have a team meeting, chill, step back... and starting thinking more about your users and less about yourselves.

@sovdeeth sovdeeth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good

Comment on lines +194 to +195
* @param value The new value.
* This is always false for {@link ChangeMode#DELETE} and {@link ChangeMode#RESET}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe call newValue or deltaValue

* @param what The property holder.
* @param value The new value.
* This is always false for {@link ChangeMode#DELETE} and {@link ChangeMode#RESET}.
* @param mode The type of change to perform.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably contract that add/remove/removall shouldn't be used

@Since("2.11")
public class CondIsEating extends PropertyCondition<LivingEntity> {

private static final boolean SUPPORTS_HORSES = Skript.methodExists(AbstractHorse.class, "isEating");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is in 1.21.4 so can be removed

@Since("2.5, 2.10 (gamemode)")
public class CondIsInvulnerable extends PropertyCondition<Object> {

private static final boolean SUPPORTS_GAMEMODE = Skript.methodExists(GameMode.class, "isInvulnerable");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in 1.21.4

Comment on lines 30 to 31
// TODO - remove this when Spigot support is dropped
private static final boolean CAN_USE_ENTITIES = Skript.methodExists(Mob.class, "isLeftHanded");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in 1.21.4

@Since("2.11")
public class CondIsScreaming extends PropertyCondition<LivingEntity> {

private static final boolean SUPPORTS_ENDERMAN = Skript.methodExists(Enderman.class, "isScreaming");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in 1.21.4

@Since("1.3.4")
public class CondPvP extends Condition {

private static final boolean PVP_GAME_RULE_EXISTS = Skript.fieldExists(GameRule.class, "PVP");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added 1.21.9

Comment on lines +19 to +24
@Description("""
A shorthand for returning the result of a condition (true or false).
This is functionally identical to using 'true if <condition> else false'.
""")
@Example("set {fly} to whether player can fly")
@Example("broadcast \"Flying: %whether player is flying%\"")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain setting + example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Pull request adding a new feature. needs reviews A PR that needs additional reviews

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

3 participants