ModsJava
PlayerActionsAPI
Player Actions API allows to transform a string list into a list of actions
⬇ Download on HangarOpen in MCModsHubGet it on Google Play →## **PlayerActionsAPI**
Player Actions API allows to transform a string list into a list of actions, send a message to the player, execute a command in the console etc. This API uses the same syntax as DeluxeMenu.
## **Actions**
**Action** **Description**
* **[broadcast]** Broadcast a message to the server.
* **[chat]** Send a chat message as the player performing the action.
* **[close]** Close the viewers open menu.
* **[console**] Execute a command from the console.
* **[message**] Send a message to the menu viewer.
* **[player]** Execute a command from the player.
You can add a tick delay to your action by using this: You must set the delay after defining the action to perform.
Example
```yaml
commands:
- "[console] give %player% diamond"
- "[message] &bAction &f&l» &fExample message"
```
## **Developer**
JitPack: [https://jitpack.io/#Maxlego08/PlayerActionsAPI](https://jitpack.io/#Maxlego08/PlayerActionsAPI)
### **Maven**
```
jitpack.io
https://jitpack.io
com.github.Maxlego08
PlayerActionsAPI
{version}
```
## **Gradle**
```
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Maxlego08:PlayerActionsAPI:{version}'
}
```
Do not forget to relocate the sources so as not to complicate with other plugin.
### **How to use**
This configuration allows to execute a command and after a delay of 10 tickets to send a message
```yaml
commands:
- "[console] give %player% diamond"
- "[message] &bAction &f&l» &fExample message"
```
**Load Actions**
The first step and turn your string list into an action list.
```java
public class Example extends JavaPlugin {
@Override
public void onEnable() {
List commands = getConfig().getStringList("commands");
List actions = ActionsAPI.loadActions(commands);
}
}
```
**Use actions**
To use the actions just run the execute method. The method requires a plugin and a player.
```java
public class Example extends JavaPlugin {
public void execute(List actions, Player player) {
actions.forEach(command -> command.execute(this, player));
}
}
```
PlayerActionsAPI is a free Minecraft Java mod. Compatible with Minecraft 1.10, 1.10.1, 1.10.2, 1.11 and newer. Downloaded 9 times (via Hangar). Download it and open it directly in the game.
Explore more