Skip to content

Add DPC community API integration for cross-server faction sharing #1958

@dmccoystephenson

Description

@dmccoystephenson

Overview

Integrate the Medieval Factions plugin with the new DPC community API
(introduced in dansplugins-dot-com#110)
to allow servers running Medieval Factions to publish their faction data
to the DPC community registry. This enables players and server owners to
browse factions from across the community on the DPC website.

The integration is strictly opt-in. Operators receive a toggleable
login reminder and can enable or disable participation at any time via commands.


Motivation

The DPC website now exposes a POST /api/v1/factions endpoint that accepts
faction data from registered Minecraft servers. Medieval Factions is the
natural first plugin to integrate, as its faction data model maps cleanly
to the API's current schema. Participating server owners will get visibility
on the DPC website — and by optionally including their server IP and Discord
link, they can advertise their server and community directly to DPC visitors
browsing faction data.


Proposed Scope

Configuration

Add the following to config.yml:

dpc-api:
  enabled: false               # whether this server is opted in to sharing data
  url: "https://dansplugins.com"
  key: ""                      # API key issued by DPC
  login-reminder: true         # whether to show the opt-in reminder to operators on login
  share-server-ip: false       # whether to include the server IP in faction data (enables server advertising on DPC website)
  discord-link: ""             # optional Discord invite link to display on the DPC website alongside faction data

Operator Login Reminder

  • When an operator logs in, if dpc-api.enabled: false and dpc-api.login-reminder: true,
    send them a chat message reminding them they can opt in, e.g.:

    [Medieval Factions] Want to share your faction data with the DPC community?
    Run /mf dpc optin to participate, or /mf dpc reminder off to hide this message.
    Tip: run /mf dpc shareip on to advertise your server, or /mf dpc discord <link> to share your Discord.

  • The reminder should only show to players with operator-level permission

  • The reminder must not appear if dpc-api.enabled: true (already opted in)

Commands

All commands are simple wrappers around setting the corresponding config value:

Command Effect
/mf dpc optin Sets dpc-api.enabled: true, saves config, confirms to sender
/mf dpc optout Sets dpc-api.enabled: false, saves config, confirms to sender
/mf dpc reminder on Sets dpc-api.login-reminder: true, saves config, confirms to sender
/mf dpc reminder off Sets dpc-api.login-reminder: false, saves config, confirms to sender
/mf dpc shareip on Sets dpc-api.share-server-ip: true, saves config, confirms to sender
/mf dpc shareip off Sets dpc-api.share-server-ip: false, saves config, confirms to sender
/mf dpc discord <link> Sets dpc-api.discord-link to the provided URL, saves config, confirms to sender
/mf dpc discord clear Clears dpc-api.discord-link, saves config, confirms to sender

HTTP Client

  • Add a lightweight HTTP client service (e.g., using Java's HttpClient or OkHttp)
    to handle communication with the DPC API
  • Send requests asynchronously to avoid blocking the server thread

Sync Behavior

  • Only runs when dpc-api.enabled: true
  • On a configurable interval (e.g., every 10 minutes), or on significant faction
    events (creation, deletion, member join/leave), push the current faction list
    to POST /api/v1/factions
  • Payload should conform to the DPC API's faction data model, with serverIp
    and discordLink included only when configured:
{
  "name": "string",
  "serverId": "string",
  "memberCount": 0,
  "description": "string",
  "serverIp": "string or omitted",
  "discordLink": "string or omitted"
}

Data Mapping

Medieval Factions field DPC API field Notes
Faction name name
Server name (from config) serverId
getMembers().size() memberCount
Faction description (if present) description
Server IP (from Bukkit) serverIp Only included when share-server-ip: true
dpc-api.discord-link discordLink Only included when non-empty

bStats Metrics

Add the following custom metrics to the plugin's bStats chart collection:

Metric name Type Description
DPC API Opt-In Simple pie Tracks how many servers have dpc-api.enabled: true vs false
DPC API Login Reminder Simple pie Tracks how many servers have dpc-api.login-reminder: true vs false
DPC API Share Server IP Simple pie Tracks how many servers have dpc-api.share-server-ip: true vs false
DPC API Discord Link Set Simple pie Tracks how many servers have a non-empty dpc-api.discord-link

Acceptance Criteria

  • dpc-api.enabled, dpc-api.url, dpc-api.key, dpc-api.login-reminder,
    dpc-api.share-server-ip, and dpc-api.discord-link added to config.yml
    with safe defaults (enabled: false, login-reminder: true,
    share-server-ip: false, discord-link: "")
  • Operator login reminder shown when enabled: false and login-reminder: true
  • Reminder not shown when enabled: true or login-reminder: false
  • Reminder mentions both shareip and discord commands as advertising tips
  • /mf dpc optin and /mf dpc optout toggle dpc-api.enabled and save config
  • /mf dpc reminder on and /mf dpc reminder off toggle dpc-api.login-reminder and save config
  • /mf dpc shareip on and /mf dpc shareip off toggle dpc-api.share-server-ip and save config
  • /mf dpc discord <link> sets dpc-api.discord-link and saves config
  • /mf dpc discord clear clears dpc-api.discord-link and saves config
  • discordLink is included in the faction payload only when discord-link is non-empty
  • serverIp is included in the faction payload only when share-server-ip: true
  • Factions are only pushed to the API when dpc-api.enabled: true
  • X-API-Key header is included on all POST requests
  • Sync runs asynchronously and does not block the main server thread
  • Failed requests are logged clearly without crashing the plugin
  • DPC API Opt-In bStats pie chart registered and reporting
  • DPC API Login Reminder bStats pie chart registered and reporting
  • DPC API Share Server IP bStats pie chart registered and reporting
  • DPC API Discord Link Set bStats pie chart registered and reporting
  • README or wiki updated with setup instructions for server owners,
    including notes on the advertising benefits of share-server-ip and discord-link

Reference

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions