MorePersistentDataTypes
Adds a ton of new PersistentDataTypes, including support for all collections, maps and arrays to the Bukkit API!
Install / Use
/learn @mfnalex/MorePersistentDataTypesREADME
MorePersistentDataTypes & Collections, Maps and Arrays for PDC!
<!--- Buttons start --> <p align="center"> <a href="https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/"> <img src="https://static.jeff-media.com/img/button_spigotmc_thread.png?3" alt="SpigotMC Thread"> </a> <a href="https://hub.jeff-media.com/javadocs/morepersistentdatatypes"> <img src="https://static.jeff-media.com/img/button_javadocs.png?3" alt="Javadocs"> </a> <a href="https://discord.jeff-media.com/"> <img src="https://static.jeff-media.com/img/button_discord.png?3" alt="Discord"> </a> <a href="https://paypal.me/mfnalex"> <img src="https://static.jeff-media.com/img/button_donate.png?3" alt="Donate"> </a> </p> <!--- Buttons end --> <p align="center"> <a href="https://maven-badges.herokuapp.com/maven-central/com.jeff-media/MorePersistentDataTypes"> <img src="https://maven-badges.herokuapp.com/maven-central/com.jeff-media/MorePersistentDataTypes/badge.png" alt="Maven" /></a> <img src="https://img.shields.io/github/last-commit/mfnalex/MorePersistentDataTypes" /> </p>MorePersistentDataTypes is a tiny library that provides a ton of new PersistentDataTypes to use in conjunction with Bukkit's PersistentDataContainer. It also allows you to use any kind of Collection, Map or Array to store your data.
Features
- Adds new PersistentDataTypes for ItemStacks, YamlConfigurations, UUIDs, Locations, and much more!
- Allows to use any kind of Collection, Map or Array as PersistentDataType!
- Of course also supports unlimited levels of nested Collections like
LinkedHashMap<String,List<ItemStack>> - See below for more information
- Of course also supports unlimited levels of nested Collections like
It is also possible to easily create your own PersistentDataTypes for your custom objects. When they already implement ConfigurationSerializable, it's only one line of code!
It also has the default data types built in, so you can access everything from one class. See at the bottom for a list of all new data types.
Example
You want to save an ItemStack inside a PersistentDataContainer - normally you would have to serialize the ItemStack to a byte array first, or worse, to a base64 String. With MorePersistentDataTypes, you can simply do this:
pdc.set(someNamespacedKey, DataType.ITEM_STACK,myItemStack);
Furthermore, you can store EVERYTHING that implements ConfigurationSerializable using DataType.CONFIGURATION_SERIALIZABLE.
Using Collections, Arrays or Maps
Using collections, arrays or maps is easy. There are predefined methods for certain collection and map types:
Map<String, ItemStack> map = pdc.get(someKey, DataType.asMap(DataType.STRING, DataType.ITEM_STACK));
If you want to use a special collection or map class that's not already included, simply pass a Supplier that returns an empty instance of your desired collection or map type. More information can be found in the Javadocs (see button at the top of this page).
TreeSet<Location> set = pdc.get(someKey, DataType.asGenericCollection(TreeSet::new, DataType.LOCATION));
For arrays, you should use the builtin default array DataType if one exists, for example DataType.STRING_ARRAY. If there is no already existing array DataType, like for UUIDs, you can use the DataType.asArray method:
PersistentDataType<?, UUID[]> uuidArrayDataType = DataType.asArray(new UUID[0], DataType.UUID);
Maven
Repository
The artifact is available on Maven Central. You don't need to add a repository to your pom.xml.
Dependency
<dependency>
<groupId>com.jeff-media</groupId>
<artifactId>MorePersistentDataTypes</artifactId>
<version>2.4.0</version>
<scope>compile</scope>
</dependency>
Relocating and shading
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<relocations>
<relocation>
<pattern>com.jeff_media.morepersistentdatatypes</pattern>
<shadedPattern>YOUR.PACKAGE.morepersistentdatatypes</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
Gradle
Repository
repositories {
mavenCentral()
}
Dependency
dependencies {
implementation 'com.jeff-media:MorePersistentDataTypes:2.4.0'
}
Relocating and shading
Plugins:
plugins {
id 'java'
id "com.github.johnrengelman.shadow" version "7.1.1"
}
ShadowJar:
shadowJar {
relocate 'com.jeff_media.morepersistentdatatypes', 'YOUR.PACKAGE.morepersistentdatatypes'
}
List of all data types
In addition to the default data types
| Name | Saved as | Class | |-----------------|----------|-----------------------| | BOOLEAN | byte | java.lang.Boolean | | BOOLEAN_ARRAY | byte[] | java.lang.Boolean[] | | CHARACTER | int | java.lang.Character | | CHARACTER_ARRAY | int[] | java.lang.Character[] | | DOUBLE_ARRAY | byte[] | java.lang.Double | | FLOAT_ARRAY | byte[] | java.lang.Float | | SHORT_ARRAY | byte[] | java.lang.Short | | STRING_ARRAY | byte[] | java.lang.String[] |
Custom data types
| Name | Saved as | Note | Class | |----------------------------------|----------|---------|--------------------------------------------------------------------| | ATTRIBUTE_MODIFIER | byte[] | | org.bukkit.attribute.AttributeModifier | | ATTRIBUTE_MODIFIER_ARRAY | byte[] | | org.bukkit.attribute.AttributeModifier[] | | BLOCK_DATA | String | | org.bukkit.block.data.BlockData | | BLOCK_VECTOR | byte[] | | org.bukkit.util.BlockVector | | BLOCK_VECTOR_ARRAY | byte[] | | org.bukkit.util.BlockVector[] | | BOUNDING_BOX | byte[] | | org.bukkit.util.BoundingBox | | BOUNDING_BOX_ARRAY | byte[] | | org.bukkit.util.BoundingBox[] | | COLOR | byte[] | | org.bukkit.Color | | COLOR_ARRAY | byte[] | | org.bukkit.Color[] | | CONFIGURATION_SERIALIZABLE | byte[] | | org.bukkit.configuration.serialization.ConfigurationSerializable | | CONFIGURATION_SERIALIZABLE_ARRAY | byte[] | | org.bukkit.configuration.serialization.ConfigurationSerializable[] | | DATE | long | | java.util.Date | | FILE_CONFIGURATION | String | | org.bukkit.configuration.file.FileConfiguration | | FIREWORK_EFFECT | byte[] | | org.bukkit.FireworkEffect | | FIREWORK_EFFECT_ARRAY | byte[] | | org.bukkit.FireworkEffect[] | | ITEM_META | byte[] | | org.bukkit.inventory.meta.ItemMeta | | ITEM_META_ARRAY | byte[] | | org.bukkit.inventory.meta.ItemMeta[] | | ITEM_STACK | byte[] | | org.bukkit.inventory.ItemStack | | ITEM_STACK_ARRAY | byte[] | | org.bukkit.inventory.ItemStack[] | | LOCATION | byte[] | | org.bukkit.Location | | LOCATION_ARRAY | byte[] | | org.bukkit.Location[] | | OFFLINE_PLAYER | byte[] | | org.bukkit.OfflinePlayer | | OFFLINE_PLAYER_ARRAY | byte[] | | org.bukkit.OfflinePlayer[] | | PATTERN | byte[] | | org.bukkit.block.banner.Pattern | | PATTERN_ARRAY | byte[] | | org.bukkit.block.banner.Pattern[] | | PLAYER | byte[] | | org.bukkit.entity.Player | | PLAYER_ARRAY | byte[] | | org.bukkit.entity.Player[] | | PLAYER_PROFILE | byte[] | 1.18.1+ | org.bukkit.profile.PlayerProfile | | PLAYER_PROFILE_ARRAY | byte[] | 1.18.1+ | org.bukkit.profile.PlayerProfile[] | | POTION_EFFECT | byte[] | | org.bukkit.potion.PotionEffect | | POTION_EFFECT_ARRAY | byte[] | | org.bukkit.potion.Potio
Related Skills
gh-issues
338.0kFetch GitHub issues, spawn sub-agents to implement fixes and open PRs, then monitor and address PR review comments. Usage: /gh-issues [owner/repo] [--label bug] [--limit 5] [--milestone v1.0] [--assignee @me] [--fork user/repo] [--watch] [--interval 5] [--reviews-only] [--cron] [--dry-run] [--model glm-5] [--notify-channel -1002381931352]
oracle
338.0kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
tmux
338.0kRemote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output.
xurl
338.0kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
