Custom Storage
By default Server Admin Core stores data as JSON files. To keep data in a database, a REST API or anything else, for example to share bans between several servers, write your own storage class.
1. Subclass UServerAdminCoreStorage
#pragma once
#include "ServerAdminCoreStorage.h"
#include "MyServerAdminCoreStorage.generated.h"
UCLASS()
class UMyServerAdminCoreStorage : public UServerAdminCoreStorage
{
GENERATED_BODY()
public:
virtual bool LoadDatabase(FServerAdminCoreDatabase& OutDatabase) override;
virtual bool SaveDatabase(const FServerAdminCoreDatabase& Database, EServerAdminCoreDataCategory Categories) override;
virtual void AppendLogEntry(const FServerAdminCoreLogEntry& Entry) override;
virtual void LoadRecentLogEntries(int32 MaxEntries, TArray<FServerAdminCoreLogEntry>& OutEntries) override;
};
| Function | Called | Notes |
|---|---|---|
InitializeStorage(DataDirectory) | Once, before loading | Optional override. Open connections here. |
LoadDatabase | On start and on /reload | Fill only what you have, leave other fields untouched |
SaveDatabase | Shortly after every change, and on shutdown | Categories tells you what changed (Bans, Mutes, Whitelist, Groups, Players, Notes) |
AppendLogEntry | For every admin log entry | Optional |
LoadRecentLogEntries | On start | Optional, oldest first |
LoadDatabase and SaveDatabase are called on the game thread. If your backend is slow, keep a local cache and sync in
the background, or saves will cause hitches.
2. Select it
Project Settings → Plugins → Server Admin Core → Storage Class → MyServerAdminCoreStorage.
Sharing bans between servers
A simple pattern is to store bans, mutes, groups and the whitelist in a shared database, and keep players and notes
local. Call Reload Data (or the /reload command) on your servers after another server changes data, or poll on a timer.
Extending the JSON storage
You can also subclass UServerAdminCoreJsonStorage and only override parts of it, for example AppendLogEntry to also send
logs to a web service.