Set Forge custom Data to player

Hi,

I have a probleme to set NBT to player i save they nbt when he player logout and i want to sync these nbt with all my server and i want to set these nbt to the player when he login on server
Isave player data with that

private static final DataQuery UnsafeData = DataQuery.of("UnsafeData","ForgeCaps");
DataContainer container = new org.spongepowered.api.data.MemoryDataContainer();
container.set(UnsafeData,player.toContainer().getView(DataQuery.of("UnsafeData","ForgeCaps")).get());
ByteArrayOutputStream out = new ByteArrayOutputStream();
@Cleanup
GZIPOutputStream zipOut = new GZIPOutputStream(out) {
	{
				def.setLevel(Deflater.BEST_COMPRESSION);
	}
};

DataFormats.NBT.writeTo(zipOut, container);

zipOut.close();

saving data is working is when i want to reset this data to player that don’t work i use this code

ByteArrayInputStream in = new ByteArrayInputStream(data);
GZIPInputStream zipIn = new GZIPInputStream(in);
DataContainer container = DataFormats.NBT.readFrom(zipIn);
Optional<DataView> unsafedata = container.getView(UnsafeData);
player.setRawData(unsafedata.get());

if someone have an idea tell me

That’s a bad advice, but if you limit your mod to forge (“ForgeCaps”), i’d just use NBTTagCompounds

how can i do this have you got some exemple pls

You have a player, cast it to EntityPlayerMC and call the seralization if you want to save the player to a nbt, and deserialization if you want to load the player from a nbt