diff --git a/pom.xml b/pom.xml index 208d4fd..25779de 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.sat7 DynamicShop - 3.15.1 + 3.15.2 jar DynamicShop diff --git a/src/main/java/me/sat7/dynamicshop/DynamicShop.java b/src/main/java/me/sat7/dynamicshop/DynamicShop.java index 1cd93f6..6b17855 100644 --- a/src/main/java/me/sat7/dynamicshop/DynamicShop.java +++ b/src/main/java/me/sat7/dynamicshop/DynamicShop.java @@ -96,6 +96,13 @@ public static String dsPrefix(Player player) public static final LocaleManager localeManager = new LocaleManager(); public static boolean isPapiExist; + public static boolean DEBUG_LOG_ENABLED = false; + public static void PrintConsoleDbgLog(String msg) + { + if (DEBUG_LOG_ENABLED) + console.sendMessage(DynamicShop.dsPrefix_ + msg); + } + public static boolean DEBUG_MODE = false; public static void DebugLog() { diff --git a/src/main/java/me/sat7/dynamicshop/commands/Root.java b/src/main/java/me/sat7/dynamicshop/commands/Root.java index 28adafd..a7c8eb1 100644 --- a/src/main/java/me/sat7/dynamicshop/commands/Root.java +++ b/src/main/java/me/sat7/dynamicshop/commands/Root.java @@ -83,6 +83,12 @@ else if (args[0].equalsIgnoreCase("dummyUUID") && DynamicShop.DEBUG_MODE && play sender.sendMessage(Constants.DYNAMIC_SHOP_PREFIX + "DebugMode " + DynamicShop.DEBUG_MODE); return true; } + else if (args[0].equalsIgnoreCase("dbgLog")) + { + DynamicShop.DEBUG_LOG_ENABLED = !DynamicShop.DEBUG_LOG_ENABLED; + sender.sendMessage(Constants.DYNAMIC_SHOP_PREFIX + "DebugLog " + DynamicShop.DEBUG_LOG_ENABLED); + return true; + } else if (args[0].equalsIgnoreCase("dbg") && DynamicShop.DEBUG_MODE) { DynamicShop.DebugLog(); diff --git a/src/main/java/me/sat7/dynamicshop/guis/ItemTrade.java b/src/main/java/me/sat7/dynamicshop/guis/ItemTrade.java index 3223db4..822377c 100644 --- a/src/main/java/me/sat7/dynamicshop/guis/ItemTrade.java +++ b/src/main/java/me/sat7/dynamicshop/guis/ItemTrade.java @@ -272,7 +272,7 @@ private void CreateTradeButtons(boolean sell) int tradeLimitLeft = UserUtil.GetTradingLimitLeft(player, shopName, tradeIdxInt, HashUtil.GetItemHash(new ItemStack(Material.getMaterial(material))), sell); if (tradeLimitLeft != Integer.MAX_VALUE) { - String limitString = sell ? t(player, "SHOP.SALES_LIMIT_PER_PLAYER") : t(player, "SHOP.PURCHASE_LIMIT_PER_PLAYER"); + String limitString = sell ? t(player, "TRADE.SALES_LIMIT_PER_PLAYER") : t(player, "TRADE.PURCHASE_LIMIT_PER_PLAYER"); String tradeLimitResetTime = ShopUtil.GetTradeLimitNextResetTime(shopName, tradeIdxInt); tradeLimitString = limitString.replace("{num}", String.valueOf(tradeLimitLeft)).replace("{time}", tradeLimitResetTime); } diff --git a/src/main/java/me/sat7/dynamicshop/transactions/Sell.java b/src/main/java/me/sat7/dynamicshop/transactions/Sell.java index 3ab24ef..5cc2b30 100644 --- a/src/main/java/me/sat7/dynamicshop/transactions/Sell.java +++ b/src/main/java/me/sat7/dynamicshop/transactions/Sell.java @@ -77,6 +77,7 @@ public static double quickSellItem(Player player, ItemStack itemStack, String sh if (player != null) player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "MESSAGE.NO_ITEM_TO_SELL")); + DynamicShop.PrintConsoleDbgLog("QSellFail-Player does not have an item. player:" + player + " itemType:" + itemStack.getType() + " shopName:" + shopName + " tradeIdx:" + tradeIdx); return 0; } @@ -86,7 +87,10 @@ public static double quickSellItem(Player player, ItemStack itemStack, String sh { tradeAmount = UserUtil.CheckTradeLimitPerPlayer(player, shopName, tradeIdx, HashUtil.GetItemHash(itemStack), tradeAmount, true); if (tradeAmount == 0) + { + DynamicShop.PrintConsoleDbgLog("QSellFail-Trading volume limit reached. player:" + player + " itemType:" + itemStack.getType() + " shopName:" + shopName + " tradeIdx:" + tradeIdx); return 0; + } } // 비용 계산 @@ -96,7 +100,10 @@ public static double quickSellItem(Player player, ItemStack itemStack, String sh // 계산된 비용에 대한 처리 시도 Economy econ = DynamicShop.getEconomy(); if (!CheckTransactionSuccess(currencyType, player, priceSum)) + { + DynamicShop.PrintConsoleDbgLog("QSellFail-Transaction failed. player:" + player + " itemType:" + itemStack.getType() + " shopName:" + shopName + " tradeIdx:" + tradeIdx); return 0; + } // 플레이어 인벤토리에서 아이템 제거 if (player != null) diff --git a/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java index b64c54e..655e614 100644 --- a/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java +++ b/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java @@ -857,6 +857,7 @@ public static String[] FindTheBestShopToSell(Player player, ItemStack itemStack) int tradeIdx = -1; String currency = ""; + ArrayList failReason = new ArrayList<>(); // 접근가능한 상점중 최고가 찾기 for(Map.Entry entry : shopConfigFiles.entrySet()) @@ -869,6 +870,8 @@ public static String[] FindTheBestShopToSell(Player player, ItemStack itemStack) String permission = data.get().getString("Options.permission"); if (permission != null && permission.length() > 0 && !player.hasPermission(permission) && !player.hasPermission(permission + ".sell")) { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-no permission"); continue; } } @@ -876,33 +879,53 @@ public static String[] FindTheBestShopToSell(Player player, ItemStack itemStack) // 비활성화된 상점 boolean enable = data.get().getBoolean("Options.enable", true); if (!enable) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-shop is disabled"); continue; + } // 표지판 전용 상점, 지역상점, 잡포인트 상점 boolean outside = !CheckShopLocation(entry.getKey(), player); if (outside && data.get().contains("Options.flag.localshop") && !data.get().contains("Options.flag.deliverycharge")) { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-local shop"); continue; } if (data.get().contains("Options.flag.signshop")) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-sign shop"); continue; + } // 영업시간 확인 if (player != null && !CheckShopHour(entry.getKey(), player)) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-not open hours"); continue; + } double deliveryCosts = CalcShipping(entry.getKey(), player); - if (deliveryCosts == -1) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-Infinite Delivery Fee (Other World)"); continue; + } int sameItemIdx = ShopUtil.findItemFromShop(entry.getKey(), itemStack); - if (sameItemIdx != -1) { String tradeType = data.get().getString(sameItemIdx + ".tradeType"); if (tradeType != null && tradeType.equalsIgnoreCase("BuyOnly")) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-buy only"); continue; // 구매만 가능함 + } // 여러 재화로 취급중인 경우 지원 안함. if (currency.isEmpty()) @@ -932,6 +955,8 @@ else if (!currency.equalsIgnoreCase(ShopUtil.GetCurrency(data))) if (ShopUtil.getShopBalance(entry.getKey()) != -1 && ShopUtil.getShopBalance(entry.getKey()) < Calc.calcTotalCost(entry.getKey(), String.valueOf(sameItemIdx), itemStack.getAmount())[0]) { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-no money in shop"); continue; } @@ -939,7 +964,11 @@ else if (!currency.equalsIgnoreCase(ShopUtil.GetCurrency(data))) int maxStock = data.get().getInt(sameItemIdx + ".maxStock", -1); int stock = data.get().getInt(sameItemIdx + ".stock"); if (maxStock != -1 && maxStock <= stock) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-shop reaches max stock"); continue; + } // 플레이어 당 거래량 제한 확인 int sellLimit = ShopUtil.GetSellLimitPerPlayer(entry.getKey(), sameItemIdx); @@ -947,7 +976,11 @@ else if (!currency.equalsIgnoreCase(ShopUtil.GetCurrency(data))) { int tradeAmount = UserUtil.CheckTradeLimitPerPlayer(player, entry.getKey(), sameItemIdx, HashUtil.GetItemHash(itemStack), itemStack.getAmount(), true); if (tradeAmount == 0) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-Reached trading volume limit"); continue; + } } double value = Calc.getCurrentPrice(entry.getKey(), String.valueOf(sameItemIdx), false); @@ -963,6 +996,15 @@ else if (!currency.equalsIgnoreCase(ShopUtil.GetCurrency(data))) } } + if (DynamicShop.DEBUG_LOG_ENABLED && topShopName.equals("") && failReason.size() > 0) + { + DynamicShop.PrintConsoleDbgLog("No shops available for sell. player:" + player + " itemType:" + itemStack.getType() + " Details:"); + for (String s : failReason) + { + DynamicShop.PrintConsoleDbgLog(" - " + s); + } + } + return new String[]{topShopName, Integer.toString(tradeIdx)}; } @@ -974,6 +1016,8 @@ public static String[] FindTheBestShopToBuy(Player player, ItemStack itemStack) int currencyInt = -1; + ArrayList failReason = new ArrayList<>(); + // 접근가능한 상점중 최저가 찾기 for(Map.Entry entry : shopConfigFiles.entrySet()) { @@ -983,30 +1027,50 @@ public static String[] FindTheBestShopToBuy(Player player, ItemStack itemStack) String permission = data.get().getString("Options.permission"); if (permission != null && permission.length() > 0 && !player.hasPermission(permission) && !player.hasPermission(permission + ".buy")) { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-no permission"); continue; } // 비활성화된 상점 boolean enable = data.get().getBoolean("Options.enable", true); if (!enable) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-shop is disabled"); continue; + } // 표지판 전용 상점, 지역상점, 잡포인트 상점 boolean outside = !CheckShopLocation(entry.getKey(), player); if (outside && data.get().contains("Options.flag.localshop") && !data.get().contains("Options.flag.deliverycharge")) { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-local shop"); continue; } if (data.get().contains("Options.flag.signshop")) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-sign shop"); continue; + } // 영업시간 확인 if (!CheckShopHour(entry.getKey(), player)) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-not open hours"); continue; + } double deliveryCosts = CalcShipping(entry.getKey(), player); if (deliveryCosts == -1) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-Infinite Delivery Fee (Other World)"); continue; + } int sameItemIdx = ShopUtil.findItemFromShop(entry.getKey(), itemStack); @@ -1015,12 +1079,20 @@ public static String[] FindTheBestShopToBuy(Player player, ItemStack itemStack) String tradeType = data.get().getString(sameItemIdx + ".tradeType"); if (tradeType != null && tradeType.equalsIgnoreCase("SellOnly")) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-sell only"); continue; + } // 재고가 없음 int stock = data.get().getInt(sameItemIdx + ".stock"); if (stock != -1 && stock < 2) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-Out of stock"); continue; + } // 여러 재화로 취급중인 경우 지원 안함. int tempCurrencyIndex = 0; @@ -1066,7 +1138,11 @@ else if (currencyInt != tempCurrencyIndex) { int tradeAmount = UserUtil.CheckTradeLimitPerPlayer(player, entry.getKey(), sameItemIdx, HashUtil.GetItemHash(itemStack), itemStack.getAmount(), false); if (tradeAmount == 0) + { + if (DynamicShop.DEBUG_LOG_ENABLED) + failReason.add("shopName:" + entry.getKey() + "-Trading volume limit reached"); continue; + } } double value = Calc.getCurrentPrice(entry.getKey(), String.valueOf(sameItemIdx), true); @@ -1082,6 +1158,15 @@ else if (currencyInt != tempCurrencyIndex) } } + if (DynamicShop.DEBUG_LOG_ENABLED && topShopName.equals("") && failReason.size() > 0) + { + DynamicShop.PrintConsoleDbgLog("No shops available for purchase. player:" + player + " itemType:" + itemStack.getType() + " Details:"); + for (String s : failReason) + { + DynamicShop.PrintConsoleDbgLog(" - " + s); + } + } + return new String[]{topShopName, Integer.toString(tradeIdx)}; }