From 38c995b27f0f081e51fa23b6ce92003c7fc38a91 Mon Sep 17 00:00:00 2001 From: cj89898 Date: Sat, 2 May 2020 07:29:14 -0500 Subject: [PATCH] Added spoilers, fixed some scripts --- Community-Scripts.md | 71 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/Community-Scripts.md b/Community-Scripts.md index a367391..611fcb6 100644 --- a/Community-Scripts.md +++ b/Community-Scripts.md @@ -20,7 +20,10 @@ The JavaScript Expansion for PlaceholderAPI allows for expansions that wouldn't * **Usage:** `%javascript_randomintbetween_,%` * **Example:** `%javascript_randomintbetween_10,20%` - Produces a random integer between 10 and 20. -**Save as** `random_integer_between.js` +**Javascript Code** + +
+ random_integer_between.js ```javascript var min = 1; @@ -40,6 +43,7 @@ function randomInteger() { randomInteger(); ``` +
**Add to** `javascript_placeholders.yml` @@ -63,8 +67,8 @@ randomintbetween: You will need to insert the `set`, `add`, or `subtract` placeholder in the plugin function where you want to track the data. A quick example of functionality for this placeholder would be a "1 time use" item in a GUI plugin that supports PlaceholderAPI. -**Example of usage with DeluxeMenus** - +
+ Example of usage with DeluxeMenus ```yaml menu_title: 'One time use menu' open_command: onetimeuse @@ -92,8 +96,12 @@ items: - '[console] give %player_name% diamond 1 %javascript_data_set,{player_uuid}.has_used,true%' - '[close]' ``` +
-**Save as** `data.js` +**Javascript Code** + +
+ data.js ```javascript function set(path, data) { @@ -185,6 +193,7 @@ function runPlaceholder() { } runPlaceholder(); ``` +
**Add to** `javascript_placeholders.yml` @@ -203,7 +212,10 @@ data: **NOTE:** this method works if you haven't changed the true boolean option in PlaceholderAPI config ('true': 'yes') if you changed it and don't want to use the default one change "yes" in `(haspermission === "yes")` to the option you set for `true` in the PlaceholderAPI config. -**Save as** `haspermission.js` +**Javascript Code** + +
+ haspermission.js ```javascript // create a variable and name it wantever you want like this @@ -227,6 +239,7 @@ function permission() { // by this we are calling the function to run permission(); ``` +
**Add to** `javascript_placeholders.yml` @@ -247,7 +260,10 @@ haspermission: **NOTE:** If you need help in adding/removing values OR got some issues with it, feel free to ask me or anyone else in the [HelpChat Discord](https://helpch.at/discord). -**Save as** `animated_text.js` +**Javascript Code** + +
+ animated_text.js ```javascript var messages = ["This is", "This is a", "This is a test message"]; @@ -263,7 +279,7 @@ function getMessage(ID) { var msgnumber = Data.exists(numdata) ? Data.get(numdata) : 0; msgnumber++; - if (msgnumber >= 3) { + if (msgnumber >= messages.length) { msgnumber = 0; } @@ -273,6 +289,7 @@ function getMessage(ID) { } getMessage(IDv); ``` +
**Add to** `javascript_placeholders.yml` @@ -334,7 +351,10 @@ maxhealth: * **Description:** Return the display name of the item you're holding in your hand. * **Usage:** `%javascript_displayname%` -**Save as** `displayname.js` +**Javascript Code** + +
+ displayname.js ```javascript var player = BukkitPlayer; @@ -359,6 +379,7 @@ function displayname() { } displayname(); ``` +
**Add to** `javascript_placeholders.yml` @@ -415,7 +436,10 @@ lorelines: * **Usage:** `%javascript_lore% OR %javascript_lore_%` * **Example:** `%javascript_lore%` to return all lore lines, `%javascript_lore_1%` to return lore line number 1 -**Save as** `lore.js` +**Javascript Code** + +
+ lore.js ```javascript var player = BukkitPlayer; @@ -462,6 +486,7 @@ function itemlore() { } itemlore(); ``` +
**Add to** `javascript_placeholders.yml` @@ -493,7 +518,10 @@ lore: **Note:** If you didn't set the data and the amount it will be by default data = 0 and amount = 1. You can add as much lore lines as you want just add `|` between each line as seen in the example above. -**Save as** `item.js` +**Javascript Code** + +
+ item.js ```javascript var vbukkit = org.bukkit.Bukkit; @@ -617,6 +645,7 @@ function run() { run(); ``` +
**Add to** `javascript_placeholders.yml` @@ -681,7 +710,8 @@ difference_dates: * `%javascript_cooldown_name_start%` * `%javascript_cooldown_name_reset%` -**Example of using with DeluxeMenus** +
+ Example of using with DeluxeMenus ```yaml menu_title: '&aExample GUI menu' @@ -865,8 +895,12 @@ items: - '[message] Do whatever u want' - '[refresh]' ``` +
-**Save as** `cooldown.js` +**Javascript Code** + +
+ cooldown.js ```javascript var monthSymbol = "mo"; @@ -949,6 +983,7 @@ function run() { } run(); ``` +
**Add to** `javascript_placeholders.yml` @@ -1035,10 +1070,18 @@ healthbar: ```javascript function numInGroupOfWorlds() { var num = 0; + for (var i = 0; i < args.length; i++) { - num += BukkitServer.getWorld(args[i]).getPlayers().length; - if (i + 1 == args.length) return num.toFixed(0); + var world = BukkitServer.getWorld(args[i]); + + if (world == null) { + continue; + } + + num += world.getPlayers().length; } + + return num.toFixed(0); } numInGroupOfWorlds();