Java SDK
Build custom integrations with your Minecraft plugins. The ServerStats SDK gives you programmatic access to event tracking, A/B testing, and session management.
Why Use the SDK?
The ServerStats plugin handles basic analytics automatically. Use the SDK when you want to:
- Track custom events — Crate opens, quest completions, PvP kills
- Run A/B tests — Show different experiences to different players
- Access session data — Get player hostnames, join times, session IDs
- Build advanced integrations — Create automated workflows based on analytics
Quick Example
import com.serverstats.api.ServerStats;// Track a custom eventServerStats.trackEvent("crate_opened").withPlayer(player.getUniqueId(), player.getName()).withData("crate_type", "legendary").withData("reward", "diamond_sword").send();// A/B test different rewardsString variant = ServerStats.getVariant(player.getUniqueId(), "crate-rewards");if ("boosted".equals(variant)) {giveDoubleRewards(player);}
Requirements
- Java 17+
- ServerStats plugin installed and configured on the server
- Paper, Velocity, or BungeeCord server
Getting Started
| Step | Description |
|---|---|
| Installation | Add the SDK to your project |
| Event Tracking | Track custom player actions |
| A/B Testing | Run experiments in your plugin |
| Sessions | Access player session data |
| Plugin Messaging | Send events through your proxy |
| API Reference | Complete method reference |
Package Structure
com.serverstats.api├── ServerStats # Main entry point (static methods)├── manager/│ ├── ABTestManager # A/B test operations│ └── SessionManager # Player session access├── messaging/│ ├── ServerStatsMessaging # Send events via plugin messages│ └── ServerStatsMessageParser # Parse incoming messages (proxy-side)├── object/│ ├── abtest/│ │ ├── ABTest # Test configuration│ │ └── Variant # Test variant│ └── builder/│ └── EventBuilder # Fluent event builder└── session/└── PlayerSession # Session data interface