Invalid Data Exception with Custom Data

I have recently been fooling around with custom data and seem to have an issue during server startup. You can view the Stack Trace here. It seems to mention that it can’t find the DisguiseData class which is very weird since I don’t know why it wouldn’t be included in the jar. I checked the jar with jd-gui and when I view the classes for DisguiseData (DisguiseData and ImmutableDisguiseData) it gives me an internal error. Now, I don’t know whether that is just a coincidence with jdgui but I am inclined to not think that since that is one of the classes not found.

Hopefully I am not making some stupid compiling error, I don’t know how I would be since I haven’t changed anything since my previous builds. You can view the DisguiseData class here if that would be any help.

You did change the registration:

[15:48:33] [Server thread/ERROR] [STDERR]: Caused by: java.lang.ClassNotFoundException: net.huntersharpe.Disguise.DisguiseData

The DisguiseData class that it’s attempting to look up is no longer available, since you’ve moved your custom data to et.huntersharpe.Disguise.data.DisguiseData.

It’s a known issue with how Custom Data is preserved without a string id. To temporarily fix this, you can move the DisguiseData class back up a package, or ignore the future errors and re-create the data, or edit all the NBT compounds to point to the right class.

1 Like

Thanks @gabizou and now when I try to retrieve my custom data from a player I says there’s no value present.

Method of Giving Data

player.offer(DisguiseKeys.IDENTIFIER, disguisedEntity.getUniqueId().toString());
//& 
player.offer(new DisguiseData("PIG", disguisedEntity.getUniqueId().toString()))
//ignore the pig part thats just another Disguise Key - (DisguiseKeys.ENTITY_TYPE)

Method of Retrieving Data

Entity entity = event.getTargetEntity().getWorld().getEntity(UUID.fromString(event.getTargetEntity().get(DisguiseKeys.IDENTIFIER).get())),get();
//Which is where I get the no value present.

the above is where I am getting the error “event.getTargetEntity().get(DisguiseKeys.IDENTIFIER)” I presume I am either incorrectly offering the data which I’ve tried offering it both ways or incorrectly retrieving the data.
You can view my DisguiseKeys class here if that would help.

After some more research into the documentation and other threads on here. I have tested out other theories and while I have solved my above issue as well as others but I am left with a IllegalArgumentException with the DataManipulator seen here. Line 63:

//I've switched my method of retrieval to .getOrCreate()
disguisedEntity.getOrCreate(DisguiseData.class).get().set(DisguiseKeys.IDENTIFIER, player.getUniqueId());

No I don’t know if I create a new issue by doing that or I did not create my Data Manipulator correctly.

Sorry to bump but as this is still an issue for me, I think it is appropriate.

Just going to leave this here: https://github.com/SpongePowered/SpongeCommon/issues/1102
It is an issue that I’m working on but it does require a fair bit of work to get done and resolved.

Whether it will resolve your issue is a different question, but for now, I believe your issue is just how your custom data is set up, which I’ll hopefully reply in the coming days (quite busy with the end of year things to do).