I would say you could poke around in my code, with this being the class it’s trying to save, and with the addition of this in the main plugin file;
Sponge.getDataManager().register(ShopReferenceData.class, ImmutableShopReferenceData.class, new ShopReferenceDataManipulatorBuilder());
Sponge.getDataManager().registerBuilder(ShopReference.class, new ShopReferenceBuilder());
… However, while it works in game, it has problems persisting after reloading the server . Best of luck, and if you find anything that works, let me know!
I have created the infrastructure for the values I want to store.
Then I register these item during pre-init event of the plugin:
open class AlmaEconSimPlugin(val cmdFactory:ICommandFactory = CommandFactory()) {
@Inject lateinit var logger: Logger
@Inject lateinit var game: Game
@Listener
fun onPreInit(event: GamePreInitializationEvent) {
registerSimData()
[...]
}
[...]
protected fun registerSimData() {
Sponge.getDataManager().register(SimData::class.java, ImmutableSimData::class.java,
SimDataManipulatorBuilder())
}
At another place in the code I create a villager and want to set the initial value of DAYS_SINCE_LAST_MEAL to 0.
if (villager.supports(SimKeys.DAYS_SINCE_LAST_MEAL)) {
val simData = villager.getOrCreate(SimData::class.java).get()
simData.daysSinceLastMeal().set(0)
}
How can I now set the value of that property (DAYS_SINCE_LAST_MEAL) to some value? Like I did above (simData.daysSinceLastMeal().set(0)) or differently?