How to get Map<Vector3i, BlockState> from config?

Code how I set map to config:

node.setValue(new TypeToken<Map<Vector3i, BlockState>>(){}, schematic.getBlocks());
How it looks:
How Im trying to get it back from config:

Map<Vector3i, BlockState> map = node.getValue(new TypeToken<Map<Vector3i, BlockState>>(){});
Exception: [06:16:35 ERROR] [Sponge]: Could not pass MessageChannelEvent$Chat$Impl to Plugi -

P.S. When I code “node.getValue()” it works fine, but returns me Map<String, String> (not Map<Vector3i, BlockState>)

Well, first of all, it is literally a Map<String, String>. When you supply a different TypeToken, it converts the value. For example, for the string value minecraft:stone, should getValue() return an ItemType, a BlockType, or a BlockState?

Second, you can’t store a string representation of a HOCON object in a key and expect it to be able to parse out. Only objects that can be obtained from a non-complex value (e.g. string) can be used as keys in a Map. Your best bet is to make a class which implements TypeSerializer<Vector3i>, and register it to the settings of your ConfigurationLoader before loading. Make it be able to parse a string like 2,0,-2. Then you’ll be able to use it in keys.

1 Like

Thank you very much, registering my custom TypeSerializer<Vector3i> solved the problem!