@@ -279,12 +279,20 @@ public synchronized void recoverFromFile(@NotNull String fileContent) {
279279 plugin .getLogger ().info ("Recovering shops..." );
280280 Gson gson = JsonUtil .getGson ();
281281 int total = shopsPlain .length ;
282- for ( int i = 0 ; i < total ; i ++) {
283- String shopStr = shopsPlain [ i ]. trim ();
284- boolean success = false ;
282+ List < ShopRawDatabaseInfo > list = new ArrayList <>( total );
283+ for ( String s : shopsPlain ) {
284+ String shopStr = s . trim () ;
285285 try {
286- ShopRawDatabaseInfo shopDatabaseInfoOrigin = gson .fromJson (shopStr , ShopRawDatabaseInfo .class );
287- ShopDatabaseInfo data = new ShopDatabaseInfo (shopDatabaseInfoOrigin );
286+ list .add (gson .fromJson (shopStr , ShopRawDatabaseInfo .class ));
287+ } catch (JsonSyntaxException ignore ) {
288+ }
289+ }
290+ plugin .getLogger ().info ("Processed " + total + "/" + total + " - [ Valid " + list .size () + "]" );
291+ // Load to RAM
292+ Util .mainThreadRun (() -> {
293+ plugin .getLogger ().info ("Loading recovered shops..." );
294+ for (ShopRawDatabaseInfo rawDatabaseInfo : list ) {
295+ ShopDatabaseInfo data = new ShopDatabaseInfo (rawDatabaseInfo );
288296 Shop shop =
289297 new ContainerShop (plugin ,
290298 data .getLocation (),
@@ -300,18 +308,13 @@ public synchronized void recoverFromFile(@NotNull String fileContent) {
300308 if (shopNullCheck (shop )) {
301309 continue ;
302310 }
303- // Load to RAM
304- Util .mainThreadRun (() -> {
305- plugin .getDatabaseHelper ().createShop (shop , null , null );
306- plugin .getShopManager ().loadShop (data .getWorld ().getName (), shop );
307- shop .update ();
308- });
309-
310- success = true ;
311- } catch (JsonSyntaxException ignore ) {
311+ plugin .getDatabaseHelper ().createShop (shop , null , null );
312+ plugin .getShopManager ().loadShop (data .getWorld ().getName (), shop );
313+ shop .update ();
312314 }
313- plugin .getLogger ().info ("Processed " + i + "/" + total + " - [" + success + "]" );
314- }
315+ plugin .getLogger ().info ("Finished!" );
316+ });
317+
315318 }
316319
317320// @NotNull
0 commit comments