Conditionals
Using conditionals in the GPT Assistant Minecraft plugin can drastically improve the functionality of your server by creating intuitive responses to players' queries.
1. The Equality Operator "==":
The "==" operator checks if two values are equal.
Example:
(%vault_eco_balance% == 0) ? 'You have no money' : 'You have money'
2. The Identity/Strict Equality Operator "===":
The "===" operator checks if two values are equal AND if they are of the same type.
Example:
('%luckperms_primary_group_name%' === 'vip') ? 'You are a VIP' : 'You are not a VIP'
3. The Greater Than Operator ">":
It checks if a value is greater than the other value.
Example:
(%player_ping% > 250) ? 'High ping' : 'Low ping'
4. The Less Than Operator "<":
It checks if a value is less than the other value.
Example:
(%vault_eco_balance% < 50) ? 'Not enough money' : 'Enough money'
5. The Greater Than or Equal To Operator ">=":
It checks if a value is greater than or equal to the other value.
Example:
(%vault_eco_balance% >= 50) ? 'Enough money' : 'Not enough money'
6. The Less Than or Equal To Operator "<=":
It checks if a value is less than or equal to the other value.
Example:
(%player_ping% <= 60) ? 'Low ping' : 'High ping'
7. The Not Equal Operator "!=":
It checks if two values are not equal.
Example:
('%luckperms_primary_group_name%' != 'guest') ? 'You are not a guest' : 'You are a guest'
8. The Logical And Operator "&&":
It is used to test more than one condition.
Example:
('%luckperms_primary_group_name%' === 'vip' && %player_exp_to_level% >= 30) ? 'Can use VIP enchant' : 'Cannot use VIP enchant'
9. The Logical Or Operator "||":
It is used to test at least one condition.
Example:
('%luckperms_primary_group_name%' === 'vip' || %vault_eco_balance% >= 50) ? 'Can buy or fly' : 'Don\'t have vip or enough money'
10. Using Single Quotes "'":
If you want to specify a string or text, you should put it inside single quotes ''.
Example:
'You are VIP'
But if you need to use a single quote inside a string, you should escape it using a backslash.
Example:
'Aida\'s Bar'
11. Using Double Quotes "":
Same as single quotes, they are used to indicate a string or text, but can cause problems when used within YML files. Stick with single quotes.
12. Plus Operator "+":
You can use the "+" operator to add/caoncatenate things.
Example of concatenation:
'%luckperms_primary_group_name%' + ' is your group'
Hopefully, this guide helps you understand how to use and create conditional statements. Feel free to test out different combinations and build upon this knowledge!
Last updated