|
25 | 25 | import lombok.Getter; |
26 | 26 | import lombok.Setter; |
27 | 27 | import org.apache.commons.lang.StringUtils; |
| 28 | +import org.bukkit.Bukkit; |
28 | 29 | import org.bukkit.Location; |
29 | 30 | import org.bukkit.Material; |
30 | 31 | import org.bukkit.World; |
@@ -92,6 +93,8 @@ public void loadShops(@Nullable String worldName) { |
92 | 93 | int loaded = 0; |
93 | 94 | int total = 0; |
94 | 95 | int valid = 0; |
| 96 | + List<Shop> pendingLoading = new ArrayList<>(); |
| 97 | + |
95 | 98 | try (WarpedResultSet warpRS = plugin.getDatabaseHelper().selectAllShops(); ResultSet rs = warpRS.getResultSet()) { |
96 | 99 | Timer timer = new Timer(); |
97 | 100 | timer.start(); |
@@ -158,18 +161,23 @@ public void loadShops(@Nullable String worldName) { |
158 | 161 | //TODO: Only remove from memory, so if it actually is a bug, user won't lost all shops. |
159 | 162 | //TODO: Old shop will be deleted when in same location creating new shop. |
160 | 163 | } else { |
161 | | - shop.onLoad(); |
162 | | - shop.update(); |
| 164 | + pendingLoading.add(shop); |
163 | 165 | ++loaded; |
164 | 166 | } |
165 | 167 | } else { |
166 | 168 | loadAfterChunkLoaded++; |
167 | 169 | } |
168 | 170 | } |
| 171 | + Bukkit.getScheduler().runTaskLater(plugin, () -> { |
| 172 | + for (Shop shop : pendingLoading) { |
| 173 | + shop.onLoad(); |
| 174 | + shop.update(); |
| 175 | + } |
| 176 | + }, 1); |
169 | 177 | this.plugin.getLogger().info(">> Shop Loader Information"); |
170 | 178 | this.plugin.getLogger().info("Total shops: " + total); |
171 | 179 | this.plugin.getLogger().info("Valid shops: " + valid); |
172 | | - this.plugin.getLogger().info("Loaded shops: " + loaded); |
| 180 | + this.plugin.getLogger().info("Pending loading shops: " + loaded); |
173 | 181 | this.plugin.getLogger().info("Waiting worlds loaded: " + loadAfterWorldLoaded); |
174 | 182 | this.plugin.getLogger().info("Waiting chunks loaded: " + loadAfterChunkLoaded); |
175 | 183 | this.plugin.getLogger().info("Done! Used " + timer.stopAndGetTimePassed() + "ms to loaded shops in database."); |
|
0 commit comments