Skip to main content
A DataAddon is the fundamental building block in Nexus Core. Each addon represents a single MongoDB document collection, defines its schema through @DbDataModels annotations, controls its own Redis cache key prefix, and can optionally gate or intercept incoming requests via handleRequest(). Splitting your data model into focused addons keeps the orchestration layer modular and easy to maintain.

Creating a DataAddon in Three Steps

1

Extend DataAddon and implement the abstract methods

Create a class that extends DataAddon and implement five required methods: addonId(), addonName(), getDatabase(), getCollection(), cacheKeyHeaderTag(), and handleRequest(). These tell Nexus Core which MongoDB database and collection to use, how to prefix Redis cache keys, and whether to allow or reject a given request.
2

Annotate fields with @DbDataModels

Declare your document fields as class members and annotate each one with @DbDataModels. Use isId = true on the primary key field (exactly one per addon) and defaultValue on all other fields to specify fallback values for incoming packets that omit them.
3

Register the addon on startup

Call NexusApplication.getInstance().getProtocolHandler().registerAddon(new YourAddon()) during application startup. After registration, Nexus Core automatically routes all matching requests to your addon’s MongoDB collection and Redis keyspace.

Complete Example: PlayerStatsAddon

The following addon stores player statistics in the player_stats collection inside the nexus_core_db database. It uses the player UUID as the primary key and prefixes Redis cache entries with stats.

Registering the Addon

Once registered, Nexus Core processes all GET_DATA, SET_DATA, REMOVE_DATA, INCREMENT_DATA, and other request types for protocol ID 100 against the player_stats collection automatically.

Next Steps

DataAddon API Reference

Full reference for every abstract method, the handleRequest lifecycle, and NexusJsonDataContainer.

Annotations Reference

The complete @DbDataModels syntax, supported field types, and validation rules.