Custom Abilities: Conditions - BoBoBalloon/InnovativeItemsDOCS GitHub Wiki

Intro

When using abilities there may be cases where you do not want your ability to trigger. For example, you want to make an ability that heals a target and fires a particle effect, but you only want to heal them if they are below a certain amount of health, this is where conditions come in. Conditions allow you to check a value that can be true or false, if the value is true, the ability will trigger, if the value is false, the ability will not trigger.

Example

An example of ability with a condition named test without any arguments is provided below:

test-ability:
  trigger: 'right-click'
  conditions:
    - 'test()'
  keywords:
    - 'message(?player, You passed the condition!)'

Conditions are structured the same way as keywords, meaning if you enter an invalid value, the console will inform you of this mistake when the plugin is first loaded or reloaded and the condition will fail to load (this also includes the escape character and the like). The ability above named test-ability will only fire when the player right-clicks a block or air. And it will test the condition by the name of test, if test comes back with a value of true, it will send a message to the player who right-clicked "You passed the condition!". If test came back with a value of false, no message would be sent.

The Not Operator (!)

In some programming languages, the not operator can be used to invert a value that is true or false (data type is known as a boolean or bool). This is also true with conditions. To use the not operator, place an exclamation point character before the name of the condition. In doing so, the opposite value will be expected. If we were to use the not operator with the same example in the example section above, it would look like this:

test-ability:
  trigger: 'right-click'
  conditions:
    - '!test()'
  keywords:
    - 'message(?player, You passed the condition!)'

This one little exclamation point drastically changes the meaning of the condition. Now it will test the condition by the name of test, if test comes back with a value of true, no message will be sent. If test came back with a value of false, it will send a message to the player who right-clicked "You passed the condition!". Meaning it inverts the true or false, so if the test came back as true, it would become false, but if it came back as false, it would become true.

List of Native Conditions

Below will be a list of all built-in conditions that you may reference while writing new abilities.

If a condition can take more than one targeter inside of an argument, they will be separated by "|".

(Remember, this is an incomplete list, and conditions can be removed and added at any time)

Condition Description Arguments Example
isclearweather Will check if the weather is sunny (not raining or snowing) nothing - 'isclearweather()'
isinbiome Will check if the target is in the specified biome ?player|?entity|?block {biome} - 'isinbiome(?player, PLAINS)'
ishealthat Will check if the target has a certain amount of health ?player|?entity {amount} {=,>,<} - 'ishealthat(?player, 5, >)'
istime Will check if the time of day matches the provided time of day {MORNING,NOON,NIGHT} - 'istime(NIGHT)'
ispermissionpresent Will check if the target has the specified permission ?player|?entity {permission} - 'ispermissionpresent(?player, test.permission)'
isgamemode Will check if the target is on the specified gamemode ?player|?entity {gamemode} - 'isgamemode(?player, SURVIVAL)'
isplayer Will check if target is a player ?entity - 'isplayer(?entity)'
issneaking Will check if target is sneaking/crouching ?player|?entity - 'issneaking(?player)'
isblocking Will check if target is blocking with a shield ?player|?entity - 'isblocking(?player)'
isgliding Will check if target is gliding with an elytra ?player|?entity - 'isgliding(?player)'
isentitytype Will check if target is the provided entity type ?player|?entity {entity type} - 'isentitytype(?player, PLAYER)'
isblock Will check if block at the given location is the specified type ?player|?entity|?block {x offset} {y offset} {z offset} {material} - 'isblock(?block, 0, 0, 0, DIRT)'
isblockat Will check if block at the given location is the specified type {x} {y} {z} {world name} {material} - 'isblockat(100, 100, 100, world, DIRT)'
isfacing Will check if the provided entity is looking in the provided direction ?player|?entity {any cardinal direction} - 'isfacing(?player, NORTHEAST)'
isfalling Will check if the provided entity is falling in the air ?player|?entity - 'isfalling(?player)'
isinworld Will check if the player is in the given world {internal world name} - 'isinworld(world_the_end)'
isusingitem Will check if the player is using the provided vanilla item ?player|?entity {material} {amount} {HAND,OFF_HAND,HEAD,CHEST,LEGS,FEET,ANY} - 'isusingitem(?player, DIAMOND_SWORD, 1, HAND)'
isusingcustomitem Will check if the player is using the provided custom item ?player|?entity {item name} {amount} {HAND,OFF_HAND,HEAD,CHEST,LEGS,FEET,ANY} - 'isusingcustomitem(?player, blood-blade, 1, HAND)'
isexperienceat Will check if the player has a certain amount of experience ?player|?entity {amount} {=,>,<} - 'isexperienceat(?player, 1000, =)'
ishealthpercentat Will check if the player has a certain percent of health ?player|?entity {percent} {=,>,<} - 'ishealthpercentat(?player, 100, =)'
haspotioneffect Will check if the entity has the potion effect ?player|?entity {effect type} {level requirement} {=,>,<} - 'haspotioneffect(?player, 0, >)'
isburning Will check if the target is on fire ?player|?entity - 'isburning(?player)'
iscoordinate Will check if the specified coordinate is at the expected amount ?player|?entity {x,y,z} {=,>,<} {value} - 'iscoordinate(?player, y, >, 100)'
hascoreboardtag Will check if the specified entity has a persistent scoreboard tag of the tag provided ?player|?entity {tag name} - 'hascoreboardtag(?player, has_eaten_apple)'
chance A condition that will allow the ability to execute a specific percent of the time {number between 1-99 that represents the percent chance of the condition being true} - 'chance(50)'
haslineofsight A condition that checks if the player can see the targeted entity ?entity {max distance from player in blocks} - 'haslineofsight(?entity, 30)'
islooking Will check if the provided entity is looking ?player|?entity {UP,DOWN} - 'islooking(?player, UP)'

List of Native Dependent Conditions

Below is a separate list of conditions that depend on a specific plugin

Condition Depend Description Arguments Example
isinregion WorldGuard Will check if the provided location is inside a WorldGuard region ?player|?entity|?block {world name} {region name} - 'isinregion(?player, world, spawn)'