Flagship is Moonrise Studios' distributed feature-flag runtime for Paper, BungeeCord, and Velocity. PostgreSQL or MariaDB is the durable source of truth, Redis provides a shared cache and Pub/Sub synchronization, Caffeine holds the hot in-memory snapshot, and flags.json preserves the last known state during a complete remote outage.
| Module | Artifact | Purpose |
|---|---|---|
flagship |
gg.moonrise.flagship:flagship:1.0.0 |
Platform-neutral API and implementation |
flagship-paper |
runtime jar | Thin Paper runtime with loader-resolved libraries |
flagship-bungeecord |
runtime jar | Self-contained relocated BungeeCord runtime |
flagship-velocity |
runtime jar | Self-contained relocated Velocity runtime |
Install exactly one platform runtime jar on each server or proxy JVM. Consumer plugins compile against flagship and must not shade it.
repositories {
maven("https://repo.moonrise.gg/repository/maven-releases/")
maven("https://repo.moonrise.gg/repository/maven-snapshots/")
}
dependencies {
compileOnly("gg.moonrise.flagship:flagship:1.0.0")
}Paper consumers must declare a required server dependency with classpath access:
dependencies:
server:
Flagship:
load: BEFORE
required: true
join-classpath: trueBungeeCord consumers use depends: [Flagship]. Velocity consumers declare a required dependency on plugin ID flagship.
import gg.moonrise.flagship.FeatureFlag;
import gg.moonrise.flagship.FeatureFlags;
public final class MyFeature {
public static final FeatureFlag<Boolean> ENABLED =
FeatureFlag.of("myapp.feature-1", true);
public void run() {
if (!ENABLED.value()) {
return;
}
// Feature logic
}
public void update(boolean value) {
FeatureFlags.set(ENABLED.key(), value)
.exceptionally(error -> {
// The authoritative SQL database is unavailable or rejected the write.
return null;
});
}
}Unsetting writes an SQL tombstone, removes the cached override, and restores the code-defined default:
FeatureFlags.unset(ENABLED.key());Use an explicit type for nullable defaults or an anonymous TypeRef for generic JSON values:
FeatureFlag<String> optional = FeatureFlag.of("myapp.label", String.class, null);
FeatureFlag<List<String>> worlds = FeatureFlag.of(
"myapp.worlds",
new TypeRef<List<String>>() {},
List.of("world")
);The same key may be declared repeatedly only with the same Java type and default value. Conflicting declarations fail immediately.
FeatureFlags.redis() exposes relocation-safe asynchronous string, hash, and Pub/Sub operations. It never exposes Lettuce, Netty, Jackson, or Caffeine types. Flagship owns the client and command connections; callers only close subscription handles returned by subscribe.
FeatureFlags.redis().set("my-plugin:key", "value");
FeatureFlags.redis().subscribe("my-plugin:events", message -> {
// Handle the message.
}).thenAccept(subscription -> {
// Retain the subscription and close it when your plugin disables.
});FeatureFlags.isDatabaseAvailable() reports authoritative-store health. FeatureFlags.isRedisAvailable() reports whether cache and Pub/Sub operations are currently usable. A SQL-committed flag mutation succeeds even when Redis is down; a mutation is rejected when SQL is unavailable.
Flagship owns the HikariCP pool, JDBC connections, migrations, Redis client, and command connections. No SQL facade or third-party runtime type is exposed to consumers; the runtime closes all owned resources during platform shutdown.
Flagship registers its commands dynamically on Paper, BungeeCord, and Velocity. They are not declared in the platform descriptors. Every command requires flagship.admin, and /ff is a complete alias of /flagship.
/flagship
/flagship list
/flagship get <flag>
/flagship set <flag> <value>
/flagship unset <flag>
The root command reports the defined-flag count plus SQL and Redis health. list shows every statically declared flag in key order with its effective value and whether that value comes from a code default or SQL override. get includes the declared Java type, default, effective value, and override state. Unknown keys, including keys with different casing, are rejected without writing.
Values are decoded as typed JSON. Unquoted input for a String flag stays literal, while a quoted JSON string is unescaped normally. Generic values can include spaces because the value argument is greedy:
/ff set checkout.enabled true
/ff set checkout.maximum-attempts 4
/ff set checkout.banner Maintenance begins at 8 PM
/ff set checkout.banner "Maintenance begins at 8 PM"
/ff set checkout.worlds ["world", "world_nether"]
/ff set checkout.weights {"control": 25, "new-flow": 75}
Flag-key completion is generated from the live registry, so flags declared after startup appear immediately. Matching is case-insensitive and checks any substring of the key, not only its prefix. Mutation success is reported only after SQL commits and the local snapshot updates; a Redis outage does not turn an already committed write into a failure.
Each runtime creates config.yml in its platform data directory:
distributed:
enabled: true
refresh-interval-seconds: 30
sql:
backend: postgresql
host: localhost
port: 5432
database: flagship
username: flagship
password: ""
tls: false
connection-timeout-millis: 5000
maximum-pool-size: 4
table-prefix: flagship
redis:
host: localhost
port: 6379
username: ""
password: ""
database: 0
tls: false
timeout-millis: 5000
key-prefix: flagshipUse backend: mariadb and port 3306 for MariaDB. TLS enables full certificate and hostname verification for either SQL driver. The configured passwords are used only to create Flagship-managed clients and are never copied into flags.json or application diagnostics.
table-prefix accepts 1–40 ASCII letters, digits, or underscores. Identifiers are quoted for the selected backend, so numeric prefixes are supported safely.
Flagship automatically creates versioned <table-prefix>_flags, <table-prefix>_schema_history, and <table-prefix>_metadata tables. Unset rows remain as revisioned tombstones. On an empty first-time SQL database, valid existing values in the Redis flag hash are imported once; local JSON is never promoted into SQL.
Redis stores raw JSON values in <key-prefix>:flags, revisions in <key-prefix>:revisions, and announcements on <key-prefix>:updates. SQL reconciliation repairs missed or stale cache updates. Startup and fallback precedence is flags.json, then Redis when SQL is unavailable, then SQL as soon as it is reachable. With SQL available and Redis down, writes remain durable and Redis is repaired on reconnect. With SQL down, reads continue from Redis or local state while writes fail without changing any cache. Setting distributed.enabled: false makes Flagship local/default-only and read-only.
The Paper jar is intentionally thin. Its paper-plugin.yml loader resolves Lettuce, Netty, Jackson, Caffeine, HikariCP, both JDBC drivers, Cloud Paper 2.0.0, Cloud Annotations 2.1.0, and their transitive libraries from Paper's configured Maven Central mirror.
BungeeCord and Velocity jars bundle their complete runtime dependency closure, including their Cloud platform integration and annotations. Cloud is relocated beneath gg.moonrise.flagship.libs.cloud, GeAnTyRef beneath gg.moonrise.flagship.libs.geantyref, and the remaining third-party packages beneath gg.moonrise.flagship.libs. Platform APIs, platform-provided Adventure, and SLF4J remain external. The verifyPackaging task rejects thin-jar leaks, unrelocated Cloud classes, or other unrelocated proxy dependencies.
./gradlew clean buildOnly the flagship API is published to Nexus. It uses the Moonrise Nexus properties nexusUsername, nexusPassword, nexusSnapshotsUrl, and nexusReleasesUrl. Main builds publish 1.0.0-SNAPSHOT, feature branches publish 1.0.0-<short-sha> to experimental, and GitHub releases publish 1.0.0. The Paper, BungeeCord, and Velocity modules produce installable runtime jars and intentionally expose no Maven publication tasks.