Discord

Hook into Parties

Parties offers a developer API to handle Parties data and information about players and parties. Whenever something will change in the future it will be deprecated then deleted with future updates, so never use deprecated methods.

You can find some API access examples here!

Importing Parties

To add the API to your project you can use use Maven, Gradle or manual adding in classpath.

Maven

<repositories>
  <repository>
    <id>alessiodp-repo</id>
    <url>https://repo.alessiodp.com/releases/</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>com.alessiodp.parties</groupId>
    <artifactId>parties-api</artifactId>
    <version>3.2.15</version>
    <scope>provided</scope>
  </dependency>
</dependencies>

Gradle

repositories {
    maven {
        name = 'alessiodp-repo'
        url = 'https://repo.alessiodp.com/releases/'
    }
}

dependencies {
    compileOnly group: 'com.alessiodp.parties', name: 'parties-api', version: '3.2.15'
}

Usage

Your plugin must loaded after Parties so you have to define this behavior in plugin.yml of your plugin by inserting Parties as depend (or soft-depend):

depend: [Parties]
softdepend: [Parties]

Before hook into it, be sure its enabled!

if (getServer().getPluginManager().getPlugin("Parties") != null) {
    if (getServer().getPluginManager().getPlugin("Parties").isEnabled()) {
        // Parties is enabled
    }
}

Then you can take the instance of Parties:

PartiesAPI api = Parties.getApi();

API Methods

Parties offers a class called PartiesAPI, you can declare it to call API methods. This is how you can use it:

PartiesAPI api = Parties.getApi();
String partyDescription = null; // Now we will try to get the party description
PartyPlayer player = api.getPartyPlayer(simplePlayer.getUniqueId()); // Get the player
if (player.isInParty()) {
  Party party = api.getParty(player.getPartyId()); // Get the party by its ID
  if (party != null) { // Always check nullness for security purpose
    partyDescription = party.getDescription(); // Get the party description
  }
}

Every method is documented, you can read about methods here.

Event handlers

Parties offers some events open to handle, you can hook into them like every Bukkit listener.

@EventHandler
public void onPlayerChat(BukkitPartiesPartyPreChatEvent event) {
    if (event.getMessage().equals("nope!"))
        event.setCancelled(true);
}

You can read about events here.

JavaDoc

You can find the JavaDoc here.

Example project

You can find an example project here to see how to implement Parties is a Bukkit/BungeeCord plugin.