From b1b06e370a39bee0b6cba6eafe8e203ca7ea5190 Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Thu, 20 Jun 2019 10:49:36 +0800 Subject: [PATCH] Fix an bug and add logs Former-commit-id: eedfa23ddabcba6a901f091209fce8e764953256 [formerly fb5d5fafe762c5390e1af93ae7938a9efc925c04] Former-commit-id: a33dfbb6a9b5da277e6886c87e34dbb13c7bcc11 --- .../java/org/maxgamer/quickshop/Util/Util.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java index 75c546491..6cb096c74 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/Util.java +++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java @@ -258,8 +258,10 @@ public class Util { * @return the block which is also a chest and connected to b. */ public static Block getSecondHalf(@NotNull Block b) { - if (!isDoubleChest(b)) + if (!isDoubleChest(b)) { + Util.debugLog("Target block not a DoubleChest, ignored."); return null; + } Chest oneSideOfChest = (Chest) b.getState(); InventoryHolder chestHolder = oneSideOfChest.getInventory().getHolder(); if (chestHolder instanceof DoubleChest) { @@ -269,14 +271,17 @@ public class Util { Chest leftC = (Chest) left; Chest rightC = (Chest) right; if (equalsBlockStateLocation(oneSideOfChest.getLocation(), rightC.getLocation())) { + Util.debugLog("Left chest was founded."); return leftC.getBlock(); } if (equalsBlockStateLocation(oneSideOfChest.getLocation(), leftC.getLocation())) { + Util.debugLog("Right chest was founded."); return rightC.getBlock(); } Util.debugLog("Bug detected, DoubleChest holder can't find the any one side chest."); return null; } else { + Util.debugLog("ChestHolder not a DoubleChest holder."); return null; } } @@ -770,7 +775,7 @@ public class Util { for (String log : logs) { String text = "[DEBUG] [" + className + "]" + " [" + methodName + "] (" + codeLine + ") " + log; debugLogs.add(text); - if (debugLogs.size() > 4999) /* Keep debugLogs max can have 5k lines. */ + if (debugLogs.size() > 5000) /* Keep debugLogs max can have 5k lines. */ debugLogs.remove(0); if (!devMode) return; @@ -989,10 +994,14 @@ public class Util { } public static boolean isDoubleChest(@Nullable Block b) { - if (b == null) + if (b == null) { + Util.debugLog("The block is NULL."); return false; - if (!(b.getState() instanceof InventoryHolder)) + } + if (!(b.getState() instanceof InventoryHolder)) { + Util.debugLog("Target block not a InventoryHolder."); return false; + } InventoryHolder inventoryHolder = (InventoryHolder) b.getState(); return (inventoryHolder.getInventory() instanceof DoubleChest);