JavaScript Condition
The JavaScript condition allows you to create complex conditions using JavaScript expressions. This provides maximum flexibility for creating advanced placeholder logic.Overview
With JavaScript conditions, you can create placeholders that evaluate complex expressions, check multiple conditions, and perform calculations.Available Variables
You have access to two variables in your JavaScript expressions:How It Works
Your JavaScript expression must return a boolean value (true or false). If the expression evaluates to true, the condition matches and the placeholder text is displayed.
Configuration
To create a JavaScript condition, set the type toJAVASCRIPT and provide a JavaScript expression as the value.
Basic Example
- If the expression returns
true(player has permission), show: “Example condition text” - If the expression returns
false, show: “Default”
Real-World Examples
Permission Check
Multiple Conditions
World Check
Health Check
Game Mode Check
Complex Logic
Using JavaScript in Placeholder Text
You can also use JavaScript expressions directly in placeholder text (without conditions):When using
parsejs: true, the JavaScript expression is evaluated and the result is displayed as the placeholder text.JavaScript Expression Tips
-
Return boolean values - Conditions must return
trueorfalse - Use proper syntax - Follow JavaScript syntax rules
-
Access Player methods - Use
Player.methodName()to access player methods -
Access Server methods - Use
Server.methodName()to access server methods -
String comparisons - Use
===for strict equality checks -
Logical operators - Use
&&(AND),||(OR),!(NOT)
Common Player Methods
Here are some commonly used Player methods:Player.hasPermission(String permission)- Check permissionPlayer.getLevel()- Get player levelPlayer.getHealth()- Get current healthPlayer.getMaxHealth()- Get max healthPlayer.getWorld()- Get player’s worldPlayer.getGameMode()- Get game modePlayer.getName()- Get player name
Troubleshooting
Q: The condition isn’t workingA: Make sure:
- JShader is installed and enabled
- RocketPlaceholders version is 1.9.1 or higher
- Your JavaScript syntax is correct
- The expression returns a boolean value
A: Check:
- JavaScript syntax is valid
- Method names are correct (case-sensitive)
- Variables are properly referenced
Related Guides
- Conditions Overview - Learn about all condition types
- Custom Placeholders - Basic placeholder creation