Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,6 @@ you can see the config file in `.minecraft/config/dglab.yml`, when you first sta
* A String to set the ws address, if your computer and your phone installed `DG-LAB` in same LAN, can set it to `192.168.xx.xx` that your computer ip address
- port (int)
* the port to create ws server, and DG-LAB app will connect it.
- bukkitCompatibilityMode (boolean)
* If true, DG-LAB payloads will be treated as optional channels, so the client can accept `dglab:*` custom payloads from non-NeoForge servers (e.g., Bukkit/Paper). Default: `false`.
* If your server is Bukkit/Paper and you have installed Minecraft-DG-LAB-Bukkit plugin, please set this option to `true`.
2 changes: 2 additions & 0 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,5 @@
* 一个字符串来设置 WebSocket 连接地址,如果你的电脑和你的安装 DG-LAB 的手机在同一个局域网,可以设置此值为类似 `192.168.xx.xx`,这是你电脑的 ip 地址,可以运行 `ipconfig` 来查看。
- port (int)
* 运行 WebSocket Server 的端口,将会在这个端口的 WebSocket Server 和你的 DG-LAB APP 连接。
- bukkitCompatibilityMode (boolean)
* Bukkit 兼容模式。如果设置为 `true`,客户端将允许接收来自非 NeoForge 服务器(如 Bukkit/Paper)的 `dglab:*` 自定义数据包。默认为 `false`。若您的服务器是 Bukkit/Paper 且安装了 Minecraft-DG-LAB-Bukkit 插件,请开启此选项。
9 changes: 9 additions & 0 deletions src/main/java/cn/dancingsnow/dglab/config/ConfigHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ public static class ClientConfigs {
@Configurable.Comment({"If true, will show current strength in hud", "Default: true"})
public boolean enabled = true;

@Configurable
@Configurable.Comment({
"Bukkit 兼容模式。",
"如果启用,DG-LAB 的数据包将被视为可选通道,",
"使得客户端可以接收来自非 NeoForge 服务器(如 Bukkit/Paper)的 dglab:* 自定义数据包。",
"默认值:false"
})
public boolean bukkitCompatibilityMode = false;

@Configurable
@Configurable.Comment({"The Gui Hud Scale", "Default: 1"})
public float hudScale = 1;
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/cn/dancingsnow/dglab/networking/DgLabPackets.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cn.dancingsnow.dglab.DgLabMod;
import cn.dancingsnow.dglab.api.Strength;
import cn.dancingsnow.dglab.client.ClientData;
import cn.dancingsnow.dglab.config.ConfigHolder;

import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
Expand All @@ -13,13 +14,16 @@

public class DgLabPackets {
public static void init(PayloadRegistrar registrar) {
registrar.playToClient(
PayloadRegistrar r =
ConfigHolder.INSTANCE.client.bukkitCompatibilityMode ? registrar.optional() : registrar;

r.playToClient(
Strength.TYPE, Strength.STREAM_CODEC, (strength, ctx) -> ClientData.setStrength(strength));

registrar.playToClient(
r.playToClient(
ClearStrength.TYPE, ClearStrength.STREAM_CODEC, (c, ctx) -> ClientData.setStrength(null));

registrar.playToClient(
r.playToClient(
ShowQrCode.TYPE, ShowQrCode.STREAM_CODEC, (show, ctx) -> ClientData.setQrText(show.text()));
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/dglab/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"config.dglab.option.hudScale": "HUD Scale",
"config.dglab.option.hudX": "HUD X",
"config.dglab.option.hudY": "HUD Y",
"config.dglab.option.bukkitCompatibilityMode": "Bukkit Compatibility Mode",
"config.dglab.option.port": "Port",
"config.dglab.option.webSocket": "WebSocket Settings",
"config.dglab.option.useHttps": "Use Https",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/dglab/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"config.dglab.option.hudScale": "HUD 缩放",
"config.dglab.option.hudX": "HUD X",
"config.dglab.option.hudY": "HUD Y",
"config.dglab.option.bukkitCompatibilityMode": "Bukkit 兼容模式",
"config.dglab.option.port": "端口",
"config.dglab.option.webSocket": "WebSocket 设置",
"config.dglab.option.useHttps": "使用 Https",
Expand Down
Loading