From 2f1bb148d47f31399e184ddeee8ac1be3efb3e22 Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Wed, 28 Jul 2021 13:30:54 +0800 Subject: [PATCH] Thread-safe update0() method --- .../maxgamer/quickshop/shop/ContainerShop.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java b/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java index 688d258b4..036f90bc0 100644 --- a/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java +++ b/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java @@ -719,7 +719,13 @@ public class ContainerShop implements Shop { Util.debugLog("The Shop update action was canceled by a plugin."); return; } - Bukkit.getScheduler().runTaskAsynchronously(plugin, this::update0); + int x = this.getLocation().getBlockX(); + int y = this.getLocation().getBlockY(); + int z = this.getLocation().getBlockZ(); + String world = Objects.requireNonNull(this.getLocation().getWorld()).getName(); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + update0(world, x, y, z); + }); } private void notifyDisplayItemChange() { @@ -729,13 +735,10 @@ public class ContainerShop implements Shop { } } - private void update0() { + private void update0(String world, int x, int y, int z) { // Make sure this only trigged in async thread, we will start the I/O actions Util.ensureThread(true); - int x = this.getLocation().getBlockX(); - int y = this.getLocation().getBlockY(); - int z = this.getLocation().getBlockZ(); - String world = Objects.requireNonNull(this.getLocation().getWorld()).getName(); + int unlimited = this.isUnlimited() ? 1 : 0; try { plugin.getDatabaseHelper()