i try to De-serializing ItemStack from confignode,but get errors
“java.lang.IllegalStateException: Item type has not been set”
and i found ConfigurateTranslator.instance().translateFrom(node)
include “node”'s path info
test code: cfg.getNode("item").setValue(TypeToken.of(ItemStack.class),p.getItemInHand().get()); saveconfig("config.conf"); Sponge.getServer().getBroadcastChannel().send(Text.of(ConfigurateTranslator.instance().translateFrom(cfg.getNode("item")))); Sponge.getServer().getBroadcastChannel().send(Text.of(p.getItemInHand().get().toContainer()));
There might be an issue with the ConfigurateTranslator, please print out what the translated DataView is after translating it from the ConfigurationNode.
you mean this ? DataView dv = ConfigurateTranslator.instance().translateFrom(cfg.getNode("item")); System.out.println(dv)
and this is ConfigurationNode: item { ContentVersion=1 Count=1 ItemType="minecraft:chest" UnsafeDamage=0 }
and this is console message : [15:38:16 INFO] [STDOUT]: [ysjdmg.Ysjdmg.reloadcfg(Ysjdmg.java:358)]: MemoryDataContainer{map={item=MemoryDataView{path=item, map={ContentVersion=1, ItemType=minecraft:chest, Count=1, UnsafeDamage=0}}}}