NBTUtils comments and contributors link in README.md

This commit is contained in:
themode 2020-11-08 20:13:24 +01:00
parent 11fc1e39bc
commit 4412bea7b8
2 changed files with 18 additions and 0 deletions

1
.github/README.md vendored
View File

@ -84,6 +84,7 @@ It is a field where Minecraft evolved a lot, inventories are now used a lot as c
Commands are the simplest way of communication between clients and server. Since 1.13 Minecraft has incorporated a new library denominated "Brigadier", we then integrated an API meant to use the full potential of args types. Commands are the simplest way of communication between clients and server. Since 1.13 Minecraft has incorporated a new library denominated "Brigadier", we then integrated an API meant to use the full potential of args types.
# Credits # Credits
* The [contributors](https://github.com/Minestom/Minestom/graphs/contributors) of the project
* [The Minecraft Coalition](https://wiki.vg/) and [`#mcdevs`](https://github.com/mcdevs) - * [The Minecraft Coalition](https://wiki.vg/) and [`#mcdevs`](https://github.com/mcdevs) -
protocol and file formats research. protocol and file formats research.
* [The Minecraft Wiki](https://minecraft.gamepedia.com/Minecraft_Wiki) for all their useful info * [The Minecraft Wiki](https://minecraft.gamepedia.com/Minecraft_Wiki) for all their useful info

View File

@ -360,6 +360,14 @@ public final class NBTUtils {
// End NbtData // End NbtData
} }
/**
* Converts an object into its {@link NBT} equivalent.
*
* @param value
* @param type
* @param supportDataType
* @return
*/
@Nullable @Nullable
public static NBT toNBT(@NotNull Object value, @NotNull Class type, boolean supportDataType) { public static NBT toNBT(@NotNull Object value, @NotNull Class type, boolean supportDataType) {
type = PrimitiveConversion.getObjectClass(type); type = PrimitiveConversion.getObjectClass(type);
@ -407,6 +415,15 @@ public final class NBTUtils {
} }
} }
/**
* Converts a nbt object to its raw value.
* <p>
* Currently support number, string, byte/int/long array.
*
* @param nbt the nbt tag to convert
* @return the value representation of a tag
* @throws UnsupportedOperationException if the tag type is not supported
*/
public static Object fromNBT(@NotNull NBT nbt) { public static Object fromNBT(@NotNull NBT nbt) {
if (nbt instanceof NBTNumber) { if (nbt instanceof NBTNumber) {
return ((NBTNumber) nbt).getValue(); return ((NBTNumber) nbt).getValue();