Welcome to the Hangar Open Beta. Please report any issue you encounter on GitHub!
Avatar for Maxlego08

Player Actions API allows to transform a string list into a list of actions

Report PlayerActionsAPI?

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: delay:{ticks} You must set the delay after defining the action to perform.

Example


commands:
   - "[console] give %player% diamond"
  - "[message] <delay:10> &bAction &f&l» &fExample message"

Developer

JitPack: https://jitpack.io/#Maxlego08/PlayerActionsAPI

Maven


<repositories>
   <repository>
       <id>jitpack.io</id>
       <url>https://jitpack.io</url>
   </repository>
</repositories>
<dependency>
   <groupId>com.github.Maxlego08</groupId>
   <artifactId>PlayerActionsAPI</artifactId>
   <version>{version}</version>
</dependency>

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


commands:
  - "[console] give %player% diamond"
  - "[message] <delay:10> &bAction &f&l» &fExample message"

Load Actions

The first step and turn your string list into an action list.


public class Example extends JavaPlugin {

   @Override
   public void onEnable() {
       List<String> commands = getConfig().getStringList("commands");
       List<Action> actions = ActionsAPI.loadActions(commands);
   }
}

Use actions

To use the actions just run the execute method. The method requires a plugin and a player.


public class Example extends JavaPlugin {
  
   public void execute(List<Action> actions, Player player) {
      actions.forEach(command -> command.execute(this, player));
   }
}

Information

CategoryDeveloper Tools
Published onJuly 31, 2024
LicenseUnspecified
Downloads8
Stars0
Watchers0
Library

Pinned Versions

Members