Changeable Conditions#8707
Conversation
This comment has been minimized.
This comment has been minimized.
|
So just to verify... Feels messy. Feels redundant. 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. |
| * @param value The new value. | ||
| * This is always false for {@link ChangeMode#DELETE} and {@link ChangeMode#RESET}. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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"); |
| // TODO - remove this when Spigot support is dropped | ||
| private static final boolean CAN_USE_ENTITIES = Skript.methodExists(Mob.class, "isLeftHanded"); |
| @Since("2.11") | ||
| public class CondIsScreaming extends PropertyCondition<LivingEntity> { | ||
|
|
||
| private static final boolean SUPPORTS_ENDERMAN = Skript.methodExists(Enderman.class, "isScreaming"); |
| @Since("1.3.4") | ||
| public class CondPvP extends Condition { | ||
|
|
||
| private static final boolean PVP_GAME_RULE_EXISTS = Skript.fieldExists(GameRule.class, "PVP"); |
| @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%\"") |
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:
toggle the player's gliding stateset 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
SETorRESETare 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 glidingset 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