3737import org .spongepowered .common .accessor .nbt .CompoundTagAccessor ;
3838import org .spongepowered .common .bridge .data .DataCompoundHolder ;
3939import org .spongepowered .common .bridge .data .SpongeDataHolderBridge ;
40- import org .spongepowered .common .data .persistence .NBTTranslator ;
4140import org .spongepowered .common .data .persistence .datastore .SpongeDataStore ;
4241import org .spongepowered .common .util .Constants ;
4342
@@ -65,7 +64,7 @@ public static <T extends SpongeDataHolderBridge & DataCompoundHolder> void deser
6564 if (compound == null ) {
6665 return ;
6766 }
68- final DataContainer allData = NBTTranslator . INSTANCE . translate (compound );
67+ final DataContainer allData = new CompoundTagDataContainer (compound );
6968
7069 DataUtil .upgradeDataVersion (compound , allData ); // Upgrade v2->v3
7170
@@ -189,9 +188,8 @@ public static <T extends SpongeDataHolderBridge & DataCompoundHolder> boolean se
189188 (t , o ) -> ((CompoundTagAccessor ) o ).invoker$entrySet ().forEach (e -> t .put (e .getKey (), e .getValue ().copy ()))
190189 );
191190 }
192- dataHolder .data$setCompound (compound );
193191
194- final DataContainer allData = NBTTranslator . INSTANCE . translate (compound );
192+ final DataContainer allData = new CompoundTagDataContainer (compound );
195193
196194 // Clear old custom data root
197195 final DataView customDataRoot = allData .createView (Constants .Sponge .Data .V3 .SPONGE_DATA_ROOT );
@@ -204,25 +202,22 @@ public static <T extends SpongeDataHolderBridge & DataCompoundHolder> boolean se
204202 .map (key -> SpongeDataManager .getDatastoreRegistry ().getDataStore (key , dataHolderType ))
205203 .forEach (dataStore -> dataStore .serialize (manipulator , allData ));
206204
207- // If data is still present after cleanup merge it back into nbt
208- if (DataUtil .cleanupEmptySpongeData (allData )) {
209- compound .merge (NBTTranslator .INSTANCE .translate (allData ));
210- }
205+ DataUtil .cleanupEmptySpongeData (allData );
211206 if (compound .isEmpty ()) {
212207 dataHolder .data$setCompound (null );
213208 return false ;
209+ } else {
210+ dataHolder .data$setCompound (compound );
214211 }
215212 return true ;
216213 }
217214
218- private static boolean cleanupEmptySpongeData (final DataContainer allData ) {
219- return allData .getView (Constants .Sponge .Data .V3 .SPONGE_DATA_ROOT ).map (spongeData -> {
215+ private static void cleanupEmptySpongeData (final DataContainer allData ) {
216+ allData .getView (Constants .Sponge .Data .V3 .SPONGE_DATA_ROOT ).ifPresent (spongeData -> {
220217 if (spongeData .isEmpty ()) {
221218 allData .remove (Constants .Sponge .Data .V3 .SPONGE_DATA_ROOT );
222- return false ;
223219 }
224- return true ;
225- }).orElse (false );
220+ });
226221 }
227222
228223 public static void setSpongeData (final DataView allData , final DataQuery dataStoreKey , final DataView pluginData , final int version ) {
0 commit comments