From bb734cdfbccb1ecbcf66f57b9c45b3763680db97 Mon Sep 17 00:00:00 2001 From: Nathan Glover Date: Thu, 8 Mar 2018 19:12:01 -0500 Subject: [PATCH] Added Player Information --- Advanced-Scripts.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Advanced-Scripts.md diff --git a/Advanced-Scripts.md b/Advanced-Scripts.md new file mode 100644 index 0000000..fdec778 --- /dev/null +++ b/Advanced-Scripts.md @@ -0,0 +1,20 @@ +## 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. + +Here is an example that will return the player's name and their health. + +```javascript +var player = BukkitPlayer; + +function playerNameHealth() { + var name = player.getDisplayName(); + var health = player.getHealth(); + + return name + " has " + health + " health!"; +} + +playerNameHealth(); +``` + +Produces: ![example](https://i.imgur.com/GR1nqdE.png) when ran. \ No newline at end of file