{"id":13775244,"url":"https://github.com/mfnalex/MorePersistentDataTypes","last_synced_at":"2025-05-11T07:32:19.192Z","repository":{"id":43010507,"uuid":"394931542","full_name":"mfnalex/MorePersistentDataTypes","owner":"mfnalex","description":"Adds a ton of new PersistentDataTypes, including support for all collections, maps and arrays to the Bukkit API!","archived":false,"fork":false,"pushed_at":"2024-06-14T11:05:09.000Z","size":205,"stargazers_count":61,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-03T17:11:18.771Z","etag":null,"topics":["api","bukkit","persistentdatacontainer","spigot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mfnalex.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.MD","contributing":null,"funding":".github/funding.yml","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},"funding":{"custom":["https://paypal.me/mfnalex"]}},"created_at":"2021-08-11T09:16:53.000Z","updated_at":"2024-07-29T19:11:58.000Z","dependencies_parsed_at":"2024-06-14T12:04:11.217Z","dependency_job_id":"7d142b4e-e732-45d1-8e59-85bd960ea856","html_url":"https://github.com/mfnalex/MorePersistentDataTypes","commit_stats":null,"previous_names":["mfnalex/morepersistentdatatypes"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfnalex%2FMorePersistentDataTypes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfnalex%2FMorePersistentDataTypes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfnalex%2FMorePersistentDataTypes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfnalex%2FMorePersistentDataTypes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mfnalex","download_url":"https://codeload.github.com/mfnalex/MorePersistentDataTypes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225027357,"owners_count":17409417,"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":["api","bukkit","persistentdatacontainer","spigot"],"created_at":"2024-08-03T17:01:35.784Z","updated_at":"2024-11-17T10:30:48.494Z","avatar_url":"https://github.com/mfnalex.png","language":"Java","funding_links":["https://paypal.me/mfnalex"],"categories":["NBT \u0026 PDC"],"sub_categories":[],"readme":"# MorePersistentDataTypes \u0026 Collections, Maps and Arrays for PDC!\n\u003c!--- Buttons start --\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/\"\u003e\n    \u003cimg src=\"https://static.jeff-media.com/img/button_spigotmc_thread.png?3\" alt=\"SpigotMC Thread\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://hub.jeff-media.com/javadocs/morepersistentdatatypes\"\u003e\n    \u003cimg src=\"https://static.jeff-media.com/img/button_javadocs.png?3\" alt=\"Javadocs\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://discord.jeff-media.com/\"\u003e\n    \u003cimg src=\"https://static.jeff-media.com/img/button_discord.png?3\" alt=\"Discord\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://paypal.me/mfnalex\"\u003e\n    \u003cimg src=\"https://static.jeff-media.com/img/button_donate.png?3\" alt=\"Donate\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003c!--- Buttons end --\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://maven-badges.herokuapp.com/maven-central/com.jeff-media/MorePersistentDataTypes\"\u003e\n  \u003cimg src=\"https://maven-badges.herokuapp.com/maven-central/com.jeff-media/MorePersistentDataTypes/badge.png\" alt=\"Maven\" /\u003e\u003c/a\u003e\n\u003cimg src=\"https://img.shields.io/github/last-commit/mfnalex/MorePersistentDataTypes\" /\u003e\n\u003c/p\u003e\n\n**MorePersistentDataTypes** is a tiny library that provides a ton of new *PersistentDataTypes* to use in conjunction\nwith Bukkit's *PersistentDataContainer*. **It also allows you to use any kind of Collection, Map or Array to store your data.**\n\n## Features\n\n- Adds new PersistentDataTypes for ItemStacks, YamlConfigurations, UUIDs, Locations, and much more!\n- **Allows to use any kind of Collection, Map or Array** as PersistentDataType!\n    - Of course also supports unlimited levels of nested Collections like `LinkedHashMap\u003cString,List\u003cItemStack\u003e\u003e`\n    - See below for more information\n\nIt is also possible to easily create your own PersistentDataTypes for your custom objects. When they already implement\nConfigurationSerializable, it's only one line of code!\n\nIt also has the default data types built in, so you can access everything from one class. See at the bottom for a list\nof all new data types.\n\n[Related SpigotMC thread](https://hub.jeff-media.com/nexus/repository/jeff-media-public/)\n\n## Example\n\nYou want to save an ItemStack inside a PersistentDataContainer - normally you would have to serialize the ItemStack to a\nbyte array first, or worse, to a base64 String. With **MorePersistentDataTypes**, you can simply do this:\n\n```java\npdc.set(someNamespacedKey, DataType.ITEM_STACK,myItemStack);\n```\n\nFurthermore, you can store EVERYTHING that implements ConfigurationSerializable using\nDataType.CONFIGURATION_SERIALIZABLE.\n\n## Using Collections, Arrays or Maps\n\nUsing collections, arrays or maps is easy. There are predefined methods for certain collection and map types:\n\n```java\nMap\u003cString, ItemStack\u003e map = pdc.get(someKey, DataType.asMap(DataType.STRING, DataType.ITEM_STACK));\n```\n\nIf you want to use a special collection or map class that's not already included, simply pass a Supplier that returns\nan empty instance of your desired collection or map type. More information can be found in the Javadocs (see button at\nthe top of this page).\n\n```java\nTreeSet\u003cLocation\u003e set = pdc.get(someKey, DataType.asGenericCollection(TreeSet::new, DataType.LOCATION));\n```\n\nFor arrays, you should use the builtin default array DataType if one exists, for example DataType.STRING_ARRAY. If there is\nno already existing array DataType, like for UUIDs, you can use the DataType.asArray method:\n\n```java\nPersistentDataType\u003c?, UUID[]\u003e uuidArrayDataType = DataType.asArray(new UUID[0], DataType.UUID);\n```\n\n## Maven\n\n### Repository\n\nThe artifact is available on Maven Central. You don't need to add a repository to your pom.xml.\n\n### Dependency\n\n```xml\n\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.jeff-media\u003c/groupId\u003e\n    \u003cartifactId\u003eMorePersistentDataTypes\u003c/artifactId\u003e\n    \u003cversion\u003e2.4.0\u003c/version\u003e\n    \u003cscope\u003ecompile\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n### Relocating and shading\n\n```xml\n\u003cbuild\u003e\n    \u003cplugins\u003e\n        \u003cplugin\u003e\n            \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n            \u003cartifactId\u003emaven-shade-plugin\u003c/artifactId\u003e\n            \u003cversion\u003e3.5.0\u003c/version\u003e\n            \u003cexecutions\u003e\n                \u003cexecution\u003e\n                    \u003cphase\u003epackage\u003c/phase\u003e\n                    \u003cgoals\u003e\n                        \u003cgoal\u003eshade\u003c/goal\u003e\n                    \u003c/goals\u003e\n                \u003c/execution\u003e\n            \u003c/executions\u003e\n            \u003cconfiguration\u003e\n                \u003crelocations\u003e\n                    \u003crelocation\u003e\n                        \u003cpattern\u003ecom.jeff_media.morepersistentdatatypes\u003c/pattern\u003e\n                        \u003cshadedPattern\u003eYOUR.PACKAGE.morepersistentdatatypes\u003c/shadedPattern\u003e\n                    \u003c/relocation\u003e\n                \u003c/relocations\u003e\n            \u003c/configuration\u003e\n        \u003c/plugin\u003e\n    \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\n## Gradle\n\n### Repository\n\n```groovy\nrepositories {\n    mavenCentral()\n}\n```\n\n### Dependency\n\n```groovy\ndependencies {\n    implementation 'com.jeff-media:MorePersistentDataTypes:2.4.0'\n}\n```\n\n### Relocating and shading\n\nPlugins:\n```groovy\nplugins {\n    id 'java'\n    id \"com.github.johnrengelman.shadow\" version \"7.1.1\"\n}\n```\n\nShadowJar:\n```groovy\nshadowJar {\n    relocate 'com.jeff_media.morepersistentdatatypes', 'YOUR.PACKAGE.morepersistentdatatypes'\n}\n```\n\n\n## List of all data types\n\n### In addition to the default data types\n\n| Name            | Saved as | Class                 |\n|-----------------|----------|-----------------------|\n| BOOLEAN         | byte     | java.lang.Boolean     |\n| BOOLEAN_ARRAY   | byte[]   | java.lang.Boolean[]   |\n| CHARACTER       | int      | java.lang.Character   |\n| CHARACTER_ARRAY | int[]    | java.lang.Character[] |\n| DOUBLE_ARRAY    | byte[]   | java.lang.Double      |\n| FLOAT_ARRAY     | byte[]   | java.lang.Float       |\n| SHORT_ARRAY     | byte[]   | java.lang.Short       |\n| STRING_ARRAY    | byte[]   | java.lang.String[]    |\n\n### Custom data types\n\n| Name                             | Saved as | Note    | Class                                                              |\n|----------------------------------|----------|---------|--------------------------------------------------------------------|\n| ATTRIBUTE_MODIFIER               | byte[]   |         | org.bukkit.attribute.AttributeModifier                             |\n| ATTRIBUTE_MODIFIER_ARRAY         | byte[]   |         | org.bukkit.attribute.AttributeModifier[]                           |\n| BLOCK_DATA                       | String   |         | org.bukkit.block.data.BlockData                                    |\n| BLOCK_VECTOR                     | byte[]   |         | org.bukkit.util.BlockVector                                        |\n| BLOCK_VECTOR_ARRAY               | byte[]   |         | org.bukkit.util.BlockVector[]                                      |\n| BOUNDING_BOX                     | byte[]   |         | org.bukkit.util.BoundingBox                                        |\n| BOUNDING_BOX_ARRAY               | byte[]   |         | org.bukkit.util.BoundingBox[]                                      |\n| COLOR                            | byte[]   |         | org.bukkit.Color                                                   |\n| COLOR_ARRAY                      | byte[]   |         | org.bukkit.Color[]                                                 |\n| CONFIGURATION_SERIALIZABLE       | byte[]   |         | org.bukkit.configuration.serialization.ConfigurationSerializable   |\n| CONFIGURATION_SERIALIZABLE_ARRAY | byte[]   |         | org.bukkit.configuration.serialization.ConfigurationSerializable[] |\n| DATE                             | long     |         | java.util.Date                                                     |\n| FILE_CONFIGURATION               | String   |         | org.bukkit.configuration.file.FileConfiguration                    |\n| FIREWORK_EFFECT                  | byte[]   |         | org.bukkit.FireworkEffect                                          |\n| FIREWORK_EFFECT_ARRAY            | byte[]   |         | org.bukkit.FireworkEffect[]                                        |\n| ITEM_META                        | byte[]   |         | org.bukkit.inventory.meta.ItemMeta                                 |\n| ITEM_META_ARRAY                  | byte[]   |         | org.bukkit.inventory.meta.ItemMeta[]                               |\n| ITEM_STACK                       | byte[]   |         | org.bukkit.inventory.ItemStack                                     |\n| ITEM_STACK_ARRAY                 | byte[]   |         | org.bukkit.inventory.ItemStack[]                                   |\n| LOCATION                         | byte[]   |         | org.bukkit.Location                                                |\n| LOCATION_ARRAY                   | byte[]   |         | org.bukkit.Location[]                                              |\n| OFFLINE_PLAYER                   | byte[]   |         | org.bukkit.OfflinePlayer                                           |\n| OFFLINE_PLAYER_ARRAY             | byte[]   |         | org.bukkit.OfflinePlayer[]                                         |\n| PATTERN                          | byte[]   |         | org.bukkit.block.banner.Pattern                                    |\n| PATTERN_ARRAY                    | byte[]   |         | org.bukkit.block.banner.Pattern[]                                  |\n| PLAYER                           | byte[]   |         | org.bukkit.entity.Player                                           |\n| PLAYER_ARRAY                     | byte[]   |         | org.bukkit.entity.Player[]                                         |\n| PLAYER_PROFILE                   | byte[]   | 1.18.1+ | org.bukkit.profile.PlayerProfile                                   |\n| PLAYER_PROFILE_ARRAY             | byte[]   | 1.18.1+ | org.bukkit.profile.PlayerProfile[]                                 |\n| POTION_EFFECT                    | byte[]   |         | org.bukkit.potion.PotionEffect                                     |\n| POTION_EFFECT_ARRAY              | byte[]   |         | org.bukkit.potion.PotionEffect[]                                   |\n| UUID                             | byte[]   |         | java.util.UUID                                                     |\n| VECTOR                           | byte[]   |         | org.bukkit.util.Vector                                             |\n| VECTOR_ARRAY                     | byte[]   |         | org.bukkit.util.Vector[]                                           |\n\n## Creating your own PersistentDataTypes\n\n### Using ConfigurationSeriazableDataType\n\nWhen your custom Object already implements ConfigurationSerializable, it's even easier. Just look at the\nSerializablePerson.java in the examples/ folder.\n\nTo make it storable in a PersistentDataContainer, this is all you need:\n\n```java\nPersistentDataType\u003cbyte[],SerializablePerson\u003e personType = new ConfigurationSerializableDataType\u003c\u003e(SerializablePerson.class);\n```\n\nYou can also directly store arrays of your own ConfigurationSerializable objects:\n\n```java\nPersistentDataType\u003cbyte[],SerializablePerson[]\u003e personArrayType = new ConfigurationSerializableArrayDataType\u003c\u003e(SerializablePerson.class,SerializablePerson[].class);\n```\n\n### Using GenericDataType\n\nYou can also easily create own generic PersistentDataTypes by creating a new `GenericDataType` instance. It expects 4\nparameters:\n\n1. The primitive type that's used to store the object\n2. The complex type / the class of which you want to store an instance of\n3. A method that converts your object into the primitive type\n4. A method that converts the primitive type into your object again\n\nFor example, this returns a PersistentDataType\u003cLong,Date\u003e that can save `java.util.Date` objects inside a\nPersistentDataContainer:\n\n```java\nPersistentDataType\u003cLong, Date\u003e dateType = new GenericDataType\u003c\u003e(Long.class,Date.class,Date::new,Date::getTime);\n```\n\n## Building\n\nBuilding this requires Java 17.0.0 or higher. It can still be used by Java 8 or higher, though.\n\n## Javadocs\n\nYou can find the Javadocs here: https://hub.jeff-media.com/javadocs/morepersistentdatatypes/\n\n## Other libraries by me\n\n### [CustomBlockData](https://github.com/JEFF-Media-GbR/CustomBlockData)\n\n**MorePersistentDataTypes** goes perfectly well together with my **CustomBlockData** library, that provides a\nPersistentDataContainer for every block in your world - without any external storage needed!\n\n### [Spigot UpdateChecker](https://github.com/JEFF-Media-GbR/Spigot-UpdateChecker)\n\nPowerful **UpdateChecker** for your plugins, with only one line of code.\n\n## Discord\n\nIf you need help, feel free to join my Discord server and head to #programming-help:\n\n\u003ca href=\"https://discord.jeff-media.de\"\u003e\u003cimg src=\"https://api.jeff-media.de/img/discord1.png\"\u003e\u003c/a\u003e\n\n## Donate\n\nIf you are using this project in your paid plugins, or if you just want to buy me a coffee, I would be happy over a\nsmall donation :)\n\n\u003ca href=\"https://paypal.me/mfnalex\"\u003e\u003cimg src=\"https://www.paypalobjects.com/en_US/DK/i/btn/btn_donateCC_LG.gif\" border=\"0\" name=\"submit\" title=\"PayPal - The safer, easier way to pay online!\" alt=\"Donate with PayPal\" /\u003e\u003c/a\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfnalex%2FMorePersistentDataTypes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmfnalex%2FMorePersistentDataTypes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfnalex%2FMorePersistentDataTypes/lists"}