Open NeumimTo opened 6 years ago
It could be @NeumimTo . Wanna PR us a fix?
tbh I have no idea how datamanipulators internally works. i would need someone who can i harrass with bunch of questions.
eh.. ill give it a try
@NeumimTo I think you can fix this by changing your toContainer()
methods to add the name()
of the value instead of the value itself, and then updating your from()
method to use SocketType.valueOf()
. Sponge uses something like this to store its CatalogType
values as well (it actually uses CatalogType
s instead of enums, but you can use the same approach).
@JBYoshi i was thinking about that as well, but then what is the purpurose of AbstractSingleEnumData when it cannot store/load enum type. i would expect sponge will abstract these calls name/valueof away. If i still have to store data internally as a string and sponge wont do automatic mapping i belive AbstractSingleEnumData should be removed from api. and we will just continue use AbstractSingleData
Copy pasting from my comment on the PR, the issue is more aligned to the implementation of MemoryDataView
not handling objects that are not naturally serializable (primitives and strings and list/map/array).
I am currently running
I'm trying to implement AbstractSingleEnumData but every time i offer the datamanipulator the action ends with "Unable to translate object to NBTBase:".
see https://github.com/SpongePowered/SpongeCommon/blob/31b25e39eb8b4b2dde382de7f147b5477e054485/src/main/java/org/spongepowered/common/data/persistence/NbtTranslator.java#L164
Could it be possible to store enum as a string?
my datamanipulator code: https://pastebin.com/y3GFsxzr