mirror of
https://github.com/PlaceholderAPI/Javascript-Expansion.git
synced 2025-05-24 20:02:44 +00:00
Added spoilers, fixed some scripts
parent
1194eae7f1
commit
38c995b27f
@ -20,7 +20,10 @@ The JavaScript Expansion for PlaceholderAPI allows for expansions that wouldn't
|
|||||||
* **Usage:** `%javascript_randomintbetween_<min>,<max>%`
|
* **Usage:** `%javascript_randomintbetween_<min>,<max>%`
|
||||||
* **Example:** `%javascript_randomintbetween_10,20%` - Produces a random integer between 10 and 20.
|
* **Example:** `%javascript_randomintbetween_10,20%` - Produces a random integer between 10 and 20.
|
||||||
|
|
||||||
**Save as** `random_integer_between.js`
|
**Javascript Code**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>random_integer_between.js</summary>
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var min = 1;
|
var min = 1;
|
||||||
@ -40,6 +43,7 @@ function randomInteger() {
|
|||||||
|
|
||||||
randomInteger();
|
randomInteger();
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
**Add to** `javascript_placeholders.yml`
|
**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.
|
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**
|
<details>
|
||||||
|
<summary>Example of usage with DeluxeMenus</summary>
|
||||||
```yaml
|
```yaml
|
||||||
menu_title: 'One time use menu'
|
menu_title: 'One time use menu'
|
||||||
open_command: onetimeuse
|
open_command: onetimeuse
|
||||||
@ -92,8 +96,12 @@ items:
|
|||||||
- '[console] give %player_name% diamond 1 %javascript_data_set,{player_uuid}.has_used,true%'
|
- '[console] give %player_name% diamond 1 %javascript_data_set,{player_uuid}.has_used,true%'
|
||||||
- '[close]'
|
- '[close]'
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
**Save as** `data.js`
|
**Javascript Code**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>data.js</summary>
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
function set(path, data) {
|
function set(path, data) {
|
||||||
@ -185,6 +193,7 @@ function runPlaceholder() {
|
|||||||
}
|
}
|
||||||
runPlaceholder();
|
runPlaceholder();
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
**Add to** `javascript_placeholders.yml`
|
**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.
|
**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**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>haspermission.js</summary>
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// create a variable and name it wantever you want like this
|
// 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
|
// by this we are calling the function to run
|
||||||
permission();
|
permission();
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
**Add to** `javascript_placeholders.yml`
|
**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).
|
**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**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>animated_text.js</summary>
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var messages = ["This is", "This is a", "This is a test message"];
|
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;
|
var msgnumber = Data.exists(numdata) ? Data.get(numdata) : 0;
|
||||||
msgnumber++;
|
msgnumber++;
|
||||||
|
|
||||||
if (msgnumber >= 3) {
|
if (msgnumber >= messages.length) {
|
||||||
msgnumber = 0;
|
msgnumber = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +289,7 @@ function getMessage(ID) {
|
|||||||
}
|
}
|
||||||
getMessage(IDv);
|
getMessage(IDv);
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
**Add to** `javascript_placeholders.yml`
|
**Add to** `javascript_placeholders.yml`
|
||||||
|
|
||||||
@ -334,7 +351,10 @@ maxhealth:
|
|||||||
* **Description:** Return the display name of the item you're holding in your hand.
|
* **Description:** Return the display name of the item you're holding in your hand.
|
||||||
* **Usage:** `%javascript_displayname%`
|
* **Usage:** `%javascript_displayname%`
|
||||||
|
|
||||||
**Save as** `displayname.js`
|
**Javascript Code**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>displayname.js</summary>
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var player = BukkitPlayer;
|
var player = BukkitPlayer;
|
||||||
@ -359,6 +379,7 @@ function displayname() {
|
|||||||
}
|
}
|
||||||
displayname();
|
displayname();
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
**Add to** `javascript_placeholders.yml`
|
**Add to** `javascript_placeholders.yml`
|
||||||
|
|
||||||
@ -415,7 +436,10 @@ lorelines:
|
|||||||
* **Usage:** `%javascript_lore% OR %javascript_lore_<LineNumber>%`
|
* **Usage:** `%javascript_lore% OR %javascript_lore_<LineNumber>%`
|
||||||
* **Example:** `%javascript_lore%` to return all lore lines, `%javascript_lore_1%` to return lore line number 1
|
* **Example:** `%javascript_lore%` to return all lore lines, `%javascript_lore_1%` to return lore line number 1
|
||||||
|
|
||||||
**Save as** `lore.js`
|
**Javascript Code**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>lore.js</summary>
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var player = BukkitPlayer;
|
var player = BukkitPlayer;
|
||||||
@ -462,6 +486,7 @@ function itemlore() {
|
|||||||
}
|
}
|
||||||
itemlore();
|
itemlore();
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
**Add to** `javascript_placeholders.yml`
|
**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.
|
**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**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>item.js</summary>
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var vbukkit = org.bukkit.Bukkit;
|
var vbukkit = org.bukkit.Bukkit;
|
||||||
@ -617,6 +645,7 @@ function run() {
|
|||||||
|
|
||||||
run();
|
run();
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
**Add to** `javascript_placeholders.yml`
|
**Add to** `javascript_placeholders.yml`
|
||||||
|
|
||||||
@ -681,7 +710,8 @@ difference_dates:
|
|||||||
* `%javascript_cooldown_name_start%`
|
* `%javascript_cooldown_name_start%`
|
||||||
* `%javascript_cooldown_name_reset%`
|
* `%javascript_cooldown_name_reset%`
|
||||||
|
|
||||||
**Example of using with DeluxeMenus**
|
<details>
|
||||||
|
<summary>Example of using with DeluxeMenus</summary>
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
menu_title: '&aExample GUI menu'
|
menu_title: '&aExample GUI menu'
|
||||||
@ -865,8 +895,12 @@ items:
|
|||||||
- '[message] Do whatever u want'
|
- '[message] Do whatever u want'
|
||||||
- '[refresh]'
|
- '[refresh]'
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
**Save as** `cooldown.js`
|
**Javascript Code**
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>cooldown.js</summary>
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var monthSymbol = "mo";
|
var monthSymbol = "mo";
|
||||||
@ -949,6 +983,7 @@ function run() {
|
|||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
**Add to** `javascript_placeholders.yml`
|
**Add to** `javascript_placeholders.yml`
|
||||||
|
|
||||||
@ -1035,10 +1070,18 @@ healthbar:
|
|||||||
```javascript
|
```javascript
|
||||||
function numInGroupOfWorlds() {
|
function numInGroupOfWorlds() {
|
||||||
var num = 0;
|
var num = 0;
|
||||||
|
|
||||||
for (var i = 0; i < args.length; i++) {
|
for (var i = 0; i < args.length; i++) {
|
||||||
num += BukkitServer.getWorld(args[i]).getPlayers().length;
|
var world = BukkitServer.getWorld(args[i]);
|
||||||
if (i + 1 == args.length) return num.toFixed(0);
|
|
||||||
|
if (world == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
num += world.getPlayers().length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return num.toFixed(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
numInGroupOfWorlds();
|
numInGroupOfWorlds();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user