Download Biscuit! — Minecraft Mods — MetaMods

Biscuit!

Active

Downloads

0

Last update

10 months ago

Versions

1.20 — 1.21.9
Server
Fabric
Quilt
Libraries
Technological
Utils

Biscuit!

The mod provides a convenient programming interface for working with the cookie system and player transfer mechanism in Minecraft version 1.20.5. The solution is designed with an emphasis on ease of use and data security.

Main Features

Working with cookies as objects - cookies are represented as simple java objects (POJO), which greatly simplifies their processing and manipulation in code.

Integration into network classes - the mod adds special interfaces to most classes related to network interaction, ensuring natural integration of cookie functionality.

Tamper protection - a cookie signing system is implemented that allows detecting unauthorized changes to transmitted data.

Event system - a flexible event model allows developers to respond to various stages of working with cookies and server switching.

In the module's development plans:

  • Automatic identifier generation (may require additional implementation)
  • Built-in data encryption
  • Distribution of large amounts of information across multiple cookies

Project Setup

To connect the library to your project, add the following lines to the build.gradle file:

repositories {
    maven { url "https://api.modrinth.com/maven" }
}

dependencies {
  modImplementation("maven.modrinth:biscuit!:1.1.0")
}

Usage Examples

// Create a class to represent a cookie
public static class TestCookie {

    private final String data;

    public TestCookie(String data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return data;
    }
}

// Register the cookie in the system
Biscuit.register(new Identifier("test", "cookie"), TestCookie.class);

// Register with tamper protection
// The secret phrase must be the same on all related servers
Biscuit.register(new Identifier("test", "cookie"), TestCookie.class)
    .setSecret("my_secret");

// Setting and getting cookies is possible for:
// - ServerPlayerEntity objects
// - ClientConnection
// - Various network handlers (except handshake)
TestCookie cookie = new TestCookie("great work!");
player.setCookie(cookie);

player.getCookie(TestCookie.class).whenComplete((result, error) -> {
    System.out.println(result);
});

Setting a cookie before transferring a player between servers:

BiscuitEvents.PRE_TRANSFER.register((packet, profile, container, exit) -> {
    container.setCookie(cookie);
});
Project members
mrnavastar

mrnavastar

Developer

Created: 25 Apr 2024

ID: 23178