跳到正文

Biscuit!

作者:mrnavastar

A simple API for working with 1.20.5 cookies and transfers in an easy and secure way!

收藏

介绍

中文介绍正在准备中,下面暂时显示原文。

Maintenance
PRs Welcome

ko-fi

Biscuit!

A simple API for working with 1.20.5 cookies and transfers in an easy and secure way!

Features

  • [x] Cookies as POJOs
  • [x] Injected interfaces on many networking classes
  • [x] Cookie Signing for tamper detection
  • [x] Event system
  • [ ] Automatic identifier generation (May not be possbile)
  • [ ] Encryption
  • [ ] Spreading large data across many cookies

Setup

In your build.gradle include:

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

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

Dev

// Make a class to represent your 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:
Biscuit.register(new Identifier("test", "cookie"), TestCookie.class);

// Register the cookie with a secret for tamper detection. The secret must be the same on all servers requesting this cookie:
Biscuit.register(new Identifier("test", "cookie"), TestCookie.class).setSecret("my_secret");

// Set/Get the cookie from the ServerPlayerEntity, ClientConnection, or any of the network handlers (Not handshake)
TestCookie cookie = new TestCookie("whoohoo!");
player.setCookie(cookie);

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

Set a cookie before your mod (or another mod/the transfer command) transfers the player:

BiscuitEvents.PRE_TRANSFER.register((packet, profile, cookieJar, ci) -> {
    cookieJar.setCookie(cookie);
});

常见问题

Biscuit! 支持哪些 Minecraft 版本?

Biscuit! 支持 Minecraft Java 版 1.20–1.21.10,共 18 个版本,可用的加载器:Fabric / Quilt。下载时注意选择和你游戏版本一致的文件。

Biscuit! 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric / Quilt,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。运行环境:仅服务端。

评论

登录后评论和评分

mrnavastar 的其他作品

查看全部 →