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