Hook into Parties

Parties offers a rich API for every kind of operation.

You can find some API access examples here!

Importing Parties

Maven

<repositories>
  <repository>
    <id>codemc-repo</id>
    <url>https://repo.codemc.org/repository/maven-public/</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>com.alessiodp.parties</groupId>
    <artifactId>parties-api</artifactId>
    <version>2.6.1</version>
  </dependency>
</dependencies>

Gradle

repositories {
    maven {
        name = 'codemc-repo'
        url = 'https://repo.codemc.org/repository/maven-public/'
    }
}

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

Implementing Parties

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

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

Before hook into it, be sure its 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(BukkitPartiesChatEvent event) {
    if (event.getMessage().equals("nope!"))
        event.setCancelled(true);
}

You can read about events here.