From b532a52f03061470b6c117405e585aff437597ff Mon Sep 17 00:00:00 2001 From: BlitzGamer-88 <52609756+BlitzGamer-88@users.noreply.github.com> Date: Tue, 11 Aug 2020 14:20:44 +0300 Subject: [PATCH] Updated Advanced Scripts (markdown) --- Advanced-Scripts.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Advanced-Scripts.md b/Advanced-Scripts.md index 817fcab..2446e03 100644 --- a/Advanced-Scripts.md +++ b/Advanced-Scripts.md @@ -36,6 +36,26 @@ Placeholders could also be used as arguments. Instead of using %placeholder% you Example (assuming the identifier is called _check_): - `%javascript_check_{vault_rank}%` would check if the player has the a specific rank and would return something based on their rank. +`PlaceholderAPI.static.setPlaceholders()` could also be used to parse placeholders inside the javascript placeholder. + +Example: +```javascript +kitName = args[0]; +placeholder = "essentials_has_kit_" + kitname; +hasKit = PlaceholderAPI.static.setPlaceholders(BukkitPlayer, "%" + placeholder + "%"); + +function hasKit(){ + if(hasKit == "yes"){ + return "&aTrue"; + } + return "&cFalse"; +} + +hasKit(); +``` + +This example will take a kit name as an argument and check if the player has access to that kit and return True or False based on the input. It also parses the placeholder(essentials_has_kit_kitname) for the BukkitPlayer which is the player that the javascript placeholder is parsed for. + ## Player Information When a placeholder script is called, the player that is passed to the Javascript-Expansion is also passed to the placeholder script. This player can be accessed with `BukkitPlayer`. After receiving, you can access all of the [player methods](https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html) included in the Spigot API.