-
Notifications
You must be signed in to change notification settings - Fork 32
Description
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 dataOperator Login Reminder
-
When an operator logs in, if
dpc-api.enabled: falseanddpc-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 optinto participate, or/mf dpc reminder offto hide this message.
Tip: run/mf dpc shareip onto 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
HttpClientor 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
toPOST /api/v1/factions - Payload should conform to the DPC API's faction data model, with
serverIp
anddiscordLinkincluded 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, anddpc-api.discord-linkadded toconfig.yml
with safe defaults (enabled: false,login-reminder: true,
share-server-ip: false,discord-link: "") - Operator login reminder shown when
enabled: falseandlogin-reminder: true - Reminder not shown when
enabled: trueorlogin-reminder: false - Reminder mentions both
shareipanddiscordcommands as advertising tips -
/mf dpc optinand/mf dpc optouttoggledpc-api.enabledand save config -
/mf dpc reminder onand/mf dpc reminder offtoggledpc-api.login-reminderand save config -
/mf dpc shareip onand/mf dpc shareip offtoggledpc-api.share-server-ipand save config -
/mf dpc discord <link>setsdpc-api.discord-linkand saves config -
/mf dpc discord clearclearsdpc-api.discord-linkand saves config -
discordLinkis included in the faction payload only whendiscord-linkis non-empty -
serverIpis included in the faction payload only whenshare-server-ip: true - Factions are only pushed to the API when
dpc-api.enabled: true -
X-API-Keyheader 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-InbStats pie chart registered and reporting -
DPC API Login ReminderbStats pie chart registered and reporting -
DPC API Share Server IPbStats pie chart registered and reporting -
DPC API Discord Link SetbStats pie chart registered and reporting - README or wiki updated with setup instructions for server owners,
including notes on the advertising benefits ofshare-server-ipanddiscord-link
Reference
- DPC API PR: dansplugins-dot-com#110
- Endpoint:
POST /api/v1/factions - Auth:
X-API-Keyheader