### Get Party Description using Parties API Source: https://github.com/alessiodp/parties/wiki/API-Examples Fetches the description of a party given its name using the Parties API. Requires the Parties API instance and the party name as input. ```java PartiesAPI api = Parties.getApi(); String partyName = api.getPartyDescription("partyName"); ``` -------------------------------- ### Handle Party Creation Event with Parties API Source: https://github.com/alessiodp/parties/wiki/API-Examples An event handler for when a party is created, allowing retrieval of party details like name, description, and prefix using the Parties API. This is useful for reacting to party creation events in real-time. ```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 Parties API Instance (Java) Source: https://context7.com/alessiodp/parties/llms.txt Retrieves the main PartiesAPI instance, which is the entry point for all programmatic interactions with the Parties plugin. It's crucial to check if the plugin is enabled before attempting to access the API. ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.PartiesAPI; // Check if Parties plugin is enabled before accessing API if (getServer().getPluginManager().getPlugin("Parties") != null) { if (getServer().getPluginManager().getPlugin("Parties").isEnabled()) { PartiesAPI api = Parties.getApi(); // API is ready to use } } ``` -------------------------------- ### Check if Parties Plugin is Enabled Source: https://github.com/alessiodp/parties/wiki/Hook-into-Parties This Java code demonstrates how to check if the 'Parties' plugin is installed and enabled on the server. This is a prerequisite before hooking into its functionalities. ```java if (getServer().getPluginManager().getPlugin("Parties") != null) { if (getServer().getPluginManager().getPlugin("Parties").isEnabled()) { // Parties is enabled } } ``` -------------------------------- ### Create a Party using Parties API Source: https://github.com/alessiodp/parties/wiki/API-Examples Creates a new party with a specified leader and party name using the Parties API. It returns a status indicating success or failure, with specific error codes for existing parties or players already in a party. ```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 } } ``` -------------------------------- ### Get Online Parties List using Parties API Source: https://github.com/alessiodp/parties/wiki/API-Examples Retrieves a list of all currently online parties using the Parties API. This function returns a list of strings, where each string is the name of an online party. ```java PartiesAPI api = Parties.getApi(); List list = api.getOnlineParties(); ``` -------------------------------- ### Get Party Information (Java) Source: https://context7.com/alessiodp/parties/llms.txt Shows how to retrieve party details using various identifiers such as party name, unique ID, or by querying the party a specific player belongs to. Provides access to party name, description, member count, level, and experience. ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.PartiesAPI; import com.alessiodp.parties.api.interfaces.Party; import java.util.UUID; PartiesAPI api = Parties.getApi(); // Get party by name Party partyByName = api.getParty("MyAwesomeParty"); if (partyByName != null) { System.out.println("Party found: " + partyByName.getName()); System.out.println("Description: " + partyByName.getDescription()); System.out.println("Members: " + partyByName.getMembers().size()); System.out.println("Level: " + partyByName.getLevel()); System.out.println("Experience: " + partyByName.getExperience()); System.out.println("Kills: " + partyByName.getKills()); } // Get party by UUID UUID partyId = partyByName.getId(); Party partyById = api.getParty(partyId); // Get party of a specific player UUID playerUUID = player.getUniqueId(); Party playerParty = api.getPartyOfPlayer(playerUUID); if (playerParty != null) { System.out.println("Player is in party: " + playerParty.getName()); } ``` -------------------------------- ### Get Player Party Name using Parties API Source: https://github.com/alessiodp/parties/wiki/API-Examples Retrieves the name of the party a player belongs to using the Parties API. Requires a Player object and the Parties API instance. ```java Player somePlayer; PartiesAPI api = Parties.getApi(); String partyName = api.getPartyName(yourPlayerUUID); ``` -------------------------------- ### List Parties with Pagination (Java) Source: https://context7.com/alessiodp/parties/llms.txt This code demonstrates how to retrieve sorted lists of parties with pagination support using the Parties API. It covers getting online parties and retrieving parties sorted by name, member count, online member count, kills, and experience, with specified page sizes and offsets. Dependencies include the Parties API library and Java's LinkedList and List classes. ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.*; import java.util.LinkedList; import java.util.List; PartiesAPI api = Parties.getApi(); // Get online parties List onlineParties = api.getOnlineParties(); System.out.println("Currently online parties: " + onlineParties.size()); // Get parties sorted by name (with pagination) int pageSize = 10; int offset = 0; // First page LinkedList byName = api.getPartiesListByName(pageSize, offset); // Get parties sorted by member count LinkedList byMembers = api.getPartiesListByMembers(pageSize, offset); // Get parties sorted by online member count LinkedList byOnline = api.getPartiesListByOnlineMembers(pageSize, offset); // Get parties sorted by kills LinkedList byKills = api.getPartiesListByKills(pageSize, offset); // Get parties sorted by experience LinkedList byExp = api.getPartiesListByExperience(pageSize, offset); // Example: Display leaderboard System.out.println("=== Top Parties by Kills ==="); for (Party p : byKills) { System.out.println(p.getName() + " - " + p.getKills() + " kills"); } ``` -------------------------------- ### Get Party Information using Parties API Source: https://github.com/alessiodp/parties/wiki/Hook-into-Parties This Java snippet shows how to obtain an instance of the PartiesAPI and use it to retrieve a player's party name and description. It includes checks for whether the player is in a party. ```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 ``` -------------------------------- ### Manage Party Leadership and Ranks (Java) Source: https://context7.com/alessiodp/parties/llms.txt This code manages party leadership, fixed parties, and rank systems using the Parties API. It includes functions to get and change the party leader, check and toggle the fixed status of a party, and retrieve information about available ranks and their permissions. It requires the Parties API library and Java's Set and UUID classes. ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.*; import java.util.Set; import java.util.UUID; PartiesAPI api = Parties.getApi(); Party party = api.getParty("MyAwesomeParty"); // Get current leader UUID leaderUUID = party.getLeader(); System.out.println("Leader UUID: " + leaderUUID); // Change party leader PartyPlayer newLeader = api.getPartyPlayer(newLeaderUUID); party.changeLeader(newLeader); // Check if party is fixed (permanent, no leader required) boolean isFixed = party.isFixed(); // Toggle fixed status party.setFixed(true, null); // Make fixed party.setFixed(false, newLeader); // Make normal with new leader // Get available ranks Set ranks = api.getRanks(); for (PartyRank rank : ranks) { System.out.println("Rank: " + rank.getName()); System.out.println(" Level: " + rank.getLevel()); System.out.println(" Chat format: " + rank.getChat()); System.out.println(" Is default: " + rank.isDefault()); System.out.println(" Permissions: " + rank.getPermissions()); // Check if rank has a specific permission if (rank.havePermission("party.invite")) { System.out.println(" Can invite players"); } } ``` -------------------------------- ### Create Party (Java) Source: https://context7.com/alessiodp/parties/llms.txt Demonstrates how to create a new party, either with a specified leader or as a 'fixed' party that persists without members. Party names must be unique. ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.PartiesAPI; import com.alessiodp.parties.api.interfaces.PartyPlayer; import java.util.UUID; PartiesAPI api = Parties.getApi(); // Get the player who will be the leader UUID playerUUID = player.getUniqueId(); PartyPlayer partyPlayer = api.getPartyPlayer(playerUUID); // Create a party with a leader boolean success = api.createParty("MyAwesomeParty", partyPlayer); if (success) { player.sendMessage("Party created successfully!"); } else { player.sendMessage("Failed to create party - name may already exist or player is in a party"); } // Create a fixed party (no leader required) boolean fixedPartyCreated = api.createParty("PermanentParty", null); ``` -------------------------------- ### Manage Party Experience and Leveling (Java) Source: https://context7.com/alessiodp/parties/llms.txt This snippet demonstrates how to manage party experience points and track leveling progress using the Parties API. It covers retrieving current experience and level, calculating level progress, awarding experience, setting experience directly, and tracking kills. Dependencies include the Parties API library. ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.*; PartiesAPI api = Parties.getApi(); Party party = api.getParty("MyAwesomeParty"); // Get current experience and level double totalExp = party.getExperience(); int level = party.getLevel(); System.out.println("Party Level: " + level + " (Total XP: " + totalExp + ")"); // Get level progress double levelExp = party.getLevelExperience(); // Total XP needed for current level double currentProgress = party.getLevelUpCurrent(); // XP earned in current level double xpNeeded = party.getLevelUpNecessary(); // XP needed to level up System.out.println("Progress: " + currentProgress + "/" + xpNeeded); // Give experience to the party party.giveExperience(500.0); // With gain message party.giveExperience(250.0, false); // Without gain message // Set experience directly party.setExperience(10000.0); // Track kills int kills = party.getKills(); party.setKills(kills + 1); ``` -------------------------------- ### Implement Parties using Maven Source: https://github.com/alessiodp/parties/wiki/Hook-into-Parties This snippet shows how to add the Parties API as a dependency in your Maven project's pom.xml file. It includes the repository configuration and the dependency declaration. ```xml alessiodp-repo http://repo.alessiodp.com/ com.alessiodp.partiesapi parties-api 2.1.2 ``` -------------------------------- ### Handle Party Creation Events - Java Source: https://context7.com/alessiodp/parties/llms.txt Listen for pre-creation and post-creation events to add custom logic. This includes validating party names, modifying them before creation, and logging creation details. Dependencies include Bukkit API and AlessioDP Parties API. ```java import com.alessiodp.parties.api.events.bukkit.party.BukkitPartiesPartyPreCreateEvent; import com.alessiodp.parties.api.events.bukkit.party.BukkitPartiesPartyPostCreateEvent; import com.alessiodp.parties.api.interfaces.PartyPlayer; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; public class PartyCreateListener implements Listener { @EventHandler public void onPartyPreCreate(BukkitPartiesPartyPreCreateEvent event) { PartyPlayer creator = event.getPartyPlayer(); String partyName = event.getPartyName(); // Validate party name if (partyName != null && partyName.contains("bad")) { event.setCancelled(true); return; } // Modify party name before creation if (partyName != null) { event.setPartyName(partyName.toUpperCase()); } // Check if it's a fixed party if (event.isFixed()) { System.out.println("Creating fixed party: " + partyName); } } @EventHandler public void onPartyPostCreate(BukkitPartiesPartyPostCreateEvent event) { // Party has been created successfully String partyName = event.getParty().getName(); PartyPlayer creator = event.getPartyPlayer(); System.out.println("Party '" + partyName + "' was created by " + (creator != null ? creator.getName() : "system")); } } ``` -------------------------------- ### Manage Party Members (Java) Source: https://context7.com/alessiodp/parties/llms.txt Provides methods for managing party members, including direct addition, inviting players, removing members, checking party capacity, retrieving online members, and verifying if two players are in the same party. Supports accepting or denying invitations. ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.*; import java.util.Set; import java.util.UUID; PartiesAPI api = Parties.getApi(); Party party = api.getParty("MyAwesomeParty"); PartyPlayer playerToAdd = api.getPartyPlayer(newPlayerUUID); // Add a member directly boolean added = party.addMember(playerToAdd); if (added) { System.out.println("Player added to party"); } // Invite a player to the party PartyPlayer inviter = api.getPartyPlayer(inviterUUID); PartyInvite invite = party.invitePlayer(playerToAdd, inviter); // Player can accept or deny the invite invite.accept(); // or invite.deny(); // Remove a member boolean removed = party.removeMember(playerToAdd); // Check if party is full if (party.isFull()) { System.out.println("Party has reached maximum capacity"); } // Get online members Set onlineMembers = party.getOnlineMembers(); for (PartyPlayer member : onlineMembers) { System.out.println("Online: " + member.getName()); } // Get all member UUIDs Set allMembers = party.getMembers(); System.out.println("Total members: " + allMembers.size()); // Check if two players are in the same party boolean sameParty = api.areInTheSameParty(player1UUID, player2UUID); ``` -------------------------------- ### Configure Debug Logging in config.yml Source: https://github.com/alessiodp/parties/wiki/How-to-report-a-bug This snippet shows how to configure the logging settings in the `config.yml` file to enable debug logging. It specifies the log storage type, format, and levels for console and chat output. Ensure this configuration is applied before attempting to replicate a bug. ```yaml log-storage-type: yaml ... log-settings: format: "%date% [%time%] (%level%) {%position%} %message%" chat: true print-console: true log-level: 3 ``` -------------------------------- ### Handle Player Join/Leave Events - Java Source: https://context7.com/alessiodp/parties/llms.txt Monitor player join and leave events to trigger custom actions. This includes sending welcome messages, logging leave events, and preventing kicks during specific in-game events. Dependencies include Bukkit API and AlessioDP Parties API. ```java import com.alessiodp.parties.api.events.bukkit.player.BukkitPartiesPlayerPostJoinEvent; import com.alessiodp.parties.api.events.bukkit.player.BukkitPartiesPlayerPreLeaveEvent; import com.alessiodp.parties.api.enums.JoinCause; import com.alessiodp.parties.api.enums.LeaveCause; import com.alessiodp.parties.api.interfaces.*; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; public class PartyMemberListener implements Listener { @EventHandler public void onPlayerJoin(BukkitPartiesPlayerPostJoinEvent event) { PartyPlayer player = event.getPartyPlayer(); Party party = event.getParty(); JoinCause cause = event.getCause(); String joinMethod = switch (cause) { case INVITE -> "accepted an invite"; case JOIN -> "joined directly"; case ASK -> "request was accepted"; case LEADER -> "created the party"; default -> "joined"; }; PartyPlayer inviter = event.getInviter(); if (inviter != null) { System.out.println(player.getName() + " was invited by " + inviter.getName()); } // Welcome message party.broadcastMessage("&aWelcome " + player.getName() + " to the party!", null); } @EventHandler public void onPlayerPreLeave(BukkitPartiesPlayerPreLeaveEvent event) { PartyPlayer player = event.getPartyPlayer(); Party party = event.getParty(); LeaveCause cause = event.getCause(); // Prevent kicks during events if (cause == LeaveCause.KICK && isEventActive()) { event.setCancelled(true); return; } // Log the leave System.out.println(player.getName() + " is leaving party " + party.getName() + " (cause: " + cause + ")"); } private boolean isEventActive() { return false; // Your event check logic } } ``` -------------------------------- ### Add Parties API as Maven/Gradle Dependency Source: https://context7.com/alessiodp/parties/llms.txt Instructions for adding the Parties API as a dependency in Maven and Gradle projects. This is essential for developing plugins that interact with the Parties system. It specifies the repository and artifact coordinates. ```xml alessiodp-repo https://repo.alessiodp.com/releases/ com.alessiodp.parties parties-api 3.2.17 provided ``` ```groovy // Gradle build.gradle repositories { maven { url 'https://repo.alessiodp.com/releases/' } } dependencies { compileOnly 'com.alessiodp.parties:parties-api:3.2.17' } ``` ```yaml # plugin.yml - Add Parties as dependency name: MyPlugin version: 1.0 main: com.example.MyPlugin depend: [Parties] # Hard dependency # OR soft-depend: [Parties] # Optional dependency ``` -------------------------------- ### Create Parties Table - SQL Source: https://github.com/alessiodp/parties/wiki/SQL-structures Defines the SQL structure for the 'Parties' table, used to store information about each party. It includes columns for party name, leader, description, message of the day, prefixes, suffixes, colors, kills, passwords, and home location. ```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%'; ``` -------------------------------- ### Configure Party Settings Source: https://context7.com/alessiodp/parties/llms.txt Modify party properties including description, tag, MOTD, password, color, and protection settings. Requires the Parties API. ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.*; import java.util.Set; PartiesAPI api = Parties.getApi(); Party party = api.getParty("MyAwesomeParty"); // Set party description and MOTD party.setDescription("An awesome guild for adventurers!"); party.setMotd("Welcome! Check /party info for rules."); // Set party tag (short identifier) party.setTag("AWE"); // Manage party password party.setPasswordUnhashed("secretpass123"); // Plugin will hash it String hashedPassword = party.getPassword(); // Set party as open (anyone can join without invite) party.setOpen(true); boolean isOpen = party.isOpen(); // Enable friendly fire protection party.setProtection(true); boolean isProtected = party.isFriendlyFireProtected(); // Set party color Set availableColors = api.getColors(); for (PartyColor color : availableColors) { if (color.getName().equals("Red")) { party.setColor(color); break; } } PartyColor currentColor = party.getColor(); // Rename the party party.rename("NewPartyName"); // Delete the party party.delete(); ``` -------------------------------- ### Broadcast Messages to Party Members (Java) Source: https://context7.com/alessiodp/parties/llms.txt This snippet shows how to broadcast messages to all members of a party using the Parties API, with support for placeholders. It allows broadcasting messages from a specific player (utilizing their placeholders) or as a general server message. Dependencies include the Parties API library. ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.*; PartiesAPI api = Parties.getApi(); Party party = api.getParty("MyAwesomeParty"); PartyPlayer sender = api.getPartyPlayer(senderUUID); // Broadcast a message from a specific player (uses player's placeholders) party.broadcastMessage("&aAnnouncement: Meeting at spawn in 5 minutes!", sender); // Broadcast a general message (no player context) party.broadcastMessage("&cServer restart in 10 minutes!", null); ``` -------------------------------- ### Party Configuration and Settings Source: https://context7.com/alessiodp/parties/llms.txt Modify core party properties such as description, tag, MOTD, password, color, and protection settings. ```APIDOC ## Party Configuration and Settings ### Description Modify party properties including description, tag, MOTD, password, color, and protection settings. ### Method GET, POST, PUT, DELETE (Implicit through API calls) ### Endpoint `/api/parties/{partyId}` (Conceptual) ### Parameters #### Path Parameters - **partyId** (String) - Required - The identifier of the party to modify. #### Query Parameters None #### Request Body None (Operations are performed via API methods) ### Request Example ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.*; import java.util.Set; PartiesAPI api = Parties.getApi(); Party party = api.getParty("MyAwesomeParty"); // Set party description and MOTD party.setDescription("An awesome guild for adventurers!"); party.setMotd("Welcome! Check /party info for rules."); // Set party tag (short identifier) party.setTag("AWE"); // Manage party password party.setPasswordUnhashed("secretpass123"); // Plugin will hash it String hashedPassword = party.getPassword(); // Set party as open (anyone can join without invite) party.setOpen(true); boolean isOpen = party.isOpen(); // Enable friendly fire protection party.setProtection(true); boolean isProtected = party.isFriendlyFireProtected(); // Set party color Set availableColors = api.getColors(); for (PartyColor color : availableColors) { if (color.getName().equals("Red")) { party.setColor(color); break; } } PartyColor currentColor = party.getColor(); // Rename the party party.rename("NewPartyName"); // Delete the party party.delete(); ``` ### Response #### Success Response (200) - **Boolean** (Boolean) - Result of operations like setting description, tag, password, open status, protection, color, rename, delete. - **String** (String) - The hashed password if set. - **PartyColor** (Object) - The currently set party color. #### Response Example ```json { "success": true, "message": "Party settings updated successfully." } ``` ``` -------------------------------- ### Manage Party Homes Source: https://context7.com/alessiodp/parties/llms.txt Set and manage party home locations for teleportation functionality. Requires the Parties API and a PartyHome implementation. ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.*; import java.util.HashSet; import java.util.Set; PartiesAPI api = Parties.getApi(); Party party = api.getParty("MyAwesomeParty"); // Get current homes Set homes = party.getHomes(); for (PartyHome home : homes) { System.out.println("Home: " + home.getName()); System.out.println("World: " + home.getWorld()); System.out.println("Location: " + home.getX() + ", " + home.getY() + ", " + home.getZ()); System.out.println("Server: " + home.getServer()); // For BungeeCord } // Create and set a new home (implementation-specific, example structure) // Note: PartyHome is an interface - use your implementation class // This shows the properties you would set on a PartyHome implementation /* PartyHome newHome = new YourPartyHomeImpl(); newHome.setName("base"); newHome.setWorld("world"); newHome.setX(100.5); newHome.setY(64.0); newHome.setZ(-200.5); newHome.setYaw(90.0f); newHome.setPitch(0.0f); newHome.setServer("survival"); // For BungeeCord setups Set newHomes = new HashSet<>(); newHomes.add(newHome); party.setHomes(newHomes); */ ``` -------------------------------- ### Handle Friendly Fire Events Between Party Members (Java) Source: https://context7.com/alessiodp/parties/llms.txt This Java code snippet shows how to manage friendly fire incidents among party members using BukkitPartiesFriendlyFireBlockedEvent, BukkitPartiesCombustFriendlyFireBlockedEvent, and BukkitPartiesPotionsFriendlyFireBlockedEvent. It allows for custom PvP rules and logging. Dependencies include the Parties API. ```java import com.alessiodp.parties.api.events.bukkit.unique.BukkitPartiesFriendlyFireBlockedEvent; import com.alessiodp.parties.api.events.bukkit.unique.BukkitPartiesCombustFriendlyFireBlockedEvent; import com.alessiodp.parties.api.events.bukkit.unique.BukkitPartiesPotionsFriendlyFireBlockedEvent; import com.alessiodp.parties.api.interfaces.*; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; public class FriendlyFireListener implements Listener { @EventHandler public void onFriendlyFire(BukkitPartiesFriendlyFireBlockedEvent event) { PartyPlayer attacker = event.getAttacker(); PartyPlayer victim = event.getVictim(); Party party = event.getParty(); // Allow PvP in certain areas (cancel the block) if (isInPvPArena(victim)) { event.setCancelled(true); // Allow the damage return; } // Warn the attacker System.out.println(attacker.getName() + " tried to attack party member " + victim.getName()); } @EventHandler public void onCombustFriendlyFire(BukkitPartiesCombustFriendlyFireBlockedEvent event) { // Fire damage between party members blocked PartyPlayer attacker = event.getAttacker(); PartyPlayer victim = event.getVictim(); System.out.println("Fire damage blocked: " + attacker.getName() + " -> " + victim.getName()); } @EventHandler public void onPotionFriendlyFire(BukkitPartiesPotionsFriendlyFireBlockedEvent event) { // Harmful potion effects between party members blocked PartyPlayer attacker = event.getAttacker(); PartyPlayer victim = event.getVictim(); System.out.println("Potion damage blocked: " + attacker.getName() + " -> " + victim.getName()); } private boolean isInPvPArena(PartyPlayer player) { return false; // Your arena check logic } } ``` -------------------------------- ### Party Home Management Source: https://context7.com/alessiodp/parties/llms.txt Retrieve and manage the home locations associated with a party, used for teleportation. ```APIDOC ## Party Home Management ### Description Set and manage party home locations for teleportation functionality. ### Method GET, POST, PUT, DELETE (Implicit through API calls) ### Endpoint `/api/parties/{partyId}/homes` (Conceptual) ### Parameters #### Path Parameters - **partyId** (String) - Required - The identifier of the party whose homes are being managed. #### Query Parameters None #### Request Body None (Operations are performed via API methods) ### Request Example ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.*; import java.util.HashSet; import java.util.Set; PartiesAPI api = Parties.getApi(); Party party = api.getParty("MyAwesomeParty"); // Get current homes Set homes = party.getHomes(); for (PartyHome home : homes) { System.out.println("Home: " + home.getName()); System.out.println("World: " + home.getWorld()); System.out.println("Location: " + home.getX() + ", " + home.getY() + ", " + home.getZ()); System.out.println("Server: " + home.getServer()); // For BungeeCord } // Create and set a new home (implementation-specific, example structure) // Note: PartyHome is an interface - use your implementation class // This shows the properties you would set on a PartyHome implementation /* PartyHome newHome = new YourPartyHomeImpl(); newHome.setName("base"); newHome.setWorld("world"); newHome.setX(100.5); newHome.setY(64.0); newHome.setZ(-200.5); newHome.setYaw(90.0f); newHome.setPitch(0.0f); newHome.setServer("survival"); // For BungeeCord setups Set newHomes = new HashSet<>(); newHomes.add(newHome); party.setHomes(newHomes); */ ``` ### Response #### Success Response (200) - **Set** (Set) - A set of PartyHome objects representing the party's homes. - **Boolean** (Boolean) - Result of setting homes. #### Response Example ```json { "homes": [ { "name": "base", "world": "world", "x": 100.5, "y": 64.0, "z": -200.5, "yaw": 90.0, "pitch": 0.0, "server": "survival" } ] } ``` ``` -------------------------------- ### Handle Bukkit PartiesChatEvent in Java Source: https://github.com/alessiodp/parties/wiki/API-Events This snippet demonstrates how to listen for and handle the PartiesChatEvent in a Bukkit plugin. It shows how to check the message content and cancel the event if it matches a specific string. This event is both cancellable and editable. ```java @EventHandler public void onPlayerChat(PartiesChatEvent event) { if (event.getMessage().equals("nope!")) event.setCancelled(true); } ``` -------------------------------- ### Create Players Table - SQL Source: https://github.com/alessiodp/parties/wiki/SQL-structures Defines the SQL structure for the 'Players' table, used to store information about players within a party. It includes columns for player UUID, party association, rank, name, and timestamp. ```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%'; ``` -------------------------------- ### Manage Player Party Data Source: https://context7.com/alessiodp/parties/llms.txt Access and modify player-specific party data such as rank, nickname, spy mode, and invite management. Requires the Parties API and player UUID. ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.*; import java.util.Set; import java.util.UUID; PartiesAPI api = Parties.getApi(); UUID playerUUID = player.getUniqueId(); PartyPlayer partyPlayer = api.getPartyPlayer(playerUUID); // Check if player is in a party if (partyPlayer.isInParty()) { System.out.println("Party ID: " + partyPlayer.getPartyId()); System.out.println("Party Name: " + partyPlayer.getPartyName()); System.out.println("Player Rank Level: " + partyPlayer.getRank()); } // Set player nickname within the party partyPlayer.setNickname("CoolNick"); String nickname = partyPlayer.getNickname(); // Set player rank (rank levels are defined in config) partyPlayer.setRank(10); // Leader rank level // Toggle spy mode (see all party chats) partyPlayer.setSpy(true); boolean isSpy = partyPlayer.isSpy(); // Toggle mute (stop receiving party notifications) partyPlayer.setMuted(true); boolean isMuted = partyPlayer.isMuted(); // Get pending invites Set pendingInvites = partyPlayer.getPendingInvites(); for (PartyInvite invite : pendingInvites) { System.out.println("Invited to: " + invite.getParty().getName()); invite.accept(); // Accept the invite } // Ask to join a party Party partyToJoin = api.getParty("TargetParty"); PartyAskRequest askRequest = partyPlayer.askToJoin(partyToJoin); ``` -------------------------------- ### Create Log Table - SQL Source: https://github.com/alessiodp/parties/wiki/SQL-structures Defines the SQL structure for the 'Log' table, used to store log messages generated by the Parties application. It includes an auto-incrementing ID, date, level, position, and the log message itself. ```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%'; ``` -------------------------------- ### Party Player Operations Source: https://context7.com/alessiodp/parties/llms.txt Manage player-specific data within a party, such as rank, nickname, spy mode, and invite acceptance. ```APIDOC ## Party Player Operations ### Description Access and modify player-specific party data including rank, nickname, spy mode, and invite management. ### Method GET, POST, PUT, DELETE (Implicit through API calls) ### Endpoint `/api/parties/player/{playerUUID}` (Conceptual) ### Parameters #### Path Parameters - **playerUUID** (UUID) - Required - The unique identifier of the player. #### Query Parameters None #### Request Body None (Operations are performed via API methods) ### Request Example ```java import com.alessiodp.parties.api.Parties; import com.alessiodp.parties.api.interfaces.*; import java.util.Set; import java.util.UUID; PartiesAPI api = Parties.getApi(); UUID playerUUID = player.getUniqueId(); PartyPlayer partyPlayer = api.getPartyPlayer(playerUUID); // Check if player is in a party if (partyPlayer.isInParty()) { System.out.println("Party ID: " + partyPlayer.getPartyId()); System.out.println("Party Name: " + partyPlayer.getPartyName()); System.out.println("Player Rank Level: " + partyPlayer.getRank()); } // Set player nickname within the party partyPlayer.setNickname("CoolNick"); String nickname = partyPlayer.getNickname(); // Set player rank (rank levels are defined in config) partyPlayer.setRank(10); // Leader rank level // Toggle spy mode (see all party chats) partyPlayer.setSpy(true); boolean isSpy = partyPlayer.isSpy(); // Toggle mute (stop receiving party notifications) partyPlayer.setMuted(true); boolean isMuted = partyPlayer.isMuted(); // Get pending invites Set pendingInvites = partyPlayer.getPendingInvites(); for (PartyInvite invite : pendingInvites) { System.out.println("Invited to: " + invite.getParty().getName()); invite.accept(); // Accept the invite } // Ask to join a party Party partyToJoin = api.getParty("TargetParty"); PartyAskRequest askRequest = partyPlayer.askToJoin(partyToJoin); ``` ### Response #### Success Response (200) - **PartyPlayer** (Object) - The player's party data object. - **Boolean** (Boolean) - Result of operations like setting nickname, rank, spy mode, mute. - **Set** (Set) - A set of pending party invites. - **PartyAskRequest** (Object) - The result of asking to join a party. #### Response Example ```json { "isInParty": true, "partyId": "some-party-id", "partyName": "Awesome Party", "rank": 10, "nickname": "CoolNick", "isSpy": true, "isMuted": false, "pendingInvites": [ { "partyName": "Another Party" } ] } ``` ``` -------------------------------- ### Intercept and Modify Party Chat Messages (Java) Source: https://context7.com/alessiodp/parties/llms.txt This Java code snippet demonstrates how to listen for and manipulate party chat messages using BukkitPartiesPlayerPreChatEvent and BukkitPartiesPlayerPostChatEvent. It allows for filtering, formatting, and logging of messages. Dependencies include the Parties API. ```java import com.alessiodp.parties.api.events.bukkit.player.BukkitPartiesPlayerPreChatEvent; import com.alessiodp.parties.api.events.bukkit.player.BukkitPartiesPlayerPostChatEvent; import com.alessiodp.parties.api.interfaces.*; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; public class PartyChatListener implements Listener { @EventHandler public void onPreChat(BukkitPartiesPlayerPreChatEvent event) { PartyPlayer player = event.getPartyPlayer(); Party party = event.getParty(); String message = event.getMessage(); // Filter inappropriate content if (containsBadWords(message)) { event.setCancelled(true); return; } // Modify message event.setMessage(message.replace(":)", "\u263A")); // Modify format (must contain %message% placeholder) String format = event.getFormattedMessage(); event.setFormattedMessage("&7[Party] " + format); } @EventHandler public void onPostChat(BukkitPartiesPlayerPostChatEvent event) { // Log party messages PartyPlayer player = event.getPartyPlayer(); Party party = event.getParty(); String message = event.getMessage(); System.out.println("[PartyChat] " + party.getName() + " - " + player.getName() + ": " + message); } private boolean containsBadWords(String message) { return message.toLowerCase().contains("badword"); } } ``` -------------------------------- ### Create Spies Table - SQL Source: https://github.com/alessiodp/parties/wiki/SQL-structures Defines the SQL structure for the 'Spies' table, used to store players utilizing the spy feature. It includes a primary key on the 'uuid' column. ```sql CREATE TABLE %tableName% (uuid VARCHAR(255) NOT NULL, PRIMARY KEY (uuid)) COMMENT='Database version (do not edit):%tableVersion%'; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.