Updated APIv5 (markdown)

Risto Lahtela 2019-03-31 16:28:41 +03:00
parent cb58cce01b
commit 94f47c3bc8
1 changed files with 47 additions and 5 deletions

@ -94,9 +94,7 @@ Every `DataExtension` implementation **requires** `@PluginInfo` annotation.
name* = "Your Plugin",
iconName = "cube"
iconFamily = Family.SOLID,
color = Color.NONE,
updatePlayerDataOnLeave = false,
updateServerDataPeriodically = false
color = Color.NONE
)
public class YourExtension implements DataExtension {}
```
@ -105,8 +103,6 @@ public class YourExtension implements DataExtension {}
- `iconName` - Icon names can be found from https://fontawesome.com/icons?d=gallery&m=free
- `iconFamily` - Icon family should match details on the site above
- `color` - Colors are available here *Link to be added*
- `updatePlayerDataOnLeave` - Provider methods about players will also be called when the player leaves the server. By default the player methods are called shortly after the player joins.
- `updateServerDataPeriodically` - Provider methods about server will also be called periodically. By default the server methods are called shortly after registering the `DataExtension`.
</details>
@ -127,6 +123,52 @@ T method(String playerName); // The value is about a player
T method(Group group); // The value is about a Group a player is in
```
<details>
<summary>Controlling when Plan calls your DataExtension methods</summary>
```
@Override
public CallEvents[] callExtensionMethodsOn() {
return new CallEvents[]{
CallEvents.PLAYER_JOIN,
CallEvents.PLAYER_LEAVE,
CallEvents.SERVER_EXTENSION_REGISTER,
CallEvents.SERVER_PERIODICAL
};
}
```
- `DataExtension#callExtensionMethodsOn` can be overridden to change default event call behavior.
- Explanations
- Empty array: Plan will not call the methods automatically, see below for manual calls.
- `PLAYER_JOIN`: Plan calls player methods after a Join event (Bukkit/Bungee: MONITOR, Sponge: POST)
- `PLAYER_LEAVE`: Plan calls player methods after a Quit event (Bukkit/Bungee: NORMAL, Sponge: DEFAULT)
- `SERVER_EXTENSION_REGISTER` Plan calls server methods after registering the `DataExtension`
- `SERVER_PERIODICAL` Plan calls server methods periodically via a task
</details>
<details>
<summary>Manual update calls</summary>
```
DataExtension yourExtension;
Optional<Caller> caller = extensionService.register(yourExtension);
```
- `ExtensionService#register` returns a `Optional<Caller>`. The Caller is present if the extension was registered.
- You can use the `Caller` methods in your listeners when your data is updated.
> **HOX** Do not use `Caller` inside `DataExtension` - This might lead to unbound recursion!
```
Caller caller;
caller.updatePlayerData(playerUUID, playerName);
caller.updateServerData();
```
</details>
### `@BooleanProvider`
**Speciality:** `boolean` values, Can work with `@Conditional`-annotation for conditional execution