Merge branch 'docs/wiki' into master

This commit is contained in:
Andre_601 2021-10-01 14:16:06 +02:00 committed by GitHub
commit 416fbc0e3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 5788 additions and 4888 deletions

View File

@ -86,7 +86,7 @@ labels:
We would like to inform you, that you are now able to directly commit your changes to the wiki through a Pull request. We would like to inform you, that you are now able to directly commit your changes to the wiki through a Pull request.
When doing so, make sure you follow these steps: When doing so, make sure you follow these steps:
- The Pull request targets the [`docs/wiki`](https://github.com/PlaceholderAPI/PlaceholderAPI/tree/docs/wiki) branch of the Repository. - The Pull request is based on AND targets the [`docs/wiki`](https://github.com/PlaceholderAPI/PlaceholderAPI/tree/docs/wiki) branch of the Repository.
- You only made changes to the files inside the [`wiki`](https://github.com/PlaceholderAPI/PlaceholderAPI/tree/docs/wiki/wiki) folder. - You only made changes to the files inside the [`wiki`](https://github.com/PlaceholderAPI/PlaceholderAPI/tree/docs/wiki/wiki) folder.
- You followed the general Styling Guidelines mentioned in the wiki's [README](https://github.com/PlaceholderAPI/PlaceholderAPI/blob/docs/wiki/wiki/README.md) file. - You followed the general Styling Guidelines mentioned in the wiki's [README](https://github.com/PlaceholderAPI/PlaceholderAPI/blob/docs/wiki/wiki/README.md) file.

View File

@ -27,13 +27,16 @@ This page shows all commands, including with a detailed description of what ever
- **[Other Commands](#other-commands)** - **[Other Commands](#other-commands)**
- [`/papi dump`](#papi-dump) - [`/papi dump`](#papi-dump)
- [`/papi help`](#papi-help)
- [`/papi reload`](#papi-reload) - [`/papi reload`](#papi-reload)
- [`/papi version`](#papi-version)
---- ----
### Parse Commands ### Parse Commands
These commands are used to parse placeholders into their respective values. Useful for debugging. These commands are used to parse placeholders into their respective values. Useful for debugging.
#### `/papi bcparse` - #### `/papi bcparse`
**Description**: **Description**:
Parses placeholders of a String and broadcasts the result to all players. Parses placeholders of a String and broadcasts the result to all players.
@ -46,8 +49,7 @@ Parses placeholders of a String and broadcasts the result to all players.
/papi bcparse funnycube My name is %player_name%! /papi bcparse funnycube My name is %player_name%!
``` ```
---- - #### `/papi cmdparse`
#### `/papi cmdparse`
**Description**: **Description**:
Parses placeholders of a String and executes it as a command. Parses placeholders of a String and executes it as a command.
@ -60,8 +62,7 @@ Parses placeholders of a String and executes it as a command.
/papi cmdparse funnycube say My name is %player_name%! /papi cmdparse funnycube say My name is %player_name%!
``` ```
---- - #### `/papi parse`
#### `/papi parse`
**Description**: **Description**:
Parses the placeholders in a given text and shows the result. Parses the placeholders in a given text and shows the result.
@ -74,8 +75,7 @@ Parses the placeholders in a given text and shows the result.
/papi parse funnycube My group is %vault_group% /papi parse funnycube My group is %vault_group%
``` ```
---- - #### `/papi parserel`
#### `/papi parserel`
**Description**: **Description**:
Parses a relational placeholder. Parses a relational placeholder.
@ -90,20 +90,19 @@ Parses a relational placeholder.
``` ```
---- ----
### eCloud Commands ### eCloud Commands
These commands all start with `/papi ecloud` and are used for things related about the [[Expansion Cloud]]. These commands all start with `/papi ecloud` and are used for things related about the [[Expansion Cloud]].
#### `/papi ecloud clear` - #### `/papi ecloud clear`
**Description**: **Description**:
Clears the cache for the eCloud. Clears the cache for the eCloud.
---- - #### `/papi ecloud disable`
#### `/papi ecloud disable`
**Description**: **Description**:
Disables the connection to the eCloud. Disables the connection to the eCloud.
---- - #### `/papi ecloud download`
#### `/papi ecloud download`
**Description**: **Description**:
Allows you to download an expansion from the eCloud Allows you to download an expansion from the eCloud
@ -117,13 +116,11 @@ Allows you to download an expansion from the eCloud
/papi ecloud download Vault 1.5.2 /papi ecloud download Vault 1.5.2
``` ```
---- - #### `/papi ecloud enable`
#### `/papi ecloud enable`
**Description**: **Description**:
Enables the connection to the eCloud Enables the connection to the eCloud
---- - #### `/papi ecloud info`
#### `/papi ecloud info`
**Description**: **Description**:
Gives information about a specific Expansion. Gives information about a specific Expansion.
@ -136,8 +133,7 @@ Gives information about a specific Expansion.
/papi ecloud info Vault /papi ecloud info Vault
``` ```
---- - #### `/papi ecloud list`
#### `/papi ecloud list`
**Description**: **Description**:
Lists either all Expansions on the eCloud, only those by a specific author or only those that you have [installed](#papi-ecloud-download). Lists either all Expansions on the eCloud, only those by a specific author or only those that you have [installed](#papi-ecloud-download).
Installed Expansions show as green in the list and Expansions that are installed and have an update available show as gold. Installed Expansions show as green in the list and Expansions that are installed and have an update available show as gold.
@ -152,8 +148,7 @@ Installed Expansions show as green in the list and Expansions that are installed
/papi ecloud list installed /papi ecloud list installed
``` ```
---- - #### `/papi ecloud placeholders`
#### `/papi ecloud placeholders`
**Description**: **Description**:
List all placeholders of an Expansion. List all placeholders of an Expansion.
@ -165,21 +160,20 @@ List all placeholders of an Expansion.
/papi ecloud placeholders Vault /papi ecloud placeholders Vault
``` ```
---- - #### `/papi ecloud refresh`
#### `/papi ecloud refresh`
**Description**: **Description**:
Refresh the cached data from the eCloud. Refresh the cached data from the eCloud.
---- - #### `/papi ecloud status`
#### `/papi ecloud status`
**Description**: **Description**:
Displays the actual Status of the eCloud. Displays the actual Status of the eCloud.
---- ----
### Expansion Commands ### Expansion Commands
These commands can be used to manage the expansions that you have currently installed. These commands can be used to manage the expansions that you have currently installed.
#### `/papi info` - #### `/papi info`
**Description**: **Description**:
Gives you information about the specified Expansion. Gives you information about the specified Expansion.
@ -191,14 +185,12 @@ Gives you information about the specified Expansion.
/papi info Vault /papi info Vault
``` ```
---- - #### `/papi list`
#### `/papi list`
**Description**: **Description**:
Lists all active/registered expansions. Lists all active/registered expansions.
This is different to [/papi ecloud list installed](#papi-ecloud-list) in the fact, that it also includes expansions that were installed through a plugin (That aren't a separate jar-file) and it also doesn't show which one have updates available. This is different to [/papi ecloud list installed](#papi-ecloud-list) in the fact, that it also includes expansions that were installed through a plugin (That aren't a separate jar-file) and it also doesn't show which one have updates available.
---- - #### `/papi register`
#### `/papi register`
**Description**: **Description**:
Registers an expansion from a specified filename. Registers an expansion from a specified filename.
This is useful in cases, where you downloaded the expansion manually and don't want to restart the server. This is useful in cases, where you downloaded the expansion manually and don't want to restart the server.
@ -212,8 +204,7 @@ The file needs to be inside `/plugins/PlaceholderAPI/expansions`.
/papi register MyExpansion.jar /papi register MyExpansion.jar
``` ```
---- - #### `/papi unregister`
#### `/papi unregister`
**Description**: **Description**:
Unregisters the specified expansion. Unregisters the specified expansion.
@ -226,14 +217,23 @@ Unregisters the specified expansion.
``` ```
---- ----
### Other Commands ### Other Commands
These are other commands of PlaceholderAPI that don't fit any of the above categories. These are other commands of PlaceholderAPI that don't fit any of the above categories.
#### `/papi dump` - #### `/papi dump`
**Description**: **Description**:
Pastes useful information from PlaceholderAPI such as plugin version, server version and installed expansions to https://paste.helpch.at for simple sharing and support. Pastes useful information from PlaceholderAPI such as plugin version, server version and installed expansions to https://paste.helpch.at for simple sharing and support.
#### `/papi reload` - #### `/papi help`
**Description**:
Displays all the commands PlaceholderAPI currently offers.
- #### `/papi reload`
**Description**: **Description**:
Reloads the config settings. Reloads the config settings.
You need to use this command after [downloading Expansions](#papi-ecloud-download) from the eCloud or they won't be properly registered. You need to use this command after [downloading Expansions](#papi-ecloud-download) from the eCloud or they won't be properly registered.
- #### `/papi version`
**Description**:
Shows the current version and authors of PlaceholderAPI.

View File

@ -7,10 +7,12 @@ It also has a list with all available placeholders (Work in progress).
### Setup ### Setup
**[[Hook into PlaceholderAPI]]** **[[Hook into PlaceholderAPI]]**
- [[First steps|Hook-into-PlaceholderAPI#first-steps]] - [[First steps|Hook-into-PlaceholderAPI#first-steps]]
- [[Adding placeholders to PlaceholderAPI|Hook-into-PlaceholderAPI#adding-placeholders-to-placeholderapi]] - [[Adding placeholders to PlaceholderAPI|PlaceholderExpansion]]
- [[PlaceholderExpansion]] - [[Common Parts|PlaceholderExpansion#common-parts]]
- [[Without an external plugin|PlaceholderExpansion#without-an-external-plugin]] - [[Without an external plugin|PlaceholderExpansion#without-a-plugin]]
- [[With external plugin|PlaceholderExpansion#with-external-plugin]] - [[With an external Plugin (Separate Jar)|PlaceholderExpansion#with-a-plugin-external-jar]]
- [[With an external Plugin (Internal class)|PlaceholderExpansion#with-a-plugin-internal-class]]
- [[Relational Placeholders|PlaceholderExpansion#relational-placeholders]]
- [[Setting placeholders in your plugin|Hook-into-PlaceholderAPI#setting-placeholders-in-your-plugin]] - [[Setting placeholders in your plugin|Hook-into-PlaceholderAPI#setting-placeholders-in-your-plugin]]
### Other ### Other
@ -19,39 +21,7 @@ It also has a list with all available placeholders (Work in progress).
**[[FAQ]]** **[[FAQ]]**
**[[Plugins using PlaceholderAPI]]** **[[Plugins using PlaceholderAPI]]**
**[[Placeholders]]** **[[Placeholders]]**
- [[PAPI-placeholders|Placeholders#papi-placeholders-1]] - [[Standalone|Placeholders#standalone]]
- [[Advancements|Placeholders#advancements]]
- [[Animations|Placeholders#animations]]
- [[Armor|Placeholders#armor]]
- [[ASCII|Placeholders#ASCII]]
- [[BungeeCord|Placeholders#bungeecord]]
- [[CheckItem|Placeholders#checkitem]]
- [[CooldownBar|Placeholders#cooldownbar]]
- [[Formatter|Placeholders#formatter]]
- [[Javascript|Placeholders#javascript]]
- [[ListPlayers|Placeholders#listplayer]]
- [[LocalTime|Placeholders#localtime]]
- [[Math|Placeholders#math]]
- [[MVdW placeholders|Placeholders#mvdw-placeholders]]
- [[OtherPlayer|Placeholders#otherplayer]]
- [[ParseNear|Placeholders#parsenear]]
- [[ParseOther|Placeholders#parseother]]
- [[Pinger|Placeholders#pinger]]
- [[Player|Placeholders#player]]
- [[PlayerList|Placeholders#playerlist]]
- [[Plugin|Placeholders#plugin]]
- [[Progress|Placeholders#progress]]
- [[RainbowColor|Placeholders#rainbowcolor]]
- [[RandomColor|Placeholders#randomcolor]]
- [[RedisBungee|Placeholders#redisbungee]]
- [[RelCon|Placeholders#relcon]]
- [[ScoreboardObjectives|Placeholders#scoreboardobjectives]]
- [[Server|Placeholders#server]]
- [[Sound|Placeholders#sound]]
- [[Spectators|Placeholders#spectators]]
- [[Statistic|Placeholders#statistic]]
- [[Plugin-placeholders|Placeholders#plugin-placeholders-1]]
- [[A|Placeholders#a]] - [[A|Placeholders#a]]
- [[B|Placeholders#b]] - [[B|Placeholders#b]]
- [[C|Placeholders#c]] - [[C|Placeholders#c]]
@ -75,4 +45,33 @@ It also has a list with all available placeholders (Work in progress).
- [[U|Placeholders#u]] - [[U|Placeholders#u]]
- [[V|Placeholders#v]] - [[V|Placeholders#v]]
- [[W|Placeholders#w]] - [[W|Placeholders#w]]
- [[X|Placeholders#x]]
- [[Y|Placeholders#y]]
- [[Z|Placeholders#z]] - [[Z|Placeholders#z]]
- [[Plugin-placeholders|Placeholders#plugin-placeholders-1]]
- [[A|Placeholders#a-1]]
- [[B|Placeholders#b-1]]
- [[C|Placeholders#c-1]]
- [[D|Placeholders#d-1]]
- [[E|Placeholders#e-1]]
- [[F|Placeholders#f-1]]
- [[G|Placeholders#g-1]]
- [[H|Placeholders#h-1]]
- [[I|Placeholders#i-1]]
- [[J|Placeholders#j-1]]
- [[K|Placeholders#k-1]]
- [[L|Placeholders#l-1]]
- [[M|Placeholders#m-1]]
- [[N|Placeholders#n-1]]
- [[O|Placeholders#o-1]]
- [[P|Placeholders#p-1]]
- [[Q|Placeholders#q-1]]
- [[R|Placeholders#r-1]]
- [[S|Placeholders#s-1]]
- [[T|Placeholders#t-1]]
- [[U|Placeholders#u-1]]
- [[V|Placeholders#v-1]]
- [[W|Placeholders#w-1]]
- [[X|Placeholders#x-1]]
- [[Y|Placeholders#y-1]]
- [[Z|Placeholders#z-1]]

View File

@ -1,397 +1,296 @@
[placeholderexpansion]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java
[playerexpansion]: https://github.com/PlaceholderAPI/Player-Expansion
[serverexpansion]: https://github.com/PlaceholderAPI/Server-Expansion
[mathexpansion]: https://github.com/Andre601/Math-expansion
[relational]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/src/main/java/me/clip/placeholderapi/expansion/Relational.java
## Overview ## Overview
This page covers how you can use the `PlaceholderExpansion` to add own placeholders to PlaceholderAPI, which then can be used by other plugins. This page will cover how you can create your own [`PlaceholderExpansion`][placeholderexpansion] which you can either [[Upload to the eCloud|Expansion cloud]] or integrate into your own plugin.
PlaceholderAPI is using Expansions for its placeholders, with PlaceholderAPI providing the core. Users can download Expansions from the cloud server using commands in-game or by going [here](https://api.extendedclip.com/home/) if they want to use the placeholder. It's worth noting that PlaceholderAPI relies on expansions being installed. PlaceholderAPI only acts as the core replacing utility while the expansions allow other plugins to use any installed placeholder in their own messages.
You can download Expansions either directly from the eCloud yourself, or download them through the [[download command of PlaceholderAPI|Commands#papi-ecloud-download]].
## Note ## Table of Contents
You can either make a separate jar file, to upload it to the expansion-cloud (recommended) or have it as a local class inside your plugin.
## Examples - [Getting started](#getting-started)
There are multiple methods and ways you can use the PlaceholderExpansion. - [Common Parts](#common-parts)
Those depend on what you want to display through the placeholders in the end. - [Without a Plugin](#without-a-plugin)
- [With a Plugin (External Jar)](#with-a-plugin-external-jar)
- [With a Plugin (Internal Class)](#with-a-plugin-internal-class)
- [Register the Expansion](#register-the-expansion)
- [Relational Placeholders](#relational-placeholders)
- [Notes about Relational Placeholders](#notes-about-relational-placeholders)
* [Without external plugin](#without-external-plugin) ## Getting started
* [With external plugin](#with-external-plugin) For starters, you need to decide what type of [`PlaceholderExpansion`][placeholderexpansion] you want to create. There are various ways to create an expansion. This page will cover the most common ones.
* [Separate jar](#separate-jar)
* [Internal class](#internal-class)
### Without an external plugin ### Common Parts
This part here covers how you create an expansion that doesn't require any external/additional plugins to function. All shown examples will share the same common parts that belong to the [`PlaceholderExpansion`][placeholderexpansion] class.
Examples of such expansions are: In order to not repeat the same basic info for each method throughout this page, and to greatly reduce its overall length, we will cover the most basic/necessary ones here.
- [Player expansion](/PlaceholderAPI/Player-Expansion)
- [Math expansion](https://github.com/Andre601/Math-Expansion)
- [Statistics expansion](/PlaceholderAPI/Statistics-Expansion)
Since it would be weird (and also make no real sense) to have this inside your plugin, we assume you make a separate jar-file as an expansion. #### Basic PlaceholderExpansion Structure
To begin, first make the class extend the `PlaceholderExpansion` and add the required methods:
```java ```java
package at.helpch.placeholderapi.example.expansions; package at.helpch.placeholderapi.example.expansions;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
/**
* This class will automatically register as a placeholder expansion
* when a jar including this class is added to the directory
* {@code /plugins/PlaceholderAPI/expansions} on your server.
* <br>
* <br>If you create such a class inside your own plugin, you have to
* register it manually in your plugins {@code onEnable()} by using
* {@code new YourExpansionClass().register();}
*/
public class SomeExpansion extends PlaceholderExpansion { public class SomeExpansion extends PlaceholderExpansion {
/**
* This method should always return true unless we
* have a dependency we need to make sure is on the server
* for our placeholders to work!
*
* @return always true since we do not have any dependencies.
*/
@Override
public boolean canRegister(){
return true;
}
/**
* The name of the person who created this expansion should go here.
*
* @return The name of the author as a String.
*/
@Override @Override
public String getAuthor() { public String getAuthor() {
return "someauthor"; return "someauthor";
} }
/**
* The placeholder identifier should go here.
* <br>This is what tells PlaceholderAPI to call our onRequest
* method to obtain a value if a placeholder starts with our
* identifier.
* <br>The identifier has to be lowercase and can't contain _ or %
*
* @return The identifier in {@code %<identifier>_<value>%} as String.
*/
@Override @Override
public String getIdentifier() { public String getIdentifier() {
return "example"; return "example";
} }
/**
* This is the version of this expansion.
* <br>You don't have to use numbers, since it is set as a String.
*
* @return The version as a String.
*/
@Override @Override
public String getVersion() { public String getVersion() {
return "1.0.0"; return "1.0.0";
} }
/**
* This is the method called when a placeholder with our identifier
* is found and needs a value.
* <br>We specify the value identifier in this method.
* <br>Since version 2.9.1 can you use OfflinePlayers in your requests.
*
* @param player
* A {@link org.bukkit.OfflinePlayer OfflinePlayer}.
* @param identifier
* A String containing the identifier/value.
*
* @return Possibly-null String of the requested identifier.
*/
@Override
public String onRequest(OfflinePlayer player, String identifier){
// %example_placeholder1%
if(identifier.equals("placeholder1")){
return "placeholder1 works";
}
// %example_placeholder2%
if(identifier.equals("placeholder2")){
return "placeholder2 works";
}
// We return null if an invalid placeholder (f.e. %example_placeholder3%)
// was provided
return null;
}
} }
``` ```
Let's quickly break down the different methods you have to implement.
- #### getAuthor
This method allows you to set the name of the expansion's author.
- #### getIdentifier
The identifier is the part in the placeholder that is between the first `%` (Or `{` if bracket placeholders are used) and the first `_`.
Because of that can you not use `%`, `{`, `}` or `_` in youd identifier.
If you still want to use those symbols can you override the `getName()` method to display a different name.
- #### getVersion
This is a string, which means it can contain more than just a number. This is used to determine if a new update is available or not when the expansion is shared on the eCloud.
For expansions that are part of a plugin, this does not really matter.
Those are all the neccessary parts for your PlaceholderExpansion.
Any other methods that are part of the [`PlaceholderExpansion`][placeholderexpansion] class are optional and will usually not be used, or will default to a specific value. Please read the Javadoc comments of those methods for more information.
You must choose between one of these two methods for handling the actual parsing of placeholders:
- #### onRequest(OfflinePlayer, String)
If not explicitly set, this will automatically call [`onPlaceholderRequest(Player, String)`](#onplaceholderrequestplayer-string).
This method is recommended as it allows the usage of `null` and can therefore be used in placeholders that don't require a valid player to be used.
- #### onPlaceholderRequest(Player, String)
If not set, this method will return `null` which PlaceholderAPI sees as an invalid placeholder.
---- ----
## Without a Plugin
An expansion does not always need a plugin to rely on. If the placeholders it provides can return values from just the server itself or some other source (i.e. Java itself), then it can work independently.
### With external plugin Common examples of such Expansions are:
Those examples here applies to people who want to provide information from their own plugin through placeholders from PlaceholderAPI.
There exists a repository showcasing an [example-expansion](/PlaceholderAPI/Example-Expansion) with what you can/should do.
In our examples do we have the plugin `SomePlugin` and want to show certain placeholders with it. - [Player Expansion][playerexpansion]
- [Server Expansion][serverexpansion]
- [Math Expansion][mathexpansion]
There are two ways to actually get information from your plugin and they only are different in if you have the expansion as a separate jar-file or as an internal class. These kinds of expansions don't require any additional plugins to function.
When creating such an expansion is it recommended to use [`onRequest(OfflinePlayer, String)`](#onrequestofflineplayer-string).
#### Separate jar #### Full Example
In our separate jar do we have to make some checks, to be sure, that the required plugin is installed and running. Please see the [Common parts](#common-parts) section for info on the other methods.
The below code shows how the class can look like in case the plugin doesn't have a public and easy to access API.
```java ```java
package at.helpch.placeholderapi.example.expansions; package at.helpch.placeholderapi.example.expansions;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import at.helpch.placeholderapi.example.SomePlugin;
/**
* This class will automatically register as a placeholder expansion
* when a jar including this class is added to the directory
* {@code /plugins/PlaceholderAPI/expansions} on your server.
* <br>
* <br>If you create such a class inside your own plugin, you have to
* register it manually in your plugins {@code onEnable()} by using
* {@code new YourExpansionClass().register();}
*/
public class SomeExpansion extends PlaceholderExpansion { public class SomeExpansion extends PlaceholderExpansion {
// We get an instance of the plugin later.
private SomePlugin plugin;
/**
* Since this expansion requires api access to the plugin "SomePlugin"
* we must check if said plugin is on the server or not.
*
* @return true or false depending on if the required plugin is installed.
*/
@Override
public boolean canRegister(){
return (plugin = (SomePlugin) Bukkit.getPluginManager().getPlugin(getRequiredPlugin())) != null;
}
/**
* The name of the person who created this expansion should go here.
*
* @return The name of the author as a String.
*/
@Override @Override
public String getAuthor() { public String getAuthor() {
return "someauthor"; return "someauthor";
} }
/**
* The placeholder identifier should go here.
* <br>This is what tells PlaceholderAPI to call our onRequest
* method to obtain a value if a placeholder starts with our
* identifier.
* <br>The identifier has to be lowercase and can't contain _ or %
*
* @return The identifier in {@code %<identifier>_<value>%} as String.
*/
@Override @Override
public String getIdentifier() { public String getIdentifier() {
return "someplugin"; return "example";
} }
/**
* if the expansion requires another plugin as a dependency, the
* proper name of the dependency should go here.
* <br>Set this to {@code null} if your placeholders do not require
* another plugin to be installed on the server for them to work.
* <br>
* <br>This is extremely important to set your plugin here, since if
* you don't do it, your expansion will throw errors.
*
* @return The name of our dependency.
*/
@Override
public String getRequiredPlugin(){
return "SomePlugin";
}
/**
* This is the version of this expansion.
* <br>You don't have to use numbers, since it is set as a String.
*
* @return The version as a String.
*/
@Override @Override
public String getVersion() { public String getVersion() {
return "1.0.0"; return "1.0.0";
} }
/**
* This is the method called when a placeholder with our identifier
* is found and needs a value.
* <br>We specify the value identifier in this method.
* <br>Since version 2.9.1 can you use OfflinePlayers in your requests.
*
* @param player
* A {@link org.bukkit.Player Player}.
* @param identifier
* A String containing the identifier/value.
*
* @return possibly-null String of the requested identifier.
*/
@Override @Override
public String onPlaceholderRequest(Player player, String identifier){ public String onRequest(OfflinePlayer player, String params) {
if(params.equalsIgnoreCase("name")) {
if(p == null){ return player == null ? null : player.getName(); // "name" requires the player to be valid
return "";
} }
// %someplugin_placeholder1% if(params.equalsIgnoreCase("placeholder1")) {
if(identifier.equals("placeholder1")){ return "Placeholder Text 1";
return plugin.getConfig().getString("placeholder1", "value doesnt exist");
} }
// %someplugin_placeholder2% if(params.equalsIgnoreCase("placeholder2")) {
if(identifier.equals("placeholder2")){ return "Placeholder Text 2";
return plugin.getConfig().getString("placeholder2", "value doesnt exist");
} }
// We return null if an invalid placeholder (f.e. %someplugin_placeholder3%) return null; // Placeholder is unknown by the Expansion
// was provided
return null;
} }
} }
``` ```
---- ----
#### Internal class ## With a Plugin (External Jar)
You can have the class inside your plugin. If your expansion relies on a plugin to provide its placeholder values, you will need to override a few more methods to make sure everything will work correctly.
This has some advantages but can also have some disadvantages.
If you include a PlaceholderExpansion class in your plugin, you MUST add an override the persist() method to return true Your expansion will need to override the `getRequiredPlugin()` method to return the name of the plugin your expansion depends on.
otherwise, if PlaceholderAPI is reloaded, your expansion will be unregistered and lost forever. PlaceholderAPI automatically checks if this method will either return null, or if the name defined results in a non-null plugin.
It is worth noting that it is a bit more difficult to make a separate jar file that depends on a plugin, as it will require the plugin to have some sort of accessible API in order to get the required values.
One way to bypass this is to override the `canRegister()` method with the following code:
```java
private SomePlugin plugin = null; // This would be the plugin your expansion depends on
@Override
public boolean canregister() {
// This sets plugin to the SomePlugin instance you get through the PluginManager
return (plugin = (SomePlugin) Bukkit.getPluginManager().getPlugin(getRequiredPlugin())) != null;
}
```
Using this code-snippet, you can get a direct instance of the plugin and access things such as config values.
With that said, it is recommended instead to use an API if one is available, as this kind of plugin access is a relatively poor approach.
#### Full Example
Please see the [Common parts](#common-parts) section for info on the other methods.
```java
package at.helpch.placeholderapi.example.expansions;
import at.helpch.placeholderapi.example.SomePlugin;
import org.bukkit.OfflinePlayer;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
public class SomeExpansion extends PlaceholderExpansion {
private SomePlugin plugin; // This instance is assigned in canRegister()
@Override
public String getAuthor() {
return "someauthor";
}
@Override
public String getIdentifier() {
return "example";
}
@Override
public String getVersion() {
return "1.0.0";
}
@Override
public String getRequiredPlugin() {
return "SomePlugin";
}
@Override
public boolean canRegister() {
return (plugin = (SomePlugin) Bukkit.getPluginManager().getPlugin(getRequiredPlugin())) != null;
}
@Override
public String onRequest(OfflinePlayer player, String params) {
if(params.equalsIgnoreCase("placeholder1")){
return plugin.getConfig().getString("placeholders.placeholder1", "default1");
}
if(params.equalsIgnoreCase("placeholder2")){
return plugin.getConfig().getString("placeholders.placeholder2", "default2");
}
return null; // Placeholder is unknown by the expansion
}
}
```
----
## With a Plugin (Internal Class)
The way expansions are handled when they are part of the plugin itself is fairly similar to when you [make an expansion without a plugin dependency](#without-a-plugin).
In fact, you don't even have to override the `getRequiredPlugin()` and `canRegister()` methods as it is always guaranteed that the plugin is available.
Something worth noting, however, is that you need to override the `persist()` method and make it return true. This ensures that the expansion won't be unregistered by PlaceholderAPI whenever it is reloaded.
Finally, you can also use dependency injection as an easier way to access a plugin's methods.
Here is a small code example of how dependency injection may look:
```java
public class SomeExpansion extends PlaceholderExpansion {
private final SomePlugin plugin; // The instance is created in the constructor and won't be modified, so it can be final
public SomeExpansion(SomePlugin plugin) {
this.plugin = plugin;
}
}
```
#### Full Example
Please see the [Common parts](#common-parts) section for info on the other methods.
```java ```java
package at.helpch.placeholderapi.example.expansions; package at.helpch.placeholderapi.example.expansions;
import at.helpch.placeholderapi.example.SomePlugin;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import at.helpch.placeholderapi.example.SomePlugin;
/**
* This class will be registered through the register-method in the
* plugins onEnable-method.
*/
public class SomeExpansion extends PlaceholderExpansion { public class SomeExpansion extends PlaceholderExpansion {
private SomePlugin plugin; private final SomePlugin plugin;
/**
* Since we register the expansion inside our own plugin, we
* can simply use this method here to get an instance of our
* plugin.
*
* @param plugin
* The instance of our plugin.
*/
public SomeExpansion(SomePlugin plugin) { public SomeExpansion(SomePlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
/**
* Because this is an internal class,
* you must override this method to let PlaceholderAPI know to not unregister your expansion class when
* PlaceholderAPI is reloaded
*
* @return true to persist through reloads
*/
@Override
public boolean persist(){
return true;
}
/**
* Because this is a internal class, this check is not needed
* and we can simply return {@code true}
*
* @return Always true since it's an internal class.
*/
@Override
public boolean canRegister(){
return true;
}
/**
* The name of the person who created this expansion should go here.
* <br>For convienience do we return the author from the plugin.yml
*
* @return The name of the author as a String.
*/
@Override @Override
public String getAuthor() { public String getAuthor() {
return plugin.getDescription().getAuthors().toString(); return "someauthor";
} }
/**
* The placeholder identifier should go here.
* <br>This is what tells PlaceholderAPI to call our onRequest
* method to obtain a value if a placeholder starts with our
* identifier.
* <br>The identifier has to be lowercase and can't contain _ or %
*
* @return The identifier in {@code %<identifier>_<value>%} as String.
*/
@Override @Override
public String getIdentifier() { public String getIdentifier() {
return "someplugin"; return "example";
} }
/**
* This is the version of the expansion.
* <br>You don't have to use numbers, since it is set as a String.
*
* For convienience do we return the version from the plugin.yml
*
* @return The version as a String.
*/
@Override @Override
public String getVersion() { public String getVersion() {
return plugin.getDescription().getVersion(); return "1.0.0";
} }
/**
* This is the method called when a placeholder with our identifier
* is found and needs a value.
* <br>We specify the value identifier in this method.
* <br>Since version 2.9.1 can you use OfflinePlayers in your requests.
*
* @param player
* A {@link org.bukkit.Player Player}.
* @param identifier
* A String containing the identifier/value.
*
* @return possibly-null String of the requested identifier.
*/
@Override @Override
public String onPlaceholderRequest(Player player, String identifier){ public boolean persist() {
return true; // This is required or else PlaceholderAPI will unregister the Expansion on reload
if(player == null){
return "";
} }
// %someplugin_placeholder1% @Override
if(identifier.equals("placeholder1")){ public String onRequest(OfflinePlayer player, String params) {
return plugin.getConfig().getString("placeholder1", "value doesnt exist"); if(params.equalsIgnoreCase("placeholder1")){
return plugin.getConfig().getString("placeholders.placeholder1", "default1");
} }
// %someplugin_placeholder2% if(params.equalsIgnoreCase("placeholder2")) {
if(identifier.equals("placeholder2")){ return plugin.getConfig().getString("placeholders.placeholder2", "default2");
return plugin.getConfig().getString("placeholder2", "value doesnt exist");
} }
// We return null if an invalid placeholder (f.e. %someplugin_placeholder3%) return null; // Placeholder is unknown by the Expansion
// was provided
return null;
} }
} }
``` ```
As you can see is this method pretty similar to the one without any external plugins, since we can get an instance of our plugin much easier and also have a 100% guarantee that the plugin is installed and running. ### Register the Expansion
To register the expansion, you will need to call the `register()` method yourself.
This should be done in your plugin's `onEnable()` method after you make sure that PlaceholderAPI is installed and enabled.
Our final step now is to register the class and its placeholders. The plugin doesn't do this on its own.
To achieve this, add the following to your `onEnable()` section (Use your expansion name of course):
```java ```java
package at.helpch.placeholderapi.example package at.helpch.placeholderapi.example
@ -409,3 +308,74 @@ public class SomePlugin extends JavaPlugin{
} }
} }
``` ```
----
## Relational Placeholders
Relational Placeholders are a bit more specific compared to the previous examples.
While they do use the same [common parts](#common-parts) that the other examples do, they have a different method to return placeholders.
In order to use the relational placeholders feature, you will need to implement the [`Relational`][relational] interface, which in return adds the `onPlaceholderRequest(Player, Player, String)` method to use.
#### Full Example
Please see the [Common parts](#common-parts) section for info on the other methods.
In this example, we use the [Internal class setup](#with-a-plugin-internal-jar) and `SomePlugin` has an `areFriends(Player, Player)` method that returns true or false based on if the given players are friends.
```java
package at.helpch.placeholderapi.example.expansions;
import at.helpch.placeholderapi.example.SomePlugin;
import org.bukkit.ChatColor;
import org.bukkit.Player;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.Relational;
public class SomeExpansion extends PlaceholderExpansion implements Relational {
private final SomePlugin plugin;
public SomeExpansion(SomePlugin plugin) {
this.plugin = plugin;
}
@Override
public String getAuthor() {
return "someauthor";
}
@Override
public String getIdentifier() {
return "example";
}
@Override
public String getVersion() {
return "1.0.0";
}
@Override
public boolean persist() {
return true; // This is required or else PlaceholderAPI will unregister the Expansion on reload
}
@Override
public String onPlaceholderRequest(Player one, Player two, String identifier) {
if(one == null || two == null)
return null; // We require both Players to be online
if(params.equalsIgnoreCase("friend")) {
if(plugin.areFriends(one, two)) {
return ChatColor.GREEN + one.getName() + " and " + two.getName() + " are friends!";
} else {
return ChatColor.GREEN + one.getName() + " and " + two.getName() + " are not friends!";
}
}
return null; // Placeholder is unknown by the Expansion
}
}
```
### Notes about Relational Placeholders
Relational placeholders will always start with `%rel_` to properly identify them.
So in the above example, the full placeholder will look like `%rel_example_friend%`.

File diff suppressed because it is too large Load Diff

View File

@ -41,9 +41,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
- **[Advanced Abilities](https://www.spigotmc.org/resources/21983/)** - **[Advanced Abilities](https://www.spigotmc.org/resources/21983/)**
- [ ] Supports placeholders. - [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#advanced-abilities]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#advanced-abilities]]**]
- **[Advanced Achievements](https://www.spigotmc.org/resources/6239/)** - **[Advanced Achievements](https://www.spigotmc.org/resources/83466/)**
- [x] Supports placeholders. - [ ] Supports placeholders.
- [ ] Provides own placeholders. [Link] - [x] Provides own placeholders. [**[[Link|Placeholders#advanced-achievements]]**]
- **[AdvancedAFK](https://www.spigotmc.org/resources/60761/)** - **[AdvancedAFK](https://www.spigotmc.org/resources/60761/)**
- [x] Supports placeholders. - [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#advancedafk]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#advancedafk]]**]
@ -461,6 +461,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
---- ----
## L ## L
- **[Lands](https://www.spigotmc.org/resources/53313/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#lands]]**]
- **[LastLoginAPI](https://www.spigotmc.org/resources/66348/)** - **[LastLoginAPI](https://www.spigotmc.org/resources/66348/)**
- [ ] Supports placeholders. - [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#lastloginapi]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#lastloginapi]]**]
@ -476,6 +479,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
- **[LemonMobCoins](https://www.spigotmc.org/resources/59402/)** - **[LemonMobCoins](https://www.spigotmc.org/resources/59402/)**
- [x] Supports placeholders. - [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#lemonmobcoins]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#lemonmobcoins]]**]
- **[LevelledMobs](https://www.spigotmc.org/resources/levelledmobs-for-1-14-x-1-17-x.74304/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#levelledmobs]]**]
- **[LuckPerms](https://www.spigotmc.org/resources/28140/)** - **[LuckPerms](https://www.spigotmc.org/resources/28140/)**
- [ ] Supports placeholders. - [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#luckperms]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#luckperms]]**]
@ -581,9 +587,15 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
- **[OnTime](http://dev.bukkit.org/bukkit-plugins/ontime/)** - **[OnTime](http://dev.bukkit.org/bukkit-plugins/ontime/)**
- [ ] Supports placeholders. - [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#ontime]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#ontime]]**]
- **[OpEconomy](https://www.spigotmc.org/resources/95674)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#opeconomy]]**]
- **[OreAnnouncer](https://www.spigotmc.org/resources/33464/)** - **[OreAnnouncer](https://www.spigotmc.org/resources/33464/)**
- [ ] Supports placeholders. - [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#oreannouncer]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#oreannouncer]]**]
- **[OreMarket](https://www.spigotmc.org/resources/91015/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#oremarket]]**]
- **[Outpost](https://www.spigotmc.org/resources/38657/)** - **[Outpost](https://www.spigotmc.org/resources/38657/)**
- [ ] Supports placeholders. - [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#outpost]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#outpost]]**]
@ -730,7 +742,7 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
- [x] Supports placeholders. - [x] Supports placeholders.
- [ ] Provides own placeholders. [Link] - [ ] Provides own placeholders. [Link]
- **[RocketPlaceholders](https://www.spigotmc.org/resources/82678/)** - **[RocketPlaceholders](https://www.spigotmc.org/resources/82678/)**
- [ ] Supports placeholders. - [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#rocketplaceholders]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#rocketplaceholders]]**]
- **[RogueParkour](https://www.spigotmc.org/resources/26563/)** - **[RogueParkour](https://www.spigotmc.org/resources/26563/)**
- [ ] Supports placeholders. - [ ] Supports placeholders.
@ -747,6 +759,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
- **[RPGInventory](https://www.spigotmc.org/resources/12498/)** - **[RPGInventory](https://www.spigotmc.org/resources/12498/)**
- [x] Supports placeholders. - [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#rpginventory]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#rpginventory]]**]
- **[RTP](https://www.spigotmc.org/resources/94812/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#rtp]]**]
---- ----
## S ## S
@ -834,6 +849,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
- **[Staff Facilities](https://www.spigotmc.org/resources/13097/)** - **[Staff Facilities](https://www.spigotmc.org/resources/13097/)**
- [x] Supports placeholders. - [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#staff-facilities]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#staff-facilities]]**]
- **[Staff++](https://www.spigotmc.org/resources/staff.83562/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#staffplusplus]]**]
- **[Statz](https://www.spigotmc.org/resources/25969/)** - **[Statz](https://www.spigotmc.org/resources/25969/)**
- [ ] Supports placeholders. - [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#statz]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#statz]]**]
@ -900,6 +918,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
- **[Tokens](https://www.spigotmc.org/resources/71941/)** - **[Tokens](https://www.spigotmc.org/resources/71941/)**
- [ ] Supports placeholders. - [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#tokens]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#tokens]]**]
- **[TokensPlus](https://www.spigotmc.org/resources/90507/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#tokensplus]]**]
- **[Towny](https://github.com/TownyAdvanced/Towny)** - **[Towny](https://github.com/TownyAdvanced/Towny)**
- [ ] Supports placeholders. - [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#towny]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#towny]]**]
@ -921,6 +942,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
- **[TrickOrTreat](https://www.spigotmc.org/resources/61370/)** - **[TrickOrTreat](https://www.spigotmc.org/resources/61370/)**
- [x] Supports placeholders. - [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#trickortreat]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#trickortreat]]**]
- **[Two Factor Authentication](https://www.spigotmc.org/resources/85594/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#twofactorauthentication]]**]
---- ----
## U ## U
@ -933,6 +957,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
- **[UltimateBossBar](https://www.spigotmc.org/resources/19303/)** - **[UltimateBossBar](https://www.spigotmc.org/resources/19303/)**
- [x] Supports placeholders. - [x] Supports placeholders.
- [ ] Provides own placeholders. - [ ] Provides own placeholders.
- **[UltimateClaims](https://songoda.com/marketplace/product/65)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#ultimateclaims]]**]
- **[UltimateSigns](https://www.spigotmc.org/resources/72462/)** - **[UltimateSigns](https://www.spigotmc.org/resources/72462/)**
- [x] Supports placeholders. - [x] Supports placeholders.
- [ ] Provides own placeholders. - [ ] Provides own placeholders.
@ -972,6 +999,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
- **[VentureChat](https://www.spigotmc.org/resources/771/)** - **[VentureChat](https://www.spigotmc.org/resources/771/)**
- [x] Supports placeholders. - [x] Supports placeholders.
- [ ] Provides own placeholders. [Link] - [ ] Provides own placeholders. [Link]
- **[VenturahCalendar](https://www.spigotmc.org/resources/94096/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#venturacalendar]]**]
- **[ViaVersion](https://www.spigotmc.org/resources/19254/)** - **[ViaVersion](https://www.spigotmc.org/resources/19254/)**
- [ ] Supports placeholders. - [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#viaversion]]**] - [x] Provides own placeholders. [**[[Link|Placeholders#viaversion]]**]

View File

@ -1,104 +1,181 @@
[Wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki [wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki
[Placeholders]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders
[Plugins using PlaceholderAPI]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Plugins-using-PlaceholderAPI [placeholders]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders
[using_papi]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Plugins-using-PlaceholderAPI
[discord]: https://discord.gg/HelpChat
[discussion]: https://github.com/PlaceholderAPI/PlaceholderAPI/discussions
[andre]: https://github.com/Andre601
[andrew]: https://github.com/Andrew-Chen-Wang
[action]: https://github.com/Andrew-Chen-Wang/github-wiki-action
<!-- Images -->
[branch-selector]: https://user-images.githubusercontent.com/11576465/132779328-8571458a-d63d-4c25-b920-96aa16ae0058.png
[upstream_up-to-date]: https://user-images.githubusercontent.com/11576465/132779917-96f19239-077d-44ed-98e7-6a76f305b33a.png
[upstream_needs_update]: https://user-images.githubusercontent.com/11576465/132779798-1fe3dc72-a6c2-41eb-a8bc-95793671f384.png
[create_branch]: https://user-images.githubusercontent.com/11576465/132780127-45599156-1400-40c9-b865-351574786873.png
# Wiki # Wiki
This is the wiki folder. It contains all pages that you can find in our [Wiki]. Welcome to the Wiki folder!
It allows you to suggest changes through Pull request while keeping a simple way for us to maintain the wiki, without granting everyone push rights to it.
If you want to contribute towards the wiki would we highly recommend to follow the below contributing Guidelines, to keep the overal style of the wiki intact. This folder contains all the files of the [PlaceholderAPI Wiki][wiki].
It allows you to contribute towards the wiki and us to have more control about what changes are commited to it.
## Target branch ## Contrbuting to the wiki
The wiki is handled on a separate branch called `docs/wiki`. If you want to contribute towards the wiki, will you need to follow the below instructions to not get your Pull request closed without a warning.
When making a Pull request, make sure to target this specific branch. Any PR not targeting this branch may either be closed or the target changed.
## Adding your resource(s) ### Fork the Repository (Not wiki!)
When you either have a plugin, which adds and/or uses placeholders or an expansion and you want to add it to the wiki should you follow the below steps. > Already having a fork? Skip to the [next Step](#select-target-branch)!
- [Plugins using PlaceholderAPI](#plugins-using-placeholderapi) You need to make a fork of the PlaceholderAPI Repository to contribute towards the wiki.
- [Placeholders](#placeholders) To do this, click the "Fork" button on the top-right corner of the site and select the account you want your fork to be created on. This will also show you any already existing forks of this Repository that you may have.
### [Plugins using PlaceholderAPI] The forking process should only take a few seconds and you should be redirected to your fork afterwards.
This is only required for plugins.
If your plugin supports placeholders of other plugins and/or provides own placeholders through PlaceholderAPI should you always add it the the `Plugins using PlaceholderAPI` page.
Each entry on this page follows a specific format that you need to follow: ### Select target branch
All main changes to the wiki are made on the dedicated `docs/wiki` branch.
Before you try to make any changes should you make sure that you have the `docs/wiki` branch selected. To do that, check the button next to the `X branches` text. If it says anything other than `docs/wiki` will you need to click it and select the right branch.
![branch-selector]
### Fetch Changes from Upstream
This is only required when you already had a fork and didn't update it for some time.
While you're on the `docs/wiki` branch, click the `Fetch upstream` text located right below the green `Code` button.
Depending on the status of your branch can the prompt show different outcomes:
- `This branch is not behind the upstream PlaceholderAPI:docs/wiki`
Your fork's `docs/wiki` branch is up-to-date with the latest changes from Upstream (This Repository). You don't have to update anything.
![upstream_up-to-date]
- `Fetch and merge <number> upstream commits from PlaceholderAPI:docs/wiki`
This is shown when your fork's branch is outdated and upstream (This Repository) has changes. Click the `Fetch and merge` button to fetch the latest commits and update your fork's `docs/wiki` branch.
![upstream_needs_update]
### Commit changes
To commit changes will you need to choose, if you want to directly commit to your fork's `docs/wiki` branch, or make a dedicated branch for it.
#### Make separate branch (Optional)
If you want to have a dedicated branch for it, will you need to click the button saying `docs/wiki`, type in the small text field the name of the branch you want to use and click the text saying `Create branch: <branch> from 'docs/wiki'`
![create_branch]
After that should you now have a separate branch that is based of the `docs/wiki` branch and you can finally commit changes to it.
#### Formatting
The wiki uses normal Markdown formatting with some special design-rules you need to keep in mind.
These rules are as follows:
- Unordered lists need to start with a `-` and not `*`. This is to not get it confused with *italic text* which uses single `*` characters.
- New lines in lists need to keep their indends. This means you need to add two spaces at the start to keep the text in the same line.
Example:
```markdown ```markdown
- **[:name](:url)** - Line 1
- [?] Supports placeholders. Line 2
- [?] Provides own placeholders. [:link]
``` ```
- Use the `[[Page]]` and `[[Text|Page]]` format to link to other wiki pages. While those aren't rendered in the wiki folder will they render in the final wiki pages.
- External links should be set as Refernce Links, which means they are set as `[text]: link` at the top of the page and then used either through `[text]` or `[display text][text]` througout the page.
| Key | Description | #### Adding new Expansion
| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | When you add a new expansion to the wiki's [Placeholder page][placeholders] will you need to follow the following format:
| `:name` | The name of the Plugin. Plugins are ordered by alphabet and if your plugin shares the same name as another one will you need to add it **below** the other resource. |
| `:url` | The URL to your plugin. Spigot URLs should only contain the ID. E.g. https://www.spigotmc.org/resources/placeholderapi.6245/ becomes https://www.spigotmc.org/resources/6245/ |
| `?` | Should be replaced with either an `x` or a space, depending on if the option is supported. So the result is either `[x]` or `[ ]` |
| `:link` | If your plugin also provides own placeholders should you add it to the [Placeholders] page. In such a case should you use `[**[[Link\|Placeholders#:name]]**]` otherwhise just `[Link]` |
### [Placeholders]
This step is required if you either have a plugin or an expansion that provides their own placeholders. You should add your resource to the Placeholders page of the wiki.
This page is split up into two sections: PAPI Placeholders and Plugin Placeholders.
PAPI Placeholders are extensions that don't require an external plugin or other dependency to function normally. Common examples are the Player or Server extensions.
The Plugin Placeholders are extensions that require a plugin or other dependency to function. They are often used to provide values from one pluging (e.g. Vault) to another plugin through the help of PlaceholderAPI.
The syntax used for each entry is the same:
````markdown ````markdown
- ### **[:name](:url)** - ### [:name](:link)
> :command > :command
:text
``` ```
:placeholders :placeholders
``` ```
----
```` ````
| Key | Description | There are a few extra rules you need to also keep in mind:
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `:name` | The name of the resource. Resources are ordered by alphabet and if your plugin shares the same name as another one will you need to add it **below** the other resource. |
| `:url` | The URL to your plugin. Spigot URLs should only contain the ID. E.g. https://www.spigotmc.org/resources/placeholderapi.6245/ becomes https://www.spigotmc.org/resources/6245/ |
| `:command` | The download command. When your resource is an expansion on the ecloud would you need to add `/papi ecloud download :name`. If it isn't an expansion should you put `NO DOWNLOAD COMMAND` instead. |
| `:placeholders` | List of placeholders your plugin/expansion offers. The list should stay in alphabetical order. You can use `<>` and `[]` to indicate required and optional variables. |
#### Extra notes - `:name` would be the name of your Expansion, not the plugin (Unless it is integrated into your plugin).
- Only embed a link, if your Expansion requires a plugin to function.
- When linking to a Spigot page, make sure to sanitze the link.
This means that f.e. https://www.spigotmc.org/resources/placeholderapi.6245/ becomes https://www.spigotmc.org/resources/6245/
- `:command` should be replaced with either the PlaceholderAPI command to download your expansion from the eCloud (`/papi ecloud download :name`) or with `NO DOWNLOAD COMMAND` if no separate download is available.
- `:text` is optional and should only be provided to link to additional documentation, your own placeholder list, or explain more complicated placeholders/features.
- `:placeholders` will be the list of placeholders your expansion provides.
Please avoid specific examples (i.e. `%placeholder_player_user123%`) and instead use `<>` and `[]` to mark required and optional options respecively (`%placeholder_player_<player>%`)
- If your entry has another one below it will you need to add an empty line, followed by for hypthons (`----`) at the bottom of your entry to separate it. **Note:**
- You are allowed to add a description between the `> :command` and the placeholder list. Keep in mind to keep an empty line after the command line to prevent wrong formatting. A description is only useful/required if your expansion/plugin offers specific placeholder values and/or features. When your Expansion's entry is after and/or before other entries will you need to add `----` before or after it to separate it from other entries.
- Always add your entry's name to the list at the top of the page in the format `- [:name](#:name)`. Note that if your entry shares the same name as another one on the page and you added it below it, that you will need to append a `-1`, `-2`, ... to the name in the brackets, depending on how many entries with the same name there are.
##### Example:
````markdown
- ### SomeExpansion
> NO DOWNLOAD COMMAND
```
%someexpansion_placeholder%
```
---- ----
## Other Wiki pages
Please follow these general guidelines when editing any other pages.
### Links - ### YourExpansion
The wiki uses 3 types of links: > NO DOWNLOAD COMMAND
- [Reference Links](#reference-links) ```
- [Wiki Links](#wiki-links) %yourexpansion_placeholder%
- [Header Links](#header-links) ```
#### Reference Links
Reference Links are in the format `[:text]: :url` where `:text` is the name to use as reference and `:url` is the url.
These types of links are usually put at the top of the page and allow us easier updating of these links, by just altering the URL without the need to replace them in the entire file.
To use a reference link, either use `[:text]` or `[:displayed_text][:text]` to link with a differently shown text.
For example: With `[wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki` will `[wiki]` become [wiki] and `[to the wiki][wiki]` becomes [to the wiki][wiki].
Always use reference links for URLs that point outside of the Wiki. Only exceptions are Links in the [Placeholders] and [Plugins using PlaceholderAPI] page (See above for details).
#### Wiki Links
Wiki links are used to link to other pages on the wiki.
These types of links are in the format `[[:pagename]]` or `[[:text|:pagename]]` to display a different text. `:pagename` is case-sensitive.
If you want to link to a header in another wiki page can you use `[[:text|:pagename#:header]]`.
#### Header Links
Header links are used to link to a section within the same wiki page.
The format is `[:text](#:header)`. The header name is case-insensitive but it's recommended to keep it lowercase.
---- ----
### Lists
Lists should always be started with a hyphen (`-`) to better distinguish it from other formatting characters like the asterisk (`*`) used for bold or italic text.
- ### AnotherExpansion
> NO DOWNLOAD COMMAND
```
%anotherexpansion_placeholder%
```
````
After you added your expansion to this page will you also need to add an entry to the list at the top of the page.
You do so by adding `- **[:text](#:name)**` to the list, where `:text` is the text to display (Usually the name you set) and `:name` is the name you just set. If your expansion shares the exact same name as another entry on the page will you need to make sure that your expansion is listed **after** the other one AND that the list-entry has a `-1` appended to `#:name` (So f.e. `#expansion` becomes `#expansion-1`).
Finally can you now commit your changes and move forward to the [Plugins using PlaceholderAPI][using_papi] page in the wiki folder.
#### Adding new plugin
This step is only required if you either add a new plugin to the list, or you added an Expansion that is included in your own plugin.
Similar to the [Placeholders page][placeholders] does this page follow a specific format which we will explain real quick.
```markdown
- [:name](:link)
- [?] Supports placeholders.
- [?] Provides own placeholders. [:page]
```
Here are the following rules:
- `:name` needs to be replaced with the Name of your plugin.
- `:link` needs to be the link of the plugin's resource page.
- If no resource page is available can a GitHub repository be linked (if available) or the link omited altogether)
- When linking to a Spigot page, make sure to sanitze the link.
This means that f.e. https://www.spigotmc.org/resources/placeholderapi.6245/ becomes https://www.spigotmc.org/resources/6245/
- `[?]` needs to be replaced with either `[ ]` or `[x]` depending on whether the mentioned option is supported or not.
- `:page` needs to replace with the right value, depending on the conditions.
- If your plugin provides own Placeholders for other plugins to use can you set `**[[Link|Placeholders#:name]]**` where `:name` is the title you set in the placeholders page.
- If your plugin does not provide own placeholders will you need to set `Link`.
### Make a Pull request
After you made your changes is it time to make a Pull request.
When you go to the upstream repository, should GitHub already show you a notification that you have commits to PR. Click the `Compare & pull request` button to proceed.
![image](https://user-images.githubusercontent.com/11576465/132784030-c2ffd5e0-fb95-44de-bd77-97a965cc6dbd.png)
By default will GitHub select the `master` branch as the target, which is not what we want. To fix this, click the button saying `base:master` and select the `docs/wiki` branch.
![image](https://user-images.githubusercontent.com/11576465/132784142-8f752697-7dd7-4afb-bbdc-dc66c570dc3c.png)
Finally, fill out the Pull request template and submit the Pull request.
Congratulations! You've successfully made a Pull request for the wiki.
### Questions?
If you have any questions, do not hesitate to ask in the [HelpChat Discord][discord] or [open a new discussion][discussion] in this repository. We will be happy to help you.
### Credits
- The Wiki is maintained by [Andre601][andre].
- We use the [GitHub Wiki Action][action] by [Andrew-Chen-Wang][andrew] to update the PlaceholderAPI wiki through GitHub Actions.

View File

@ -7,10 +7,12 @@
### Setup ### Setup
**[[Hook into PlaceholderAPI]]** **[[Hook into PlaceholderAPI]]**
- [[First steps|Hook-into-PlaceholderAPI#first-steps]] - [[First steps|Hook-into-PlaceholderAPI#first-steps]]
- [[Adding placeholders to PlaceholderAPI|Hook-into-PlaceholderAPI#adding-placeholders-to-placeholderapi]] - [[Adding placeholders to PlaceholderAPI|PlaceholderExpansion]]
- [[PlaceholderExpansion]] - [[Common Parts|PlaceholderExpansion#common-parts]]
- [[Without an external plugin|PlaceholderExpansion#without-an-external-plugin]] - [[Without an external plugin|PlaceholderExpansion#without-a-plugin]]
- [[With external plugin|PlaceholderExpansion#with-external-plugin]] - [[With an external Plugin (Separate Jar)|PlaceholderExpansion#with-a-plugin-external-jar]]
- [[With an external Plugin (Internal class)|PlaceholderExpansion#with-a-plugin-internal-class]]
- [[Relational Placeholders|PlaceholderExpansion#relational-placeholders]]
- [[Setting placeholders in your plugin|Hook-into-PlaceholderAPI#setting-placeholders-in-your-plugin]] - [[Setting placeholders in your plugin|Hook-into-PlaceholderAPI#setting-placeholders-in-your-plugin]]
### Other ### Other
@ -19,42 +21,7 @@
**[[FAQ]]** **[[FAQ]]**
**[[Plugins using PlaceholderAPI]]** **[[Plugins using PlaceholderAPI]]**
**[[Placeholders]]** **[[Placeholders]]**
- [[PAPI-placeholders|Placeholders#papi-placeholders-1]] - [[Standalone|Placeholders#standalone]]
- [[Advancements|Placeholders#advancements]]
- [[Animations|Placeholders#animations]]
- [[Armor|Placeholders#armor]]
- [[ASCII|Placeholders#ASCII]]
- [[BungeeCord|Placeholders#bungeecord]]
- [[CheckItem|Placeholders#checkitem]]
- [[CooldownBar|Placeholders#cooldownbar]]
- [[Formatter|Placeholders#formatter]]
- [[Javascript|Placeholders#javascript]]
- [[ListPlayers|Placeholders#listplayer]]
- [[LocalTime|Placeholders#localtime]]
- [[Math|Placeholders#math]]
- [[MVdW placeholders|Placeholders#mvdw-placeholders]]
- [[OtherPlayer|Placeholders#otherplayer]]
- [[ParseNear|Placeholders#parsenear]]
- [[ParseOther|Placeholders#parseother]]
- [[Pinger|Placeholders#pinger]]
- [[Player|Placeholders#player]]
- [[PlayerList|Placeholders#playerlist]]
- [[Plugin|Placeholders#plugin]]
- [[Progress|Placeholders#progress]]
- [[RainbowColor|Placeholders#rainbowcolor]]
- [[RandomColor|Placeholders#randomcolor]]
- [[RedisBungee|Placeholders#redisbungee]]
- [[RelCon|Placeholders#relcon]]
- [[ScoreboardObjectives|Placeholders#scoreboardobjectives]]
- [[Server|Placeholders#server]]
- [[Sound|Placeholders#sound]]
- [[Spectators|Placeholders#spectators]]
- [[SpeedPerSec|Placeholders#speedpersec]]
- [[Statistic|Placeholders#statistic]]
- [[Team|Placeholders#team]]
- [[World|Placeholders#world]]
- [[Plugin-placeholders|Placeholders#plugin-placeholders-1]]
- [[A|Placeholders#a]] - [[A|Placeholders#a]]
- [[B|Placeholders#b]] - [[B|Placeholders#b]]
- [[C|Placeholders#c]] - [[C|Placeholders#c]]
@ -78,4 +45,33 @@
- [[U|Placeholders#u]] - [[U|Placeholders#u]]
- [[V|Placeholders#v]] - [[V|Placeholders#v]]
- [[W|Placeholders#w]] - [[W|Placeholders#w]]
- [[X|Placeholders#x]]
- [[Y|Placeholders#y]]
- [[Z|Placeholders#z]] - [[Z|Placeholders#z]]
- [[Plugin-placeholders|Placeholders#plugin-placeholders-1]]
- [[A|Placeholders#a-1]]
- [[B|Placeholders#b-1]]
- [[C|Placeholders#c-1]]
- [[D|Placeholders#d-1]]
- [[E|Placeholders#e-1]]
- [[F|Placeholders#f-1]]
- [[G|Placeholders#g-1]]
- [[H|Placeholders#h-1]]
- [[I|Placeholders#i-1]]
- [[J|Placeholders#j-1]]
- [[K|Placeholders#k-1]]
- [[L|Placeholders#l-1]]
- [[M|Placeholders#m-1]]
- [[N|Placeholders#n-1]]
- [[O|Placeholders#o-1]]
- [[P|Placeholders#p-1]]
- [[Q|Placeholders#q-1]]
- [[R|Placeholders#r-1]]
- [[S|Placeholders#s-1]]
- [[T|Placeholders#t-1]]
- [[U|Placeholders#u-1]]
- [[V|Placeholders#v-1]]
- [[W|Placeholders#w-1]]
- [[X|Placeholders#x-1]]
- [[Y|Placeholders#y-1]]
- [[Z|Placeholders#z-1]]