# PayloadLib
更简便的方法,让 **Paper** 服务器发送和处理自定义负载,简单而强大。
请参考我们的 [GitHub 仓库](https://github.com/NLR-DevTeam/PayloadLib) 获取更多信息。
## 导入
要访问 PayloadLib 的快照版本,请在你的 `build.gradle` 中添加以下内容:
```groovy
repositories {
maven {
name = 'Central Portal Snapshots'
url = 'https://central.sonatype.com/repository/maven-snapshots/'
}
}
dependencies {
implementation 'top.nlrdev:payloadlib:0.0.2-SNAPSHOT'
// 可选依赖,提供 ByteBuf
implementation 'io.netty:netty-buffer:4.2.2.Final'
}
```
不建议将此插件嵌入到其他插件 JAR 中,因为它可能导致各种问题。
## 支持的数据类型
### 原始类型
| 原始类型 | 包装类型 | 数组 | 无符号实现 |
| --------- | --------- | ------------- | ------------------------------------------- |
| boolean | Boolean | _Unsupported_ | _None_ |
| byte | Byte | byte[] | _None_ |
| short | Short | _Unsupported_ | `top.nlrdev.payloadlib.types.UnsignedShort` |
| char | Character | _Unsupported_ | _None_ |
| int | Integer | _Unsupported_ | _None_ |
| long | Long | _Unsupported_ | _None_ |
| float | Float | _Unsupported_ | _None_ |
| double | Double | _Unsupported_ | _None_ |
### 非原始类型
| 类型 | PayloadLib |
| ---------------------- | ----------- |
| String | _Unchanged_ |
| UUID | _Unchanged_ |
| `org.joml.Vector3f` | _Unchanged_ |
| `org.joml.Quaternionf` | _Unchanged_ |
| Minecraft (官方) | Minecraft (Yarn) | PayloadLib |
| ------------------------------------------ | ---------------------------------- | ---------------------------------------- |
| `net.minecraft.resources.ResourceLocation` | `net.minecraft.util.Identifier` | `top.nlrdev.payloadlib.types.Identifier` |
| `ByteBufCodecs#VAR_INT` | `PacketCodecs#VAR_INT` | `top.nlrdev.payloadlib.types.VarInt` |
| `ByteBufCodecs#VAR_LONG` | `PacketCodecs#VAR_LONG` | `top.nlrdev.payloadlib.types.VarLong` |
| `net.minecraft.world.phys.Vec3` | `net.minecraft.util.math.Vec3d` | `org.joml.Vector3d` |
| `net.minecraft.core.BlockPos` | `net.minecraft.util.math.BlockPos` | `top.nlrdev.payloadlib.types.BlockPos` |
## 示例
你可以参考这些实时示例来获取灵感:
- [XIAYM-gh/SittingPlus-uwu-Bukkit](https://github.com/XIAYM-gh/SittingPlus-uwu-Bukkit)
## 许可
此模组采用 MIT 许可。