From 4412bea7b83bc0f2f80b906cdc32c3c2a11b5b2c Mon Sep 17 00:00:00 2001 From: themode Date: Sun, 8 Nov 2020 20:13:24 +0100 Subject: [PATCH] NBTUtils comments and contributors link in README.md --- .github/README.md | 1 + .../net/minestom/server/utils/NBTUtils.java | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.github/README.md b/.github/README.md index 2b3f4101c..29c15ae2d 100644 --- a/.github/README.md +++ b/.github/README.md @@ -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. # 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) - protocol and file formats research. * [The Minecraft Wiki](https://minecraft.gamepedia.com/Minecraft_Wiki) for all their useful info diff --git a/src/main/java/net/minestom/server/utils/NBTUtils.java b/src/main/java/net/minestom/server/utils/NBTUtils.java index 4de564447..05246b0e9 100644 --- a/src/main/java/net/minestom/server/utils/NBTUtils.java +++ b/src/main/java/net/minestom/server/utils/NBTUtils.java @@ -360,6 +360,14 @@ public final class NBTUtils { // End NbtData } + /** + * Converts an object into its {@link NBT} equivalent. + * + * @param value + * @param type + * @param supportDataType + * @return + */ @Nullable public static NBT toNBT(@NotNull Object value, @NotNull Class type, boolean supportDataType) { type = PrimitiveConversion.getObjectClass(type); @@ -407,6 +415,15 @@ public final class NBTUtils { } } + /** + * Converts a nbt object to its raw value. + *

+ * 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) { if (nbt instanceof NBTNumber) { return ((NBTNumber) nbt).getValue();