Storage Providers
Technical Information
Storage Providers allow developers to create different methods of storing Honeypot blocks should the built-in methods not be enough for their specific use case.
There are three different types of Storage Provider in Honeypot: REGION, PLAYER, and PLAYER_HISTORY. Developers can create Storage Providers for as many or as few types as they wish, and one provider can support more than one type if desired.
Honeypot only contains one native storage method for each type. Player information, player history, and Block Data (the location and action of Honeypot) are stored within the default SQLite stores. It is necessary to have different methods of storage allows server managers to pick what is best for them.
The built-in SQLite Store has been architected to use an R*-Tree data structure, a variant of an R-Tree data structure but with better query performance. In testing, Honeypot's DB architecture allowed it to search a 2,000,0003 block area within milliseconds (That's 8E18, or eight quintillion blocks).
Because Honeypot can achieve such extreme query times without nearly any overhead, it's recommended that you stick with the native Honeypot storage methods unless you know you absolutely need something else.
Creating and Registering Storage Providers
To create a Storage Provider for one or more Store types, create a class and annotate it with the @HoneypotStore annotation. This annotation requires two arguments.
- name
The name of the storage provider. This must be unique across all storage providers regardless of type. For example, no two
REGIONmay be called "mysql", even if one is aREGIONStore and the other is aPLAYERstore.- type
The type or types this store supports. Can be a single item or a list of multiple
@HoneypotStore(name = "myStoreA", type = StoreType.REGION) public class MyStoreA implements RegionStore { // Implementation... } @HoneypotStore(name = "myStoreB", type = { StoreType.PLAYER, StoreType.PLAYER_HISTORY }) public class MyStoreB implements PlayerStore, PlayerHistoryStore { // Implementation... }
Notice that a Honeypot Store must implement the correct Interface for the type. Each type has a dedicated interface, and you must implement it.
Once the storage provider is complete, you must register it in your onLoad() method.
Honeypot will allow registrations of storage providers only at load time, so you cannot reload Honeypot using /reload or a plugin like PlugManX. To use the Storage Provider that was added, see Configuring Honeypot. You must update the name of the storage method to what you set in the @HoneypotStore annotation.
Using Storage Providers
The static Registry class provides a lot of functionality for working with Honeypot data without needing to know the inner workings of the storage provider.
A getter exists for each Store type to get the currently selected Storage Provider.
Registry#getRegionStore()Gets the currently loaded Storage Provider for
REGIONdata.Registry#getPlayerStore()Gets the currently loaded Storage Provider for
PLAYERdata.Registry#getPlayerHistoryStore()Gets the currently loaded Storage Provider for
PLAYER_HISTORYdata.
If you need to be able to get a Store Provider by name and/or type, you may do so using the methods on the StoreRegistry.