Mod

Custom Server Data

Quick rating

Custom Server Data

No reviews yet

A useful mod for Minecraft servers and framework for mod developers.

Storage & Organization
API/Library
Mod Loaders
Fabric
Quilt
Minecraft

Community voices

Reviews

Versions
Loading versions…
Match includes

Click once to include, again to exclude, again to clear

Rating Any
Any 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
Min
Max
Play Status
Reviews
Time Played
hrs+
Verified developers only
Has developer response
List view
Grid view
Compact view
Sort by
Date
Rating
Helpful
Unhelpful
Edited
Sort ascending
Delete this review?

This removes your review from the project. You can write a new review after.

Review submitted for moderation

Your review has been sent to moderators, who will check that it meets our guidelines before it appears publicly.

No reviews yet. Be the first to review this project!

Get it on

Available Platforms

Compatibility

Supported Environments

Dev Environment
Client Unsupported
Server Required

About

Project Details

Type
Mod
License
All Rights Reserved
Latest Version
custom-server-data-1.0.3.jar
Authors
CurseForge
Modrinth

For authors

Embed Badge

If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.

Custom banner text
ModDex rating badge preview

Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.

Identifiers

Platform IDs

CurseForge ID
Modrinth ID

Resources

External Links

Source Issues Wiki Discord

About

Description

Custom Server Data

Version Loader Status

Overview

Custom Server Data is a Fabric server-side library mod that provides a structured, persistent global data framework for Minecraft 1.20.6. It allows mod developers (and the server itself) to store data.

Data is stored as human-readable JSON files inside the world save directory:

world/customserverdata/<modid>/<filename>.json

Each variable is defined with a type, default value, constraints, and nullability through a schema system, then read/written at runtime through a static API.

Developer Guide

1. Creating a Custom Type

Any custom object you want to store must implement IJsonSerializable:

import com.google.gson.JsonObject;
import fr.hdi.api.IJsonSerializable;

public class QuestData implements IJsonSerializable {
    private int nbPoints;
    private String status;

    public QuestData() {
        this.nbPoints = 0;
        this.status = "inactive";
    }

    public int getNbPoints() { return nbPoints; }
    public void setNbPoints(int nbPoints) { this.nbPoints = nbPoints; }

    public String getStatus() { return status; }
    public void setStatus(String status) { this.status = status; }

    @Override
    public JsonObject toJson() {
        JsonObject json = new JsonObject();
        json.addProperty("nb_points", nbPoints);
        json.addProperty("status", status);
        return json;
    }

    @Override
    public void fromJson(JsonObject json) {
        this.nbPoints = json.has("nb_points") ? json.get("nb_points").getAsInt() : 0;
        this.status = json.has("status") ? json.get("status").getAsString() : "inactive";
    }
}

2. Registering Data

Register your schemas in your mod's onInitialize method using ServerSchemaManager:

import fr.hdi.schema.DataType;
import fr.hdi.schema.ServerSchemaManager;
import fr.hdi.schema.VariableDefinition;
import net.fabricmc.api.ModInitializer;

public class MyMod implements ModInitializer {
    public static final String MOD_ID = "mymod";

    @Override
    public void onInitialize() {
        // Register an integer with min/max constraints
        ServerSchemaManager.register(MOD_ID, "quests",
            VariableDefinition.builder("nb_point")
                .type(DataType.INT)
                .defaultValue(10)
                .min(0)
                .max(1000)
                .build()
        );

        // Register a string
        ServerSchemaManager.register(MOD_ID, "quests",
            VariableDefinition.builder("status")
                .type(DataType.STRING)
                .defaultValue("active")
                .build()
        );

        // Register a boolean
        ServerSchemaManager.register(MOD_ID, "settings",
            VariableDefinition.builder("pvp_enabled")
                .type(DataType.BOOLEAN)
                .defaultValue(false)
                .build()
        );

        // Register a custom type
        ServerSchemaManager.register(MOD_ID, "quests",
            VariableDefinition.builder("quest_data", "QuestData")
                .type(DataType.CUSTOM)
                .customFactory(QuestData::new)
                .nullable(true)
                .build()
        );

        //Register a custom type List 
        ServerSchemaManager.register(MOD_ID, "warps",
                ServerVariableDefinition.builder("warps")
                        .type(ServerDataType.LIST)
                        .elementType(ServerDataType.CUSTOM)
                        .elementFactory(Warp::new)
                        .defaultValue(List.of())
                        .build()
        );
    }
}

This produces two JSON files on disk:

  • world/customserverdata/mymod/quests.json
  • world/customserverdata/mymod/settings.json

3. Reading / Writing Data

Use the static ServerDataStore API anywhere on the server thread:

import fr.hdi.store.ServerDataStore;

// Read values
int points = ServerDataStore.getInt("mymod", "quests", "nb_point");
String status = ServerDataStore.getString("mymod", "quests", "status");
boolean pvp = ServerDataStore.getBoolean("mymod", "settings", "pvp_enabled");

// Write values (validated against the schema)
ServerDataStore.setData("mymod", "quests", "nb_point", 42);
ServerDataStore.setData("mymod", "quests", "status", "completed");
ServerDataStore.setData("mymod", "settings", "pvp_enabled", true);

// Custom objects
QuestData quest = ServerDataStore.getCustom("mymod", "quests", "quest_data");
if (quest != null) {
    quest.setNbPoints(100);
    ServerDataStore.setData("mymod", "quests", "quest_data", quest);
}

List<Warp> warps = ServerDataStore.getList(EssentialsUtilsCommands.MOD_ID, "warps", "warps");
if (warps != null){
    warps.remove(1);
    ServerDataStore.setData(EssentialsUtilsCommands.MOD_ID, "warps","warps",warps);
}

Custom Server Data

Version Loader Status

Overview

Custom Server Data is a Fabric server-side library mod that provides a structured, persistent global data framework for Minecraft 1.20.6. It allows mod developers (and the server itself) to store data.

Data is stored as human-readable JSON files inside the world save directory:

world/customserverdata/<modid>/<filename>.json

Each variable is defined with a type, default value, constraints, and nullability through a schema system, then read/written at runtime through a static API.

Developer Guide

1. Creating a Custom Type

Any custom object you want to store must implement IJsonSerializable:

import com.google.gson.JsonObject;
import fr.hdi.api.IJsonSerializable;

public class QuestData implements IJsonSerializable {
    private int nbPoints;
    private String status;

    public QuestData() {
        this.nbPoints = 0;
        this.status = "inactive";
    }

    public int getNbPoints() { return nbPoints; }
    public void setNbPoints(int nbPoints) { this.nbPoints = nbPoints; }

    public String getStatus() { return status; }
    public void setStatus(String status) { this.status = status; }

    @Override
    public JsonObject toJson() {
        JsonObject json = new JsonObject();
        json.addProperty("nb_points", nbPoints);
        json.addProperty("status", status);
        return json;
    }

    @Override
    public void fromJson(JsonObject json) {
        this.nbPoints = json.has("nb_points") ? json.get("nb_points").getAsInt() : 0;
        this.status = json.has("status") ? json.get("status").getAsString() : "inactive";
    }
}

2. Registering Data

Register your schemas in your mod's onInitialize method using ServerSchemaManager:

import fr.hdi.schema.ServerDataType;
import fr.hdi.schema.ServerSchemaManager;
import fr.hdi.schema.ServerVariableDefinition;
import net.fabricmc.api.ModInitializer;

public class MyMod implements ModInitializer {
    public static final String MOD_ID = "mymod";

    @Override
    public void onInitialize() {
        // Register an integer with min/max constraints
        ServerSchemaManager.register(MOD_ID, "quests",
            ServerVariableDefinition.builder("nb_point")
                .type(ServerDataType.INT)
                .defaultValue(10)
                .min(0)
                .max(1000)
                .build()
        );

        // Register a string
        ServerSchemaManager.register(MOD_ID, "quests",
            ServerVariableDefinition.builder("status")
                .type(ServerDataType.STRING)
                .defaultValue("active")
                .build()
        );

        // Register a boolean
        ServerSchemaManager.register(MOD_ID, "settings",
            ServerVariableDefinition.builder("pvp_enabled")
                .type(ServerDataType.BOOLEAN)
                .defaultValue(false)
                .build()
        );

        // Register a custom type
        ServerSchemaManager.register(MOD_ID, "quests",
            ServerVariableDefinition.builder("quest_data", "QuestData")
                .type(ServerDataType.CUSTOM)
                .customFactory(QuestData::new)
                .nullable(true)
                .build()
        );

        //Register a custom type List 
        ServerSchemaManager.register(MOD_ID, "warps",
                ServerVariableDefinition.builder("warps")
                        .type(ServerDataType.LIST)
                        .elementType(ServerDataType.CUSTOM)
                        .elementFactory(Warp::new)
                        .defaultValue(List.of())
                        .build()
        );
    }
}

This produces two JSON files on disk:

  • world/customserverdata/mymod/quests.json
  • world/customserverdata/mymod/settings.json

3. Reading / Writing Data

Use the static ServerDataStore API anywhere on the server thread:

import fr.hdi.store.ServerDataStore;

// Read values
int points = ServerDataStore.getInt("mymod", "quests", "nb_point");
String status = ServerDataStore.getString("mymod", "quests", "status");
boolean pvp = ServerDataStore.getBoolean("mymod", "settings", "pvp_enabled");

// Write values (validated against the schema)
ServerDataStore.setData("mymod", "quests", "nb_point", 42);
ServerDataStore.setData("mymod", "quests", "status", "completed");
ServerDataStore.setData("mymod", "settings", "pvp_enabled", true);

// Custom objects
QuestData quest = ServerDataStore.getCustom("mymod", "quests", "quest_data");
if (quest != null) {
    quest.setNbPoints(100);
    ServerDataStore.setData("mymod", "quests", "quest_data", quest);
}

List<Warp> warps = ServerDataStore.getList(EssentialsUtilsCommands.MOD_ID, "warps", "warps");
if (warps != null){
    warps.remove(1);
    ServerDataStore.setData(EssentialsUtilsCommands.MOD_ID, "warps","warps",warps);
}

Screenshots

Gallery

This project has no gallery images yet.

Versions

Files

Relations

Project Relations

More like this

Similar Mods

Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.

On ModDex

Community snapshot

0
Ratings
0
Followers
0
In stacks

By the numbers

Statistics

<1,000
Total Downloads
CurseForge
<1,000
Modrinth
<1,000
Last Updated
CurseForge
Modrinth
Created
CurseForge
Modrinth
Last synced
When ModDex last fetched and imported data for this project from CurseForge or Modrinth. High-traffic and active projects are checked more often.
Next pipeline sync