Offline Player Cache: Directors Cut

Offline Player Cache: Directors Cut

An API Mod to allow caching player data on the server while the player is offline. This means that mods can use this API to access offline player's data.

by
7.0K Downloads
fabricforgeneoforgequiltlibrarystorageutility
Rent Server with this Mod

About this Mod

Offline Player Cache Banner

fabric quilt forge

java gradle


Preamble 📝

Offline Player Cache: Directors Cut has been completely redone from the ground up, and its framework predates 1.* and below.
This was developed in mind to have persistent leaderboards for servers for their offline players.

Content 📦

Modders may register Record's linked with an id and a Codec to serialize/deserialize it.

Upon a player's disconnection from the server, their cached data is stored into the servers level data, which then can be accessed through code or through the commands the mod provides.

Upon a player's reconnection to the server, their cached data is deleted.

Commands

/opc get <uuid>|<name> <key>

Provides details about the current player value. If they are online, it will provide their current value, but if they are offline, it will provide their cached value.

/opc remove <uuid>|<name> <key>

If the player with the associated username or UUID is offline, it will remove that players cached value based on the selected key.
If the player is online, nothing will occur with this command.

/opc list <uuid>|<name>

Lists all the keys and values this player has stored if they are offline, or if they are online, their current ones.

Developers Guide

Setup

Offline Player Cache has a Modrinth and Curseforge page.

In order to develop with the API, please add the following:

gradle.properties

opc_version=...

build.gradle

repositories {
    maven {
        name = "Modrinth"
        url = "https://api.modrinth.com/maven"
        content {
            includeGroup "maven.modrinth"
        }
    }
}

dependencies {
    modImplementation "maven.modrinth:opc-directors-cut:${project.opc_version}"
    // include this if you do not want to force your users to install the mod.
    include "maven.modrinth:opc-directors-cut:${project.opc_version}"
}
Alternatively, if you are using Kotlin DSL:

build.gradle.kts

repositories {
    maven {
        name = "Modrinth"
        url = uri("https://api.modrinth.com/maven")
        content {
            includeGroup("maven.modrinth")
        }
    }
}

dependencies {
    modImplementation("maven.modrinth:opc-directors-cut:${properties["opc_version"]}")
    // include this if you do not want to force your users to install the mod.
    include("maven.modrinth:opc-directors-cut:${properties["opc_version"]}")
}

Migration to 2.*

  • There are no longer any concepts of keys. Instead, you are to register an id, a Record, and a Codec.

Creating a Record

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;

public record Contract(String label, boolean signed) {
    public static Codec<Contract> CODEC = RecordCodecBuilder.create((instance) ->
        instance.group(
            Codec.STRING.fieldOf("label").forGetter(Contract::label),
            Codec.BOOL.fieldOf("signed").forGetter(Contract::signed)
        ).apply(instance, Contract::new)
    );
}

Registering

import maven_group.modid.concept.Contract; // Контракт :)

// somewhere during static/mod initialization
private void init() {
    OfflinePlayerCacheAPI.register(CONTRACT_RECORD_ID, Contract.class, Contract.CODEC, (Player player) -> {
        // within this block, you decide how to translate a player's data to the Record you chose.
        return new Contract(player.getName() + ":contracted", true);
    });
}

Obtaining

var cache = OfflinePlayerCacheAPI.getCache(server);
cache.getEntry(Contract.class, "bibi_reden").ifPresent(contract -> {
    // we now know that there is a valid Contract entry for this player.
    // You can also use a UUID to fetch an entry as well.
});

A Special Thanks to our Sponsor


Sponsor Banner

Use code "BAREMINIMUM" to get 15% off your first month!

Available Versions

1.0.0+1.20.1release
MC 1.20.1forge, neoforge
May 19, 2024
1.0.0+1.20.1release
MC 1.20.1fabric, quilt
May 16, 2024
0.6.5+1.20.1release
MC 1.20.1fabric
December 29, 2023

How to Install Offline Player Cache: Directors Cut on Your Server

1

Order Server

Order a Minecraft Java server with at least 3 GB RAM (4 GB recommended).

2

Set fabric Loader

In the panel under "Egg", select the fabric loader and matching Minecraft version (1.21).

3

Install Mod

Open the mod browser in the dashboard and search for "Offline Player Cache: Directors Cut". Click "Install" – done! Alternatively, upload the .jar via SFTP to the /mods folder.

Compatibility

Mod Loaders

fabricforgeneoforgequilt

Minecraft Versions

1.21, 1.20.6, 1.20.5 (+4 more)

Server-side

Required

Recommended RAM

4 GB(min. 3 GB)

Frequently Asked Questions

Offline Player Cache: Directors Cut server crashes on startup – what to do?

Most common cause: wrong fabric version or insufficient RAM. Check the server log (latest.log) for "OutOfMemoryError" or "Mixin" errors. With Mado Hosting: ensure at least 3 GB RAM is allocated and the loader matches the mod version (1.21). You can switch loaders with one click in the panel.

Is Offline Player Cache: Directors Cut compatible with fabric and forge and neoforge and quilt?

Offline Player Cache: Directors Cut officially supports fabric, forge, neoforge, quilt for Minecraft 1.21, 1.20.6, 1.20.5. Note: Forge and Fabric mods are NOT cross-compatible – pick one loader and stick with it. The Mado dashboard automatically detects incompatible loader combinations.

Server lagging with Offline Player Cache: Directors Cut – how to optimize performance?

Recommended RAM: 4 GB (per 8 players). Use /spark profiler to check if Offline Player Cache: Directors Cut consumes the most tick time. Common fixes: reduce server view-distance to 8-10, install "performant" or "starlight" as supplementary mods on Forge. With Mado Hosting, your server runs on NVMe SSDs with dedicated CPU cores for minimal latency.

Rent Modded Server

Install Offline Player Cache: Directors Cut with just one click on your server.

Recommended RAM
4 GBab €8/mo
Min. 3 GB | +1 GB pro 8 Spieler
Create Server Now
1-Click Mod Install
NVMe SSD Storage
DDoS Protection included

Details

License
MIT License
Server-side
Required

Supported Versions

1.211.20.61.20.51.20.41.20.31.20.21.20.1