Skip to main content
C++

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​

MyServerAdminCoreStorage.h
#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;
};
FunctionCalledNotes
InitializeStorage(DataDirectory)Once, before loadingOptional override. Open connections here.
LoadDatabaseOn start and on /reloadFill only what you have, leave other fields untouched
SaveDatabaseShortly after every change, and on shutdownCategories tells you what changed (Bans, Mutes, Whitelist, Groups, Players, Notes)
AppendLogEntryFor every admin log entryOptional
LoadRecentLogEntriesOn startOptional, oldest first
warning

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.