From 514cb17f701ee5e14822a819808416fdeafdf94f Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Fri, 10 May 2019 19:25:23 +0800 Subject: [PATCH] Close Inventory when server shutting down Former-commit-id: 4ce43a6f96406a9b5dbe1dc50a1dbd9dd358cf35 [formerly 39a0d86d9e6f77032c2d047416f368c5ba44b16d] Former-commit-id: 303e42588bb61c80a2725a47925140145063969a --- src/main/java/org/maxgamer/quickshop/QuickShop.java | 3 +++ .../java/org/maxgamer/quickshop/Shop/InventoryPreview.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java index 96f45a61a..9876a31b4 100644 --- a/src/main/java/org/maxgamer/quickshop/QuickShop.java +++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java @@ -903,6 +903,9 @@ public class QuickShop extends JavaPlugin { public void onDisable() { if (noopDisable) return; + for (Player player : Bukkit.getOnlinePlayers()) { + player.closeInventory(); + } if (itemWatcherTask != null) { itemWatcherTask.cancel(); } diff --git a/src/main/java/org/maxgamer/quickshop/Shop/InventoryPreview.java b/src/main/java/org/maxgamer/quickshop/Shop/InventoryPreview.java index 0a1045905..ea41b77aa 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/InventoryPreview.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/InventoryPreview.java @@ -63,6 +63,8 @@ public class InventoryPreview implements Listener { } public static boolean isPreviewItem(ItemStack stack) { + if(!stack.hasItemMeta()||!stack.getItemMeta().hasLore()) + return false; List lores = stack.getItemMeta().getLore(); for (String string : lores) { if(string.equals("QuickShop GUI preview item")) {