Skip to content

Developer API

ItsHarshXD edited this page Jul 22, 2024 · 13 revisions

Developer API

Caution

You need to have the latest version of the MatrixGliders JAR file for it to work properly.

MatrixGliders offers a comprehensive API for developers to integrate custom functionality into their plugins.

JavaDocs: https://matrixcreations.github.io/MatrixGliders-API
Documentation: https://github.com/MatrixCreations/MatrixGliders-API/wiki

GitHub Release

Maven Integration

  1. Add this in your dependency section

Caution

Replace "VERSION" with latest release version given up.

<dependency>
  <groupId>org.itsharshxd</groupId>
  <artifactId>matrixgliders</artifactId>
  <version>VERSION</version>
  <scope>system</scope>
  <systemPath>PATH_TO_THE_PLUGIN_JAR_WITHOUT_SPACE</systemPath>
</dependency>

Gradle Integration

  1. Add this in your dependency section

Caution

Replace "VERSION" with latest release version given up. (Don't include "v")

dependencies {
    compileOnly files('PATH_TO_THE_PLUGIN_JAR_WITHOUT_SPACE')
}

API Overview

To use the API you need to create MatrixGlidersAPI object.

In your class file add this:

MatrixGlidersAPI glidersAPI = MatrixGliders.getAPI();

Now you can access the API methods like this:

MatrixGlidersAPI glidersAPI = MatrixGliders.getAPI();
glidersAPI().startGlide(Player player);

API Events

  1. PlayerGlideEvent - Triggers when any player is in gliding state.
@EventHandler
public void whilePlayerGlide(PlayerGlideEvent event) {
  List<Player> players = event.getPlayers();
  // Do something
}
  1. GlidingStartEvent - Triggers when any player starts gliding.
@EventHandler
public void glidingStartEvent(GlidingStartEvent event) {
  Player player = event.getPlayer();
  // Do something
}
  1. GlidingEndEvent - Triggers when any player stops gliding.
@EventHandler
public void glidingEndEvent(GlidingEndEvent event) {
  Player player = event.getPlayer();
  // Get the cause, which led the player to stop gliding! It can be either "LANDING" or "DISCONNECT".
  Cause cause = event.getCause();
  if(cause.equals(Cause.DISCONNECT)) {
    // Do something
  }
}

API Methods:

void startGlide(Player player) //Starts gliding for the specified player
void stopGlide(Player player, Cause cause) //Stops gliding for the specified player
boolean isGliding(Player player) //Checks if the player is currently gliding
void addGliderToPlayer(Player player, String gliderID) //Adds a glider to the specified player
void removeGliderFromPlayer(Player player, String gliderID) //Removes a glider from the specified player
boolean hasGliderEquipped(Player player) //Checks if the specified player has a glider equipped
void wearEquippedGlider(Player player) //Equips the glider for the specified player
void equipGliderToConfig(Player player, String gliderID) //Equips a glider to the config for the specified player
void disrobeEquippedGlider(Player player) //Disrobes the equipped glider for the specified player
void unequipGliderFromConfig(Player player) //Unequips a glider from the config for the specified player
boolean isValidGliderID(String gliderID) //Checks if the specified glider ID is valid
List<String> getTotalGliders() //Gets the list of all gliders
List<String> getPlayerGliders(Player player) //Gets the list of gliders for the specified player
Sound getGliderSound(String gliderID) //Gets sound string for the specified glider
void playSound(Player player) //Plays the sound which is associated with the glider if any
Clone this wiki locally