Hook into Parties

Parties offers a rich API for every kind of operation.

You can find some API access examples here!

Implements Parties

If you are using Maven, just put this into your pom.xml:

<repositories>
  <repository>
    <id>alessiodp-repo</id>
    <url>https://repo.alessiodp.com/</url>
  </repository>
</repositories>
 
<dependencies>
  <dependency>
    <groupId>com.alessiodp.partiesapi</groupId>
    <artifactId>parties-api</artifactId>
    <version>2.2.2</version>
  </dependency>
</dependencies>

Otherwise, you need to insert latest Parties into your Build Path.

Open plugin.yml and insert Parties as depend (or soft-depend):

depend: [Parties]
soft-depend: [Parties]


Before hook into it, be sure Parties is enabled!

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


API Methods

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

PartiesAPI api = Parties.getApi();
String partyDescription = ""; // Now we will try to get the party description
PartyPlayer player = api.getPartyPlayer(simplePlayer.getUniqueId()); // Get the player
if (!player.getPartyName().isEmpty()) {
  Party party = api.getParty(player.getPartyName()); // Get the party by its name
  if (party != null) {
    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(PartiesChatEvent event) {
    if (event.getMessage().equals("nope!"))
        event.setCancelled(true);
}

You can read about events here.