Parties
parties() keeps friends together in a room. A player invites another, who accepts, and the two queue for a match as one block, on one side, and stay together. List it in the game’s plugins, and import its names from @spawnite/engine/parties. Fortnite and Rocket League keep parties the same way, and Hypixel holds them across its games.
A party lives in its room, and goes when it holds one member. The engine asks one party question, findParty(world, player), which parties() answers. readPartyMembers and readPartyLeader read the rest, from @spawnite/engine/core. A platform’s party can answer the same question later, so a game’s code stays the same.
Inviting and leaving
Section titled “Inviting and leaving”A page sends each request, and the room answers each with a PartyRefusal where it refuses:
sendPartyInvite(world, player)invites a player, and makes a party with the sender as its leader on the sender’s first invite. Only a leader invites, up tomaxSizemembers, 4 by default.sendPartyAccept(world, party)takes the recipient into a party whose invite the recipient holds. An invite lapses afterinviteSeconds, 60 by default.sendPartyLeave(world)takes the player out. A leader who leaves passes the lead to the member who joined first.sendPartyKick(world, player)lets the leader take a member out.
useParty() reads the local player’s party, its leader and its members, or null for none. usePartyInvites() reads the invites the local player holds, each with its party, its inviter and the seconds before it lapses.
In a queue
Section titled “In a queue”A party’s leader joins a queue for every member: sendMatchJoin from any other member is refused not-party-leader. The queue seats the party as one block on one side, and refuses party-too-large a party larger than a side or than the queue’s maxPartySize. A party with a member already on another court is refused party-member-busy, so a party never splits across two matches. A leader who leaves the line takes the whole party out of it. A member who leaves it, or the party, while it waits leaves the line alone, and the rest stay in it. A match’s rotation sends members out one by one, so a party whose members played each other on one court parts there.
A party’s chat
Section titled “A party’s chat”partyTextChannel() is a text chat channel that reaches the sender’s party, as teamTextChannel() reaches the sender’s team. A player in no party cannot write to it.
import { defineTextChat, textChannel } from "@spawnite/engine/core";import { parties, partyTextChannel } from "@spawnite/engine/parties";
// A park game's parties, as the Parties page lists them: up to four// friends who queue together, and a chat channel only they read.
export const partyPlugins = [parties({ maxSize: 4, inviteSeconds: 30 })];
export const textChat = defineTextChat({ channels: { all: textChannel(), party: partyTextChannel() },});