From 84e336f4bf68849932962414c0cdb24276c3af66 Mon Sep 17 00:00:00 2001 From: sandtechnology <20417547+sandtechnology@users.noreply.github.com> Date: Sat, 29 Feb 2020 11:12:34 +0800 Subject: [PATCH 1/4] Remove useless code Former-commit-id: ef4e7e9473a0129dc70e231955703bc0d8d78a77 --- .../java/org/maxgamer/quickshop/Shop/ContainerShop.java | 7 ------- src/main/java/org/maxgamer/quickshop/Shop/Shop.java | 6 ------ .../org/maxgamer/quickshop/Shop/VirtualDisplayItem.java | 7 ------- 3 files changed, 20 deletions(-) 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..7f23e3b51 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; } @@ -105,7 +99,6 @@ public class VirtualDisplayItem extends DisplayItem { //chunk z int z = event.getPacket().getIntegers().read(1); - World world = shop.getLocation().getWorld(); Chunk chunk = shop.getLocation().getChunk(); if (world.getName().equals(event.getPlayer().getWorld().getName()) From 70786ae10c7012306c28baaa192467a822256c7c Mon Sep 17 00:00:00 2001 From: sandtechnology <20417547+sandtechnology@users.noreply.github.com> Date: Sat, 29 Feb 2020 11:32:52 +0800 Subject: [PATCH 2/4] 3.1.4.8 Former-commit-id: a25026128b448b7e49a6814473325f004ce547bb --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 95325ed2e..267b83011 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.maxgamer QuickShop - 3.1.4.7 + 3.1.4.8 From 0b92a68e199f8f56582357bdcf4bf2034777b91b Mon Sep 17 00:00:00 2001 From: sandtechnology <20417547+sandtechnology@users.noreply.github.com> Date: Sat, 29 Feb 2020 11:46:39 +0800 Subject: [PATCH 3/4] solve the Deadlock Former-commit-id: babe2b9523ded9f6f76b12a1320897a628eaf924 --- .../org/maxgamer/quickshop/Shop/VirtualDisplayItem.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Shop/VirtualDisplayItem.java b/src/main/java/org/maxgamer/quickshop/Shop/VirtualDisplayItem.java index 7f23e3b51..9bd17de69 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/VirtualDisplayItem.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/VirtualDisplayItem.java @@ -98,7 +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()) @@ -107,8 +108,8 @@ public class VirtualDisplayItem extends DisplayItem { packetSenders.add(event.getPlayer().getUniqueId()); sendFakeItem(event.getPlayer()); } - } - }; + },1); + }}; } protocolManager.addPacketListener(packetAdapter); } From 08516b0db829497d779ccdac2c88445c6758979c Mon Sep 17 00:00:00 2001 From: sandtechnology <20417547+sandtechnology@users.noreply.github.com> Date: Sat, 29 Feb 2020 11:53:35 +0800 Subject: [PATCH 4/4] 3.1.4.9 Former-commit-id: a77969987ebaaeaecdd87a26d7fce489d8713f89 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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