Town Chat
Town chat is a per-town channel routed through AstralChat. Members opt in to "town chat mode" via /town chat; while it is on, every message they type in normal chat is redirected to their selected town instead of the global channel.
Toggling redirect
State lives on TownPlayerData.chatEnabled. Confirmation messages: CHAT_ENABLED/CHAT_DISABLED.
The action equivalent is toggle-town-chat (no arguments) — useful for menu buttons.
Sending one-off messages
The message uses the CHAT_FORMAT template from messages.yml with placeholders for the sender's display name, the town name, and the message.
Broadcasting
Permission: CHAT_BROADCAST. Delivered to every member regardless of their selected town. Format: BROADCAST_FORMAT.
Pipeline
Because the redirect happens at HIGH priority before AstralChat's render listener, town chat avoids the channel formatter / filter pipeline — town messages are not seen by social spy and are not affected by global filters. Use the CHAT_FORMAT template for any formatting you need.
Cross-server delivery
TownChatMessagePacket carries the rendered component and the town UUID. The recipient server resolves the town from its cache, then loops over the local online members and delivers the component. Members on the originating server receive it through the same packet to keep the rendering pipeline single-pathed.
Placeholder
%towns_chatEnabled% returns the viewer's current toggle state — useful for menu visibility: