Class NBTMapNormalizer
java.lang.Object
io.github.projectunified.craftitem.nbt.NBTMapNormalizer
Normalizes maps and converts them to the right types for SNBT.
Takes raw map data and recursively converts it to properly typed values. Also supports custom string translators for dynamic substitution.
Bonus Feature - Forced-Value Maps:
Use $type and $value keys to force a specific type:
Map<String, Object> map = Map.of(
"$type", "float",
"$value", "123.45"
);
Object result = NBTMapNormalizer.normalize(map); // Returns 123.45f
Supported types: byte, short, int, long, float, double, boolean, string, raw, list, compound, byte_array, int_array, long_array. Useful when Java's default type would be wrong.
-
Method Summary
-
Method Details
-
normalize
Normalizes a value by resolving forced-value maps and applying translator- Parameters:
value- The value to normalize- Returns:
- Normalized value (can be a Map, primitive, or array)
- Throws:
IllegalArgumentException- if forced-value map is invalid
-
normalize
Normalizes a value by resolving forced-value maps and applying translator- Parameters:
value- The value to normalizetranslator- Custom string translator for values- Returns:
- Normalized value (can be a Map, primitive, or array)
- Throws:
IllegalArgumentException- if forced-value map is invalid
-