diff --git a/pom.xml b/pom.xml
index 267b83011..1fd883b31 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
org.maxgamer
QuickShop
- 3.1.4.8
+ 3.1.4.9
diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java
index 9ea9b4329..e5a6e5c16 100644
--- a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java
+++ b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java
@@ -68,7 +68,6 @@ public class ContainerShop implements Shop {
private double price;
private ShopType shopType;
private boolean unlimited;
- private boolean isDeleted;
private ContainerShop(@NotNull ContainerShop s) {
this.displayItem = s.displayItem;
@@ -399,7 +398,6 @@ public class ContainerShop implements Shop {
if (isLoaded) {
this.onUnload();
}
- isDeleted=true;
// Delete the display item
if (this.getDisplayItem() != null) {
this.getDisplayItem().remove();
@@ -877,11 +875,6 @@ public class ContainerShop implements Shop {
return Util.canBeShop(this.getLocation().getBlock());
}
- @Override
- public boolean isDeleted() {
- return isDeleted;
- }
-
@Override
public @Nullable DisplayItem getDisplay() {
return this.displayItem;
diff --git a/src/main/java/org/maxgamer/quickshop/Shop/Shop.java b/src/main/java/org/maxgamer/quickshop/Shop/Shop.java
index d35293369..592b9957e 100644
--- a/src/main/java/org/maxgamer/quickshop/Shop/Shop.java
+++ b/src/main/java/org/maxgamer/quickshop/Shop/Shop.java
@@ -303,12 +303,6 @@ public interface Shop {
*/
boolean isValid();
- /**
- * Shop is deleted
- *
- * @return true if deleted
- */
- boolean isDeleted();
/**
* Get the shop display entity
diff --git a/src/main/java/org/maxgamer/quickshop/Shop/VirtualDisplayItem.java b/src/main/java/org/maxgamer/quickshop/Shop/VirtualDisplayItem.java
index 6eb86a87d..9bd17de69 100644
--- a/src/main/java/org/maxgamer/quickshop/Shop/VirtualDisplayItem.java
+++ b/src/main/java/org/maxgamer/quickshop/Shop/VirtualDisplayItem.java
@@ -49,7 +49,6 @@ public class VirtualDisplayItem extends DisplayItem {
private static ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
private volatile boolean isDisplay;
- private volatile boolean isLoaded;
//counter for ensuring ID is unique
private static final AtomicInteger counter = new AtomicInteger(0);
//server main version (1_13_R2->13)
@@ -92,11 +91,6 @@ public class VirtualDisplayItem extends DisplayItem {
//is really full chunk data
boolean isFull = event.getPacket().getBooleans().read(0);
- //if shop has deleted, unregister myself to ensure will be collected by GC
- if (!shop.isDeleted()) {
- unload();
- return;
- }
if (!shop.isLoaded() || !isDisplay || !isFull || !Util.isLoaded(shop.getLocation())) {
return;
}
@@ -104,8 +98,8 @@ public class VirtualDisplayItem extends DisplayItem {
int x = event.getPacket().getIntegers().read(0);
//chunk z
int z = event.getPacket().getIntegers().read(1);
-
-
+ //check later to prevent deadlock
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,()->{
World world = shop.getLocation().getWorld();
Chunk chunk = shop.getLocation().getChunk();
if (world.getName().equals(event.getPlayer().getWorld().getName())
@@ -114,8 +108,8 @@ public class VirtualDisplayItem extends DisplayItem {
packetSenders.add(event.getPlayer().getUniqueId());
sendFakeItem(event.getPlayer());
}
- }
- };
+ },1);
+ }};
}
protocolManager.addPacketListener(packetAdapter);
}