{"id":19716332,"url":"https://github.com/bluemap-minecraft/bluenbt","last_synced_at":"2025-04-29T20:30:44.601Z","repository":{"id":177797119,"uuid":"657587037","full_name":"BlueMap-Minecraft/BlueNBT","owner":"BlueMap-Minecraft","description":"NBT Library inspired by Gson","archived":false,"fork":false,"pushed_at":"2024-12-22T15:38:44.000Z","size":2907,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-05T19:03:50.312Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BlueMap-Minecraft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-23T11:44:07.000Z","updated_at":"2024-12-22T15:38:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"32fabdd3-a773-4863-8b95-b02e72318c17","html_url":"https://github.com/BlueMap-Minecraft/BlueNBT","commit_stats":null,"previous_names":["bluemap-minecraft/bluenbt"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlueMap-Minecraft%2FBlueNBT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlueMap-Minecraft%2FBlueNBT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlueMap-Minecraft%2FBlueNBT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlueMap-Minecraft%2FBlueNBT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlueMap-Minecraft","download_url":"https://codeload.github.com/BlueMap-Minecraft/BlueNBT/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251578271,"owners_count":21612006,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T22:41:48.811Z","updated_at":"2025-04-29T20:30:44.563Z","avatar_url":"https://github.com/BlueMap-Minecraft.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BlueNBT\nBlueNBT is an NBT (De)Serializer with an API inspired by the [GSON](https://github.com/google/gson) library.\nIt's basically GSON for NBT instead of JSON data.\nIf you used GSON before you will feel right at home!\n\n## Requirements\nBlueNBT requires **Java 21**\n\n## Adding BlueNBT to your Project\n\n### Gradle\n```kotlin\nrepositories {\n    maven ( \"https://repo.bluecolored.de/releases\" )\n}\n\ndependencies {\n    implementation ( \"de.bluecolored:bluenbt:3.0.3\" )\n}\n```\n\n### Maven\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ebluecolored\u003c/id\u003e\n        \u003curl\u003ehttps://repo.bluecolored.de/releases\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003ede.bluecolored\u003c/groupId\u003e\n    \u003cartifactId\u003ebluenbt\u003c/artifactId\u003e\n    \u003cversion\u003e3.0.3\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Usage\n**[API Javadoc](https://repo.bluecolored.de/javadoc/releases/de/bluecolored/bluenbt/BlueNBT/latest)**\n\nThe primary class to use is [`BlueNBT`](https://github.com/BlueMap-Minecraft/BlueNBT/blob/master/src/main/java/de/bluecolored/bluenbt/BlueNBT.java). \nYou can easily create yourself an instance using `new BlueNBT()`. You can configure each BlueNBT instance separately with\ndifferent settings and Type(De)Serializers. You can reuse the same BlueNBT instance for as many (de)serialization operations\nas you like.\n\n### First Example\nFirst you want to declare the data-structure that you want to write/read to/from an NBT-Data stream.   \nFor Example:\n```java\nclass MyData {\n    int someNumber;\n    String someString;\n    long[] anArrayOfLongs;\n    List\u003cMoreData\u003e aLotMoreData;\n}\n\nclass MoreData {\n    boolean isData;\n    Map\u003cString, List\u003cString\u003e\u003e muchData; \n}\n```\nNow all you need to do to write all this data to an NBT-file is: \n```java\nBlueNBT blueNBT = new BlueNBT();\ntry (\n        OutputStream out = Files.newOutputStream(Path.of(\"myFile.nbt\"));\n        OutputStream compressedOut = new BufferedOutputStream(new GzipOutputStream(out))\n){\n    blueNBT.write(myData, compressedOut);\n}\n```\nAnd reading it again is equally easy:\n```java\nBlueNBT blueNBT = new BlueNBT();\ntry ( \n        InputStream in = Files.newInputStream(Path.of(\"myFile.nbt\"));\n        InputStream compressedIn = new BufferedInputStream(new GZIPInputStream(in))\n){\n    MyData myData = blueNBT.read(compressedIn, MyData.class);\n}\n```\n\n\u003e [!NOTE]\n\u003e Both times we GZIP(De)Compressed our streams before writing/reading. This is because usually all nbt-files are\n\u003e GZIP-Compressed, BlueNBT does **not** do this for us to allow more flexibility.  \n\u003e Also, make sure to use buffered streams before (de)compression to greatly improve compression-performance.\n\n### Using TypeTokens\nSometimes you have a type with generic type-variables that you want to deserialize, for example `HashMap\u003cString, Integer\u003e`. \nHowever, you can't easily create a `Class\u003c?\u003e` or `Type` for such a type that you can use to call `BlueNBT#read(InputStream in, Class\u003cT\u003e type)`.\nThis is where `TypeToken`s come in.  \nYou can create a `TypeToken` in multiple ways:\n```java\n// simply from a Class\u003c?\u003e or Type\nTypeToken.of(String.class) // String\n\n// for an array of a certain type\nTypeToken.array(String.class) // String[]\n\n// for a raw Class\u003c?\u003e with additional type-parameters\nTypeToken.of(Map.class, String.class, Integer.class) // Map\u003cString, Integer\u003e\n\n// or by creating a generic anonymous subclass of TypeToken\nnew TypeToken\u003c Map\u003cString, Collection\u003cInteger\u003e\u003e \u003e() {} // Map\u003cString, Collection\u003cInteger\u003e\u003e\n```\nYou can then pass this `TypeToken` to e.g. `BlueNBT#read(InputStream in, TypeToken\u003cT\u003e type)`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluemap-minecraft%2Fbluenbt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbluemap-minecraft%2Fbluenbt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluemap-minecraft%2Fbluenbt/lists"}