### Event Handling Example Source: https://github.com/alessiodp/parties/wiki/API-Events Demonstrates how to listen to a Parties event and cancel it if a specific condition is met. ```APIDOC ## Event Handling ### Description Developers can handle Parties events using the standard Bukkit `@EventHandler` annotation. Events may support cancellation or data modification. ### Example ```java @EventHandler public void onPlayerChat(PartiesChatEvent event) { if (event.getMessage().equals("nope!")) event.setCancelled(true); } ``` ``` -------------------------------- ### Get party information upon creation Source: https://github.com/alessiodp/parties/wiki/API-Examples Demonstrates how to access party details within a post-creation event listener. ```java @EventHandler public void onPartyCreate(PartiesPartyPostCreateEvent event) { PartiesAPI api = Parties.getApi(); String partyName = event.getPartyName(); String description = api.getPartyDescription(partyName); String prefix = api.getPartyPrefix(partyName); // etc.. } ``` -------------------------------- ### Get party description Source: https://github.com/alessiodp/parties/wiki/API-Examples Retrieves the description string for a party by its name. ```java PartiesAPI api = Parties.getApi(); String partyName = api.getPartyDescription("partyName"); ``` -------------------------------- ### Get online parties Source: https://github.com/alessiodp/parties/wiki/API-Examples Retrieves a list of all currently active parties. ```java PartiesAPI api = Parties.getApi(); List list = api.getOnlineParties(); ``` -------------------------------- ### Check for Parties Plugin Enablement Source: https://github.com/alessiodp/parties/wiki/Hook-into-Parties Verify that the Parties plugin is installed and enabled before attempting to hook into its API. ```java if (getServer().getPluginManager().getPlugin("Parties") != null) { if (getServer().getPluginManager().getPlugin("Parties").isEnabled()) { // Parties is enabled } } ``` -------------------------------- ### Get player party Source: https://github.com/alessiodp/parties/wiki/API-Examples Retrieves the name of the party a specific player belongs to using their UUID. ```java Player somePlayer; PartiesAPI api = Parties.getApi(); String partyName = api.getPartyName(yourPlayerUUID); ``` -------------------------------- ### Create Parties Table Source: https://github.com/alessiodp/parties/wiki/SQL-structures Stores party configuration and metadata. ```sql CREATE TABLE %tableName% (name VARCHAR(255) NOT NULL, leader VARCHAR(255) NOT NULL, descr VARCHAR(255) DEFAULT '', motd VARCHAR(255) DEFAULT '', prefix VARCHAR(255) DEFAULT '', suffix VARCHAR(255) DEFAULT '', color VARCHAR(255) DEFAULT '', kills INT DEFAULT 0, password VARCHAR(255) DEFAULT '', home VARCHAR(255) DEFAULT '', PRIMARY KEY (name)) COMMENT='Database version (do not edit):%tableVersion%'; ``` -------------------------------- ### Initialize and Use PartiesAPI Source: https://github.com/alessiodp/parties/wiki/Hook-into-Parties Access the PartiesAPI instance to retrieve party information for a specific player. ```java PartiesAPI api = Parties.getApi(); String partyName = api.getPartyName(simplePlayer.getUniqueId()); // Get the party name of a player String partyDescription = ""; if (!partyName.isEmpty()) // Check if the player have a party partyDescription = api.getPartyDescription(partyName); // Get the party description ``` -------------------------------- ### Create Players Table Source: https://github.com/alessiodp/parties/wiki/SQL-structures Stores information about players currently in a party. ```sql CREATE TABLE %tableName% (uuid VARCHAR(255) NOT NULL, party VARCHAR(255) NOT NULL, rank INT DEFAULT 0, name VARCHAR(255), timestamp INT, PRIMARY KEY (uuid)) COMMENT='Database version (do not edit):%tableVersion%'; ``` -------------------------------- ### Configure Maven Dependencies Source: https://github.com/alessiodp/parties/wiki/Hook-into-Parties Add the alessiodp repository and the parties-api dependency to your pom.xml file. ```xml alessiodp-repo http://repo.alessiodp.com/ com.alessiodp.partiesapi parties-api 2.1.2 ``` -------------------------------- ### createParty(UUID leaderUUID, String partyName) Source: https://github.com/alessiodp/parties/wiki/API-Examples Attempts to create a new party with the specified leader and name. ```APIDOC ## createParty(UUID leaderUUID, String partyName) ### Description Creates a new party. Returns a Status enum indicating success or failure (e.g., ALREADYINPARTY, ALREADYEXISTPARTY). ### Signature `Status createParty(UUID leaderUUID, String partyName)` ### Parameters - **leaderUUID** (UUID) - Required - The UUID of the player who will lead the party. - **partyName** (String) - Required - The name for the new party. ``` -------------------------------- ### Create a party Source: https://github.com/alessiodp/parties/wiki/API-Examples Attempts to create a new party and handles the resulting status, including error cases like existing parties. ```java PartiesAPI api = Parties.getApi(); Status status = api.createParty(leaderUUID, "partyName"); if (status == Status.SUCCESS) { // Party created } else { // Something gone wrong switch (status) { case ALREADYINPARTY: // Player already has a party case ALREADYEXISTPARTY: // Party already exists } } ``` -------------------------------- ### Create Spies Table Source: https://github.com/alessiodp/parties/wiki/SQL-structures Stores player data for the spy feature. ```sql CREATE TABLE %tableName% (uuid VARCHAR(255) NOT NULL, PRIMARY KEY (uuid)) COMMENT='Database version (do not edit):%tableVersion%'; ``` -------------------------------- ### Create Log Table Source: https://github.com/alessiodp/parties/wiki/SQL-structures Stores log messages generated by the plugin. ```sql CREATE TABLE %tableName% (id INT NOT NULL AUTO_INCREMENT, date DATETIME, level TINYINT, position VARCHAR(50), message VARCHAR(255), PRIMARY KEY (id)) COMMENT='Database version (do not edit):%tableVersion%'; ``` -------------------------------- ### getPartyDescription(String partyName) Source: https://github.com/alessiodp/parties/wiki/API-Examples Retrieves the description of a specific party by its name. ```APIDOC ## getPartyDescription(String partyName) ### Description Retrieves the description string for the specified party. ### Signature `String getPartyDescription(String partyName)` ### Parameters - **partyName** (String) - Required - The name of the party. ``` -------------------------------- ### Enable debug logging in config.yml Source: https://github.com/alessiodp/parties/wiki/How-to-report-a-bug Update the log settings in the configuration file to ensure detailed output is captured for debugging. ```yaml log-storage-type: yaml ... log-settings: format: "%date% [%time%] (%level%) {%position%} %message%" chat: true print-console: true log-level: 3 ``` -------------------------------- ### getOnlineParties() Source: https://github.com/alessiodp/parties/wiki/API-Examples Retrieves a list of all currently online parties. ```APIDOC ## getOnlineParties() ### Description Returns a list of names of all parties currently online. ### Signature `List getOnlineParties()` ``` -------------------------------- ### Handle Parties Events Source: https://github.com/alessiodp/parties/wiki/API-Events Use the @EventHandler annotation to listen for Parties events, similar to standard Bukkit event handling. ```java @EventHandler public void onPlayerChat(PartiesChatEvent event) { if (event.getMessage().equals("nope!")) event.setCancelled(true); } ``` -------------------------------- ### getPartyName(UUID playerUUID) Source: https://github.com/alessiodp/parties/wiki/API-Examples Retrieves the name of the party that the specified player belongs to. ```APIDOC ## getPartyName(UUID playerUUID) ### Description Retrieves the name of the party associated with the given player UUID. ### Signature `String getPartyName(UUID playerUUID)` ### Parameters - **playerUUID** (UUID) - Required - The unique identifier of the player. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.