Skip to content

Developer API

shvquu edited this page Jun 13, 2026 · 4 revisions

Developer API

ServerDoctor exposes a stable public API in the serverdoctor-api module so other plugins can read diagnostics, subscribe to events, and register custom scanners.

Adding the dependency

Use compileOnly — the installed ServerDoctor plugin provides the implementation at runtime. Do not shade the API into your plugin.

repositories { maven("https://jitpack.io") }
dependencies {
    compileOnly("com.github.Shvquu.server-doctor:serverdoctor-api:v0.5.0")
}

Declare the dependency in your plugin.yml so ServerDoctor loads first:

depend: [ServerDoctor]

Accessing the API

import com.serverdoctor.api.ServerDoctorApi;
import com.serverdoctor.api.ServerDoctorProvider;

if (ServerDoctorProvider.isAvailable()) {
    ServerDoctorApi api = ServerDoctorProvider.get();
    // use api...
}

ServerDoctorProvider.get() throws IllegalStateException if ServerDoctor isn't initialized yet — guard with isAvailable() or rely on the depend ordering.

What the API offers

Method Returns
getPerformanceSnapshot() A fresh PerformanceSnapshot (TPS, MSPT, memory, threads, players)
getLatestReport() Optional<DiagnosticReport> from the last run
getConflicts() List<ConflictReport> from the last run
getSecurityRisks() List<SecurityRisk> from the last run
getRecommendations() List<Recommendation> from the last run
runDiagnostics() Runs a full analysis now and returns the DiagnosticReport
registerModule(AnalysisModule) Adds a custom scanner (see Custom Scanners)
unregisterModule(String id) Removes a scanner by id
events() The EventBus (see Events)

Example

ServerDoctorApi api = ServerDoctorProvider.get();

PerformanceSnapshot perf = api.getPerformanceSnapshot();
double tps = perf.tps1m();
long usedMb = perf.memory().usedMb();

for (ConflictReport c : api.getConflicts()) {
    getLogger().warning(c.pluginA() + " + " + c.pluginB() + ": " + c.description());
}

Data model overview

  • PerformanceSnapshottps1m(), mspt(), memory() (MemoryStats: usedMb(), maxMb(), usedRatio()), threadCount(), onlinePlayers(), capturedAt().
  • PluginInfoname(), version(), authors(), hardDepends(), softDepends(), enabled().
  • ConflictReportpluginA(), pluginB(), severity(), description().
  • SecurityRiskpluginName(), type(), severity(), description().
  • Recommendationcategory(), severity(), title(), description().
  • DiagnosticReportperformance(), results(), recommendations(), conflicts(), securityRisks(), overallSeverity(), timestamp().
  • SeverityOK, INFO, LOW, MEDIUM, HIGH, CRITICAL (with atLeast(...)).

Clone this wiki locally