Skip to content

Commit 3b83039

Browse files
committed
re-add delay shop loading
1 parent a68d20b commit 3b83039

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/main/java/org/maxgamer/quickshop/shop/ShopLoader.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import lombok.Getter;
2626
import lombok.Setter;
2727
import org.apache.commons.lang.StringUtils;
28+
import org.bukkit.Bukkit;
2829
import org.bukkit.Location;
2930
import org.bukkit.Material;
3031
import org.bukkit.World;
@@ -92,6 +93,8 @@ public void loadShops(@Nullable String worldName) {
9293
int loaded = 0;
9394
int total = 0;
9495
int valid = 0;
96+
List<Shop> pendingLoading = new ArrayList<>();
97+
9598
try (WarpedResultSet warpRS = plugin.getDatabaseHelper().selectAllShops(); ResultSet rs = warpRS.getResultSet()) {
9699
Timer timer = new Timer();
97100
timer.start();
@@ -158,18 +161,23 @@ public void loadShops(@Nullable String worldName) {
158161
//TODO: Only remove from memory, so if it actually is a bug, user won't lost all shops.
159162
//TODO: Old shop will be deleted when in same location creating new shop.
160163
} else {
161-
shop.onLoad();
162-
shop.update();
164+
pendingLoading.add(shop);
163165
++loaded;
164166
}
165167
} else {
166168
loadAfterChunkLoaded++;
167169
}
168170
}
171+
Bukkit.getScheduler().runTaskLater(plugin, () -> {
172+
for (Shop shop : pendingLoading) {
173+
shop.onLoad();
174+
shop.update();
175+
}
176+
}, 1);
169177
this.plugin.getLogger().info(">> Shop Loader Information");
170178
this.plugin.getLogger().info("Total shops: " + total);
171179
this.plugin.getLogger().info("Valid shops: " + valid);
172-
this.plugin.getLogger().info("Loaded shops: " + loaded);
180+
this.plugin.getLogger().info("Pending loading shops: " + loaded);
173181
this.plugin.getLogger().info("Waiting worlds loaded: " + loadAfterWorldLoaded);
174182
this.plugin.getLogger().info("Waiting chunks loaded: " + loadAfterChunkLoaded);
175183
this.plugin.getLogger().info("Done! Used " + timer.stopAndGetTimePassed() + "ms to loaded shops in database.");

0 commit comments

Comments
 (0)