Skip to content

Commit aefa82e

Browse files
authored
Fix /qs clean command on Folia by ensuring main thread execution (#2241)
1 parent cc7ce6d commit aefa82e

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

quickshop-bukkit/src/main/java/com/ghostchu/quickshop/command/subcommand/SubCommand_Clean.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ public SubCommand_Clean(final QuickShop plugin) {
2828
public void onCommand(@NotNull final CommandSender sender, @NotNull final String commandLabel, @NotNull final CommandParser parser) {
2929

3030
plugin.text().of(sender, "command.cleaning").send();
31-
Util.mainThreadRun(() -> executeClean(sender));
32-
}
33-
34-
private void executeClean(@NotNull final CommandSender sender) {
35-
3631
final List<Shop> pendingRemoval = new ArrayList<>();
3732
int i = 0;
3833

@@ -45,19 +40,20 @@ private void executeClean(@NotNull final CommandSender sender) {
4540
shop); // Is selling, but has no stock, and is a chest shop, but is not a double shop.
4641
// Can be deleted safely.
4742
i++;
48-
}
49-
if(plugin.getShopItemBlackList().isBlacklisted(shop.getItem())) {
43+
} else if(plugin.getShopItemBlackList().isBlacklisted(shop.getItem())) {
5044
pendingRemoval.add(shop);
5145
i++;
5246
}
5347
} catch(final IllegalStateException e) {
54-
pendingRemoval.add(shop); // The shop is not there anymore, remove it
48+
pendingRemoval.add(shop);
5549
}
5650
}
5751

5852
for(final Shop shop : pendingRemoval) {
59-
plugin.logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "SYSTEM", false), "/quickshop clean", shop.saveToInfoStorage()));
60-
plugin.getShopManager().deleteShop(shop);
53+
Util.regionThread(shop.getLocation(), () -> {
54+
plugin.logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "SYSTEM", false), "/quickshop clean", shop.saveToInfoStorage()));
55+
plugin.getShopManager().deleteShop(shop);
56+
});
6157
}
6258

6359
MsgUtil.clean();

0 commit comments

Comments
 (0)