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.
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]].
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.
All shown examples will share the same common parts that belong to the [`PlaceholderExpansion`][placeholderexpansion] class.
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.
If you want to use `_` in your expansion's name, you can override the optional `getName()` method.
- #### 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.
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.
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.
Your expansion will need to override the `getRequiredPlugin()` method to return the name of the plugin your expansion depends on.
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
SomePlugin plugin; // This would be the plugin your expansion depends on
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.
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.