From 817f1566b11f3f56a09033849dcb2dbaebfee4fa Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Tue, 18 Jun 2019 10:06:19 +0800 Subject: [PATCH] Display's fixes Former-commit-id: 53d775624320b7ca630b2cfedd8ed2165da75419 [formerly ac2d47b5e233a759cd14b8cf87c254171f0695ae] Former-commit-id: 449ec164c9f6d0e20af609883eade3164f442e98 --- .../quickshop/Listeners/ChunkListener.java | 37 +++++++++---------- .../quickshop/Shop/ContainerShop.java | 8 ++-- .../maxgamer/quickshop/Shop/DisplayItem.java | 8 ++++ 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/ChunkListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/ChunkListener.java index 20470dd7f..a9fe9f23c 100644 --- a/src/main/java/org/maxgamer/quickshop/Listeners/ChunkListener.java +++ b/src/main/java/org/maxgamer/quickshop/Listeners/ChunkListener.java @@ -10,7 +10,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkUnloadEvent; -import org.bukkit.scheduler.BukkitRunnable; import org.maxgamer.quickshop.QuickShop; import org.maxgamer.quickshop.Shop.Shop; @@ -26,16 +25,16 @@ public class ChunkListener implements Listener { HashMap inChunk = plugin.getShopManager().getShops(c); if (inChunk == null || inChunk.isEmpty()) return; - new BukkitRunnable() { - - @Override - public void run() { - for (Shop shop : inChunk.values()) { - shop.onLoad(); - } - - } - }.runTaskLater(plugin, 1); //Delay 1 tick, hope can fix the magic bug in 1.14 spigot build. + // new BukkitRunnable() { + // + // @Override + // public void run() { + for (Shop shop : inChunk.values()) { + shop.onLoad(); + } + // + // } + // }.runTaskLater(plugin, 1); //Delay 1 tick, hope can fix the magic bug in 1.14 spigot build. } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @@ -44,13 +43,13 @@ public class ChunkListener implements Listener { HashMap inChunk = plugin.getShopManager().getShops(c); if (inChunk == null || inChunk.isEmpty()) return; - new BukkitRunnable() { - @Override - public void run() { - for (Shop shop : inChunk.values()) { - shop.onUnload(); - } - } - }.runTaskLater(plugin, 1); //Delay 1 tick, hope can fix the magic bug in 1.14 spigot build. + // new BukkitRunnable() { + // @Override + // public void run() { + for (Shop shop : inChunk.values()) { + shop.onUnload(); + } + // } + // }.runTaskLater(plugin, 1); //Delay 1 tick, hope can fix the magic bug in 1.14 spigot build. } } \ No newline at end of file diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java index 38b9b205e..9eab88f52 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java @@ -733,10 +733,10 @@ public class ContainerShop implements Shop { return; } - if (!Util.isLoaded(this.getLocation())) { - Util.debugLog("Shop " + this.getLocation().toString() + " skipped to load: Target location not loaded."); - return; - } + // if (!Util.isLoaded(this.getLocation())) { + // Util.debugLog("Shop " + this.getLocation().toString() + " skipped to load: Target location not loaded."); + // return; + // } if (!Util.canBeShop(this.getLocation().getBlock())) { this.onUnload(); diff --git a/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java b/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java index 9f98dd080..a62888281 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java @@ -142,6 +142,10 @@ public interface DisplayItem { for (String lore : lores) { try { ShopProtectionFlag shopProtectionFlag = gson.fromJson(lore, ShopProtectionFlag.class); + if (shopProtectionFlag == null) + continue; + if (shopProtectionFlag.getMark() == null) + continue; if (shopProtectionFlag.getMark().equals("QuickShop DisplayItem")) return true; } catch (JsonSyntaxException e) { @@ -170,6 +174,10 @@ public interface DisplayItem { for (String lore : lores) { try { ShopProtectionFlag shopProtectionFlag = gson.fromJson(lore, ShopProtectionFlag.class); + if (shopProtectionFlag == null) + continue; + if (shopProtectionFlag.getMark() == null) + continue; if (shopProtectionFlag.getShopLocation().equals(shop.getLocation().toString())) return true; } catch (JsonSyntaxException e) {