Fabric Plugin Messaging 图标

Fabric Plugin Messaging

作者:rebot | 分类:模组

价格:0 墨喵币 下载量:0 点赞:0 版本 1.0.0
本资源为搬运资源,原资源地址: https://modrinth.com/mod/fabric-plugin-messaging
资源信息

Minecraft 版本: 1.21.1 1.21.2 1.21.3 1.21.4

平台: fabric

标签: library

资源介绍

Fabric Plugin Messaging

Enviroment Server Discord

A Fabric plugin messaging library! This server-sided mod will register a Plugin Message Packet (PluginMessagePacket.class) and a Plugin Message Event (PluginMessageEvent#EVENT) for developers to use in their projects.

Without this mod, developers would need to register their own packets, which would cause conflicts if multiple are present at the same time. By using the Packet and Listener provided here, this issue is avoided.

Developer Info

Add the mod as a dependency in your gradle build script! This will include the API in your final build.

dependencies {
    modImplementation(include("com.pokeskies:fabricpluginmessage:1.0.0"))
}

Sending

Then you can send Plugin Messages by creating an instance of the PluginMessagePacket class and then sending it! You can either create it by passing a byte array or a FriendlyByteBuf:

ByteArrayDataOutput outputStream = ByteStreams.newDataOutput();
outputStream.writeUTF("Connect");
outputStream.writeUTF("cobblemon");

ServerPlayNetworking.send(player, new PluginMessagePacket(outputStream.toByteArray()));

Receiving

If you need to receive a Plugin Message from the proxy, you can subscribe to the PluginMessageEvent:

PluginMessageEvent.EVENT.register((payload, context) -> {
    ByteArrayDataInput inputStream  = ByteStreams.newDataInput(payload.getData());
    String channel = inputStream.readUTF();
    if (channel.equals("GetServers")) {
        String serversList = inputStream.readUTF();
        System.out.println("Proxy Servers: " + serversList);
    }
});

Support

A community support Discord has been opened up for all Skies Development related projects! Feel free to join and ask questions or leave suggestions :)

下载太慢?试试 墨喵加速站,支持 Modrinth 和外网直链高速下载! 用的人越多,下载的越快!
下载与版本
评论(0)
登录 后发表评论。

暂无评论,抢个沙发吧~

举报此资源

请登录后举报

🔥 相关推荐
Pepopack

价格:0 墨喵币
下载量:0

查看详情
Lots Of Addons

价格:0 墨喵币
下载量:0

查看详情
Iron Ender Chests

价格:0 墨喵币
下载量:0

查看详情
Wall Climbers

价格:0 墨喵币
下载量:0

查看详情