setRawData()

So I’m doing some architectural and testing work for the plugin I’m going to submit to the next plugin competition.

Part of what I need to do is serialize a player’s data and use/manipulate it, and then potentially restoring it at a later point. I’m testing that with a command, see code below.

        if(source instanceof Player) {
            Player player = (Player) source;
            DataContainer container = player.toContainer();
            SpongeRunnable.of(() -> { //SpongeRunnable is a wrapper class, and I know it works perfectly
                player.setRawData(container);
                player.sendMessage(Text.of(TextColors.AQUA, "Backset your data!"));
            }).runTaskLater(PluginClass.getOperatingInstance(), 5, TimeUnit.SECONDS); //It's not actually named 'PluginClass,' but if I used the actual name, I'd be revealing what my new plugin will do.
        }
        return CommandResult.success();

Whenever I run the above command, the text is shown to me, but none of the data seems to reset. Location is not restored and neither are potion effects.

Any help is appreciated. Is it just unimplemented, and if so, when will it be implemented?

Edit: did some looking around, and it seems that either the Mixins don’t implement this method, or provide a completely empty method body. Does anyone know of another method to do this?

Nobody has bothered to implement raw data yet.
I don’t think there’s any other way using the API right now. I think your best bet is to cast it to the minecraft internal class (EntityPlayerMP), call writeToNBT and use NbtTranslator.translateFrom then do the equivalent in reverse for restoring data (NbtTranslator.translateData then readFromNBT)

Oh but that’s NMS :frowning:
Okay thanks, I’ll probably do that. Thank goodness I developed a little framework to use NMS code in my plugin library.