From 050f8dcce8eb08a6a1b6909df64934ca6a6a2c67 Mon Sep 17 00:00:00 2001 From: 7sat <49030779+7sat@users.noreply.github.com> Date: Sat, 22 Apr 2023 03:58:38 +0900 Subject: [PATCH] various minor fixes 1.Fixed an issue where the sound effect was too loud when using the 'sell all' command 2.Removed unnecessary exception messages when the economy plug-in does not exist and is forcefully terminated. 3.Min unit change in price: 0.01 -> 0.0001 --- pom.xml | 2 +- .../java/me/sat7/dynamicshop/DynaShopAPI.java | 12 ++++- .../java/me/sat7/dynamicshop/DynamicShop.java | 11 +++-- .../me/sat7/dynamicshop/commands/Sell.java | 7 ++- .../sat7/dynamicshop/commands/shop/Add.java | 4 +- .../dynamicshop/commands/shop/AddHand.java | 4 +- .../sat7/dynamicshop/commands/shop/Edit.java | 2 +- .../dynamicshop/commands/shop/EditAll.java | 6 +-- .../me/sat7/dynamicshop/guis/ItemPalette.java | 8 ++-- .../sat7/dynamicshop/guis/ItemSettings.java | 46 ++++++++----------- .../java/me/sat7/dynamicshop/guis/Shop.java | 2 +- .../me/sat7/dynamicshop/models/DSItem.java | 16 +++---- .../sat7/dynamicshop/transactions/Calc.java | 6 +-- .../sat7/dynamicshop/transactions/Sell.java | 8 +++- .../sat7/dynamicshop/utilities/ItemsUtil.java | 2 +- .../sat7/dynamicshop/utilities/LogUtil.java | 2 +- .../sat7/dynamicshop/utilities/ShopUtil.java | 12 ++--- .../utilities/TabCompleteUtil.java | 11 +++-- 18 files changed, 90 insertions(+), 71 deletions(-) diff --git a/pom.xml b/pom.xml index fdb2c4c..4527cda 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.sat7 DynamicShop - 3.14.3 + 3.15.0 jar DynamicShop diff --git a/src/main/java/me/sat7/dynamicshop/DynaShopAPI.java b/src/main/java/me/sat7/dynamicshop/DynaShopAPI.java index 86c9af6..dc4616f 100644 --- a/src/main/java/me/sat7/dynamicshop/DynaShopAPI.java +++ b/src/main/java/me/sat7/dynamicshop/DynaShopAPI.java @@ -442,9 +442,17 @@ public static String[] FindTheBestShopToSell(Player player, ItemStack itemStack, */ public static double QuickSell(Player player, ItemStack itemStack) { - return QuickSell(player, itemStack, -1); + return QuickSell(player, itemStack, -1, true); + } + public static double QuickSell(Player player, ItemStack itemStack, boolean playSound) + { + return QuickSell(player, itemStack, -1, playSound); } public static double QuickSell(Player player, ItemStack itemStack, int slot) + { + return QuickSell(player,itemStack, slot, true); + } + public static double QuickSell(Player player, ItemStack itemStack, int slot, boolean playSound) { if (itemStack == null || itemStack.getType().isAir()) return 0; @@ -457,7 +465,7 @@ public static double QuickSell(Player player, ItemStack itemStack, int slot) if (!validateShopName(ret[0])) return 0; - return Sell.quickSellItem(player, itemStack, ret[0], Integer.parseInt(ret[1]), slot == -1, slot); + return Sell.quickSellItem(player, itemStack, ret[0], Integer.parseInt(ret[1]), slot == -1, slot, playSound); } /** diff --git a/src/main/java/me/sat7/dynamicshop/DynamicShop.java b/src/main/java/me/sat7/dynamicshop/DynamicShop.java index 94356d9..1cd93f6 100644 --- a/src/main/java/me/sat7/dynamicshop/DynamicShop.java +++ b/src/main/java/me/sat7/dynamicshop/DynamicShop.java @@ -238,9 +238,9 @@ private void SetupRSP() } setupRspRetryCount++; - console.sendMessage(Constants.DYNAMIC_SHOP_PREFIX + " Economy provider not found. Retry... " + setupRspRetryCount + "/3"); + //console.sendMessage(Constants.DYNAMIC_SHOP_PREFIX + " Economy provider not found. Retry... " + setupRspRetryCount + "/3"); - Bukkit.getScheduler().runTaskLater(this, this::SetupRSP, 30L); + Bukkit.getScheduler().runTaskLater(this, this::SetupRSP, 40L); } } @@ -503,8 +503,11 @@ public List onTabComplete(CommandSender sender, Command cmd, String comm @Override public void onDisable() { - UserUtil.OnPluginDisable(); - ShopUtil.ForceSaveAllShop(); + if (econ != null) + { + UserUtil.OnPluginDisable(); + ShopUtil.ForceSaveAllShop(); + } Bukkit.getScheduler().cancelTasks(this); console.sendMessage(Constants.DYNAMIC_SHOP_PREFIX + " Disabled"); diff --git a/src/main/java/me/sat7/dynamicshop/commands/Sell.java b/src/main/java/me/sat7/dynamicshop/commands/Sell.java index ab357c9..07fd14d 100644 --- a/src/main/java/me/sat7/dynamicshop/commands/Sell.java +++ b/src/main/java/me/sat7/dynamicshop/commands/Sell.java @@ -8,6 +8,7 @@ import me.sat7.dynamicshop.utilities.HashUtil; import org.bukkit.Bukkit; import org.bukkit.GameMode; +import org.bukkit.Sound; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -101,7 +102,7 @@ else if (args[0].equalsIgnoreCase("all")) if (temp.contains(hash)) continue; - sum += DynaShopAPI.QuickSell(player, stack); + sum += DynaShopAPI.QuickSell(player, stack, false); temp.add(hash); } @@ -110,6 +111,10 @@ else if (args[0].equalsIgnoreCase("all")) player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "MESSAGE.NO_ITEM_TO_SELL_2")); return false; } + else + { + player.playSound(player.getLocation(), Sound.valueOf("ENTITY_EXPERIENCE_ORB_PICKUP"), 1, 1); + } return true; } diff --git a/src/main/java/me/sat7/dynamicshop/commands/shop/Add.java b/src/main/java/me/sat7/dynamicshop/commands/shop/Add.java index 3341bfd..2a96f3b 100644 --- a/src/main/java/me/sat7/dynamicshop/commands/shop/Add.java +++ b/src/main/java/me/sat7/dynamicshop/commands/shop/Add.java @@ -47,7 +47,7 @@ public void RunCMD(String[] args, CommandSender sender) Material mat; double buyValue; - double valueMin = 0.01; + double valueMin = 0.0001; double valueMax = -1; int median; int stock; @@ -87,7 +87,7 @@ public void RunCMD(String[] args, CommandSender sender) } } - if (buyValue < 0.01 || median == 0 || stock == 0) + if (buyValue < 0.0001 || median == 0 || stock == 0) { sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "ERR.VALUE_ZERO")); return; diff --git a/src/main/java/me/sat7/dynamicshop/commands/shop/AddHand.java b/src/main/java/me/sat7/dynamicshop/commands/shop/AddHand.java index da2d569..f03d423 100644 --- a/src/main/java/me/sat7/dynamicshop/commands/shop/AddHand.java +++ b/src/main/java/me/sat7/dynamicshop/commands/shop/AddHand.java @@ -43,7 +43,7 @@ public void RunCMD(String[] args, CommandSender sender) String shopName = Shop.GetShopName(args); double buyValue; - double valueMin = 0.01; + double valueMin = 0.0001; double valueMax = -1; int median; int stock; @@ -81,7 +81,7 @@ public void RunCMD(String[] args, CommandSender sender) } } - if (buyValue < 0.01 || median == 0 || stock == 0) + if (buyValue < 0.0001 || median == 0 || stock == 0) { player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "ERR.VALUE_ZERO")); return; diff --git a/src/main/java/me/sat7/dynamicshop/commands/shop/Edit.java b/src/main/java/me/sat7/dynamicshop/commands/shop/Edit.java index a59a0df..2effd81 100644 --- a/src/main/java/me/sat7/dynamicshop/commands/shop/Edit.java +++ b/src/main/java/me/sat7/dynamicshop/commands/shop/Edit.java @@ -49,7 +49,7 @@ public void RunCMD(String[] args, CommandSender sender) int idx; double buyValue; - double valueMin = 0.01; + double valueMin = 0.0001; double valueMax = -1; int median; int stock; diff --git a/src/main/java/me/sat7/dynamicshop/commands/shop/EditAll.java b/src/main/java/me/sat7/dynamicshop/commands/shop/EditAll.java index 9e10e91..838b5e5 100644 --- a/src/main/java/me/sat7/dynamicshop/commands/shop/EditAll.java +++ b/src/main/java/me/sat7/dynamicshop/commands/shop/EditAll.java @@ -153,9 +153,9 @@ else if (mod.equalsIgnoreCase("*")) result = originalValue * newValue; } - if (dataType.equals("value") && result < 0.01) + if (dataType.equals("value") && result < 0.0001) { - result = 0.01; + result = 0.0001; } if (dataType.equals("stock") || dataType.equals("median") || dataType.equals("maxStock") || dataType.equals("discount")) @@ -165,7 +165,7 @@ else if (mod.equalsIgnoreCase("*")) } else { - result = Math.round(result * 1000) / 1000.0; + result = Math.round(result * 10000) / 10000.0; shopData.get().set(s + "." + dataType, result); } diff --git a/src/main/java/me/sat7/dynamicshop/guis/ItemPalette.java b/src/main/java/me/sat7/dynamicshop/guis/ItemPalette.java index 6abd472..e0b682b 100644 --- a/src/main/java/me/sat7/dynamicshop/guis/ItemPalette.java +++ b/src/main/java/me/sat7/dynamicshop/guis/ItemPalette.java @@ -393,7 +393,7 @@ private void AddAll(boolean applyRecommend) targetSlotIdx = ShopUtil.findEmptyShopSlot(shopName, shopSlotIndex, true); - DSItem temp = new DSItem(itemStack, 1, 1, 0.01, -1, 10000, 10000); + DSItem temp = new DSItem(itemStack, 1, 1, 0.0001, -1, 10000, 10000); ShopUtil.addItemToShop(shopName, targetSlotIdx, temp); } } @@ -431,12 +431,12 @@ private void OnClickItem(boolean isLeft, boolean isRight, boolean isShift, ItemS { if (isShift) { - DSItem dsItem = new DSItem(itemStack, 10, 10, 0.01, -1, 10000, 10000); + DSItem dsItem = new DSItem(itemStack, 10, 10, 0.0001, -1, 10000, 10000); DynaShopAPI.openItemSettingGui(player, shopName, shopSlotIndex,0, dsItem); } else { int targetSlotIdx = ShopUtil.findEmptyShopSlot(shopName, shopSlotIndex, true); - DSItem temp = new DSItem(itemStack, 1, 1, 0.01, -1, 10000, 10000); + DSItem temp = new DSItem(itemStack, 1, 1, 0.0001, -1, 10000, 10000); ShopUtil.addItemToShop(shopName, targetSlotIdx, temp); player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "MESSAGE.ITEM_ADDED")); @@ -492,7 +492,7 @@ private void OnClickUserItem(boolean isLeft, boolean isRight, ItemStack item) { if (isLeft) { - DSItem dsItem = new DSItem(item, 10, 10, 0.01, -1, 10000, 10000); + DSItem dsItem = new DSItem(item, 10, 10, 0.0001, -1, 10000, 10000); DynaShopAPI.openItemSettingGui(player, shopName, shopSlotIndex, 0, dsItem); } else if (isRight) { diff --git a/src/main/java/me/sat7/dynamicshop/guis/ItemSettings.java b/src/main/java/me/sat7/dynamicshop/guis/ItemSettings.java index 18b98d2..4a9b20c 100644 --- a/src/main/java/me/sat7/dynamicshop/guis/ItemSettings.java +++ b/src/main/java/me/sat7/dynamicshop/guis/ItemSettings.java @@ -116,7 +116,7 @@ public Inventory getGui(Player player, String shopName, int shopSlotIndex, int t // 조절버튼 if (dsItem.getBuyValue() == dsItem.getSellValue()) sellValueStr = "§8" + ChatColor.stripColor(sellValueStr); - if (dsItem.getMinPrice() <= 0.01) + if (dsItem.getMinPrice() <= 0.0001) priceMinStr = "§8" + ChatColor.stripColor(priceMinStr); if (dsItem.getMaxPrice() <= 0) priceMaxStr = "§8" + ChatColor.stripColor(priceMaxStr); @@ -171,8 +171,8 @@ public Inventory getGui(Player player, String shopName, int shopSlotIndex, int t } else { buyPrice = (dsItem.getBuyValue() * dsItem.getMedian()) / dsItem.getStock(); - if(buyPrice < 0.01) - buyPrice = 0.01; + if(buyPrice < 0.0001) + buyPrice = 0.0001; if (dsItem.getBuyValue() != dsItem.getSellValue()) // 판매가 별도설정 { @@ -191,7 +191,7 @@ public Inventory getGui(Player player, String shopName, int shopSlotIndex, int t taxStr += ConfigUtil.getCurrentTax() + "%"; sellPrice = buyPrice - ((buyPrice / 100.0) * ConfigUtil.getCurrentTax()); } - sellPrice = (Math.round(sellPrice * 100) / 100.0); + sellPrice = (Math.round(sellPrice * 10000) / 10000.0); editBtnLore.add(taxStr); } @@ -247,8 +247,6 @@ public Inventory getGui(Player player, String shopName, int shopSlotIndex, int t String worthChanged = (dsItem.getBuyValue() == worth) ? " ▶§f " : " ▶§a "; String worthChanged2 = (dsItem.getSellValue() == worth) ? " ▶§f " : " ▶§a "; - //String minChanged = (dsItem.getMinPrice() == 0.01) ? " ▶§f " : " ▶§a "; - //String maxChanged = (dsItem.getMaxPrice() == -1) ? " ▶§f " : " ▶§a "; String medianChanged = (dsItem.getMedian() == sugMid) ? " ▶§f " : " ▶§a "; String stockChanged = (dsItem.getStock() == sugMid) ? " ▶§f " : " ▶§a "; @@ -256,10 +254,6 @@ public Inventory getGui(Player player, String shopName, int shopSlotIndex, int t + "§7 " + dsItem.getBuyValue() + worthChanged + worth + "\n" + t(null, "ITEM_SETTING.VALUE_SELL") + "\n" + "§7 " + dsItem.getSellValue() + worthChanged2 + worth + "\n" - //+ t(null, "ITEM_SETTING.PRICE_MIN") + "\n" - //+ "§7 " + dsItem.getMinPrice() + minChanged + 0.01 + "\n" - //+ t(null, "ITEM_SETTING.PRICE_MAX") + "\n" - //+ "§7 " + dsItem.getMaxPrice() + maxChanged + -1 + "\n" + t(null, "ITEM_SETTING.MEDIAN") + "\n" + "§7 " + dsItem.getMedian() + medianChanged + sugMid + "\n" + t(null, "ITEM_SETTING.STOCK") + "\n" @@ -309,7 +303,7 @@ public void OnClickUpperInventory(InventoryClickEvent e) if (e.getCurrentItem() == null) return; - if(dsItem.minPrice <= 0) dsItem.minPrice = 0.01; + if(dsItem.minPrice <= 0) dsItem.minPrice = 0.0001; if(dsItem.maxPrice <= 0) dsItem.maxPrice = -1; oldSbSame = dsItem.sellValue == dsItem.buyValue; @@ -548,7 +542,7 @@ private void Reset() { if (currentTab == BUY_VALUE) dsItem.buyValue = 10; else if (currentTab == SELL_VALUE) dsItem.sellValue = 10; - else if (currentTab == MIN_VALUE) dsItem.minPrice = 0.01; + else if (currentTab == MIN_VALUE) dsItem.minPrice = 0.0001; else if (currentTab == MAX_VALUE) dsItem.maxPrice = -1; else if (currentTab == MEDIAN) dsItem.median = 10000; else if (currentTab == STOCK) dsItem.stock = 10000; @@ -566,18 +560,18 @@ private void PlusMinus(boolean isShift, ItemStack clickedButton) if (currentTab == BUY_VALUE) { dsItem.buyValue += editNum; - if (dsItem.buyValue < 0.01) dsItem.buyValue = 0.01f; + if (dsItem.buyValue < 0.0001) dsItem.buyValue = 0.0001f; if(oldSbSame) dsItem.sellValue = dsItem.buyValue; } else if (currentTab == SELL_VALUE) { dsItem.sellValue += editNum; - if (dsItem.sellValue < 0.01) dsItem.sellValue = 0.01f; + if (dsItem.sellValue < 0.0001) dsItem.sellValue = 0.0001f; } else if (currentTab == MIN_VALUE) { dsItem.minPrice += editNum; - if (dsItem.minPrice < 0.01) dsItem.minPrice = 0.01f; + if (dsItem.minPrice < 0.0001) dsItem.minPrice = 0.0001f; } else if (currentTab == MAX_VALUE) { if (dsItem.maxPrice <= 0 && editNum > 0) @@ -585,7 +579,7 @@ private void PlusMinus(boolean isShift, ItemStack clickedButton) else { dsItem.maxPrice += editNum; - if (dsItem.maxPrice < 0.01) + if (dsItem.maxPrice < 0.0001) dsItem.maxPrice = -1; } } else if (currentTab == MEDIAN) @@ -643,22 +637,22 @@ private void Divide(boolean isShift) if (currentTab == BUY_VALUE) { dsItem.buyValue /= div; - if(dsItem.buyValue < 0.01) dsItem.buyValue = 0.01; + if(dsItem.buyValue < 0.0001) dsItem.buyValue = 0.0001; if(oldSbSame) dsItem.sellValue = dsItem.buyValue; } else if (currentTab == SELL_VALUE) { dsItem.sellValue /= div; - if(dsItem.sellValue < 0.01) dsItem.sellValue = 0.01; + if(dsItem.sellValue < 0.0001) dsItem.sellValue = 0.0001; } else if (currentTab == MIN_VALUE) { dsItem.minPrice /= div; - if(dsItem.minPrice < 0.01) dsItem.minPrice = 0.01; + if(dsItem.minPrice < 0.0001) dsItem.minPrice = 0.0001; } else if (currentTab == MAX_VALUE) { dsItem.maxPrice /= div; - if(dsItem.maxPrice < 0.01) dsItem.maxPrice = 0.01; + if(dsItem.maxPrice < 0.0001) dsItem.maxPrice = 0.0001; } else if (currentTab == MEDIAN) { if(dsItem.median > 1) @@ -740,12 +734,12 @@ private void SetEqualToOther() private void ValueValidation() { - if (dsItem.buyValue < 0.01) - dsItem.buyValue = 0.01; - if (dsItem.sellValue < 0.01) - dsItem.sellValue = 0.01; - if (dsItem.minPrice < 0.01) - dsItem.minPrice = 0.01; + if (dsItem.buyValue < 0.0001) + dsItem.buyValue = 0.0001; + if (dsItem.sellValue < 0.0001) + dsItem.sellValue = 0.0001; + if (dsItem.minPrice < 0.0001) + dsItem.minPrice = 0.0001; if (dsItem.maxPrice < -1) dsItem.maxPrice = -1; if (dsItem.median < -1) diff --git a/src/main/java/me/sat7/dynamicshop/guis/Shop.java b/src/main/java/me/sat7/dynamicshop/guis/Shop.java index 81965d1..e52bb92 100644 --- a/src/main/java/me/sat7/dynamicshop/guis/Shop.java +++ b/src/main/java/me/sat7/dynamicshop/guis/Shop.java @@ -610,7 +610,7 @@ else if (e.isRightClick() && player.hasPermission(P_ADMIN_SHOP_EDIT)) sellValue = shopData.getDouble(idx + ".value2"); } double valueMin = shopData.getDouble(idx + ".valueMin"); - if (valueMin <= 0.01) valueMin = 0.01; + if (valueMin <= 0.0001) valueMin = 0.0001; double valueMax = shopData.getDouble(idx + ".valueMax"); if (valueMax <= 0) valueMax = -1; int median = shopData.getInt(idx + ".median"); diff --git a/src/main/java/me/sat7/dynamicshop/models/DSItem.java b/src/main/java/me/sat7/dynamicshop/models/DSItem.java index 974597e..43889c5 100644 --- a/src/main/java/me/sat7/dynamicshop/models/DSItem.java +++ b/src/main/java/me/sat7/dynamicshop/models/DSItem.java @@ -26,10 +26,10 @@ public class DSItem public DSItem(ItemStack itemStack, double buyValue, double sellValue, double minPrice, double maxPrice, int median, int stock) { setItemStack(itemStack); - setBuyValue(Math.round(buyValue * 100) / 100.0); - setSellValue(Math.round(sellValue * 100) / 100.0); - setMinPrice(Math.round(minPrice * 100) / 100.0); - setMaxPrice(Math.round(maxPrice * 100) / 100.0); + setBuyValue(Math.round(buyValue * 10000) / 10000.0); + setSellValue(Math.round(sellValue * 10000) / 10000.0); + setMinPrice(Math.round(minPrice * 10000) / 10000.0); + setMaxPrice(Math.round(maxPrice * 10000) / 10000.0); setMedian(median); setStock(stock); maxStock = -1; @@ -37,10 +37,10 @@ public DSItem(ItemStack itemStack, double buyValue, double sellValue, double min public DSItem(ItemStack itemStack, double buyValue, double sellValue, double minPrice, double maxPrice, int median, int stock, int maxStock, int discount, int sellLimit, int buyLimit, long tradeLimitInterval, long tradeLimitNextTimer) { setItemStack(itemStack); - setBuyValue(Math.round(buyValue * 100) / 100.0); - setSellValue(Math.round(sellValue * 100) / 100.0); - setMinPrice(Math.round(minPrice * 100) / 100.0); - setMaxPrice(Math.round(maxPrice * 100) / 100.0); + setBuyValue(Math.round(buyValue * 10000) / 10000.0); + setSellValue(Math.round(sellValue * 10000) / 10000.0); + setMinPrice(Math.round(minPrice * 10000) / 10000.0); + setMaxPrice(Math.round(maxPrice * 10000) / 10000.0); setMedian(median); setStock(stock); setMaxStock(maxStock); diff --git a/src/main/java/me/sat7/dynamicshop/transactions/Calc.java b/src/main/java/me/sat7/dynamicshop/transactions/Calc.java index 2713634..86f242f 100644 --- a/src/main/java/me/sat7/dynamicshop/transactions/Calc.java +++ b/src/main/java/me/sat7/dynamicshop/transactions/Calc.java @@ -31,7 +31,7 @@ public static double getCurrentPrice(String shopName, String idx, boolean buy, b value = data.getDouble(idx + ".value"); } - double min = data.getDouble(idx + ".valueMin", 0.01); + double min = data.getDouble(idx + ".valueMin", 0.0001); double max = data.getDouble(idx + ".valueMax"); int median = data.getInt(idx + ".median"); int stock = data.getInt(idx + ".stock"); @@ -114,7 +114,7 @@ public static double[] calcTotalCost(String shopName, String idx, int amount) stock++; } double temp = median * value / stock; - double min = data.getDouble(idx + ".valueMin", 0.01); + double min = data.getDouble(idx + ".valueMin", 0.0001); double max = data.getDouble(idx + ".valueMax"); if (temp < min) @@ -163,7 +163,7 @@ public static double[] calcTotalCost(String shopName, String idx, int amount) } else { - total = (Math.round(total * 100) / 100.0); + total = (Math.round(total * 10000) / 10000.0); } return new double[]{total, tax}; diff --git a/src/main/java/me/sat7/dynamicshop/transactions/Sell.java b/src/main/java/me/sat7/dynamicshop/transactions/Sell.java index 357575c..ff388bb 100644 --- a/src/main/java/me/sat7/dynamicshop/transactions/Sell.java +++ b/src/main/java/me/sat7/dynamicshop/transactions/Sell.java @@ -29,6 +29,11 @@ private Sell() } public static double quickSellItem(Player player, ItemStack itemStack, String shopName, int tradeIdx, boolean isShiftClick, int slot) + { + return quickSellItem(player, itemStack, shopName, tradeIdx, isShiftClick, slot, true); + } + + public static double quickSellItem(Player player, ItemStack itemStack, String shopName, int tradeIdx, boolean isShiftClick, int slot, boolean playSound) { CustomConfig data = ShopUtil.shopConfigFiles.get(shopName); @@ -173,7 +178,8 @@ else if (data.get().getString("Options.currency","").equalsIgnoreCase("exp")) SendSellMessage(currencyType, econ, player, tradeAmount, priceSum, itemStack); // 플레이어에게 소리 재생 - player.playSound(player.getLocation(), Sound.valueOf("ENTITY_EXPERIENCE_ORB_PICKUP"), 1, 1); + if (playSound) + player.playSound(player.getLocation(), Sound.valueOf("ENTITY_EXPERIENCE_ORB_PICKUP"), 1, 1); } // 상점 계좌 잔액 수정 diff --git a/src/main/java/me/sat7/dynamicshop/utilities/ItemsUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/ItemsUtil.java index f5b387f..0ffd079 100644 --- a/src/main/java/me/sat7/dynamicshop/utilities/ItemsUtil.java +++ b/src/main/java/me/sat7/dynamicshop/utilities/ItemsUtil.java @@ -67,7 +67,7 @@ public static void sendItemInfo(Player player, String shopName, int idx, String String info = " value:" + data.get().getDouble(idx + ".value"); double valueMin = data.get().getDouble(idx + ".valueMin"); - if (valueMin > 0.01) info += " min:" + valueMin; + if (valueMin > 0.0001) info += " min:" + valueMin; double valueMax = data.get().getDouble(idx + ".valueMax"); if (valueMax > 0) info += " max:" + valueMax; diff --git a/src/main/java/me/sat7/dynamicshop/utilities/LogUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/LogUtil.java index 25423d3..54ac761 100644 --- a/src/main/java/me/sat7/dynamicshop/utilities/LogUtil.java +++ b/src/main/java/me/sat7/dynamicshop/utilities/LogUtil.java @@ -46,7 +46,7 @@ public static void addLog(String shopName, String itemName, int amount, double v String time = sdf.format(System.currentTimeMillis()); String keyString = CreatePath(shopName); - String valueString = time + "," + shopName + "," + itemName + "," + amount + "," + (Math.round(value * 100) / 100.0) + "," + curr + "," + player; + String valueString = time + "," + shopName + "," + itemName + "," + amount + "," + (Math.round(value * 10000) / 10000.0) + "," + curr + "," + player; if (log.get(keyString) == null) { diff --git a/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java index 2d290d1..bcf322a 100644 --- a/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java +++ b/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java @@ -317,7 +317,7 @@ public static boolean addItemToShop(String shopName, int idx, DSItem dsItem) data.get().set(idx + ".value2", dsItem.sellValue); } - if (dsItem.minPrice > 0.01) + if (dsItem.minPrice > 0.0001) { data.get().set(idx + ".valueMin", dsItem.minPrice); } @@ -326,7 +326,7 @@ public static boolean addItemToShop(String shopName, int idx, DSItem dsItem) data.get().set(idx + ".valueMin", null); } - if (dsItem.maxPrice > 0.01) + if (dsItem.maxPrice > 0.0001) { data.get().set(idx + ".valueMax", dsItem.maxPrice); } @@ -414,7 +414,7 @@ public static void editShopItem(String shopName, int idx, DSItem dsItem) data.get().set(idx + ".value2", dsItem.sellValue); } - if (dsItem.minPrice > 0.01) + if (dsItem.minPrice > 0.0001) { data.get().set(idx + ".valueMin", dsItem.minPrice); } @@ -423,7 +423,7 @@ public static void editShopItem(String shopName, int idx, DSItem dsItem) data.get().set(idx + ".valueMin", null); } - if (dsItem.maxPrice > 0.01) + if (dsItem.maxPrice > 0.0001) { data.get().set(idx + ".valueMax", dsItem.maxPrice); } @@ -764,7 +764,7 @@ public static void addShopBalance(String shopName, double amount) if (old < 0) return; double newValue = old + amount; - newValue = (Math.round(newValue * 100) / 100.0); + newValue = (Math.round(newValue * 10000) / 10000.0); try { @@ -824,7 +824,7 @@ public static void SetToRecommendedValueAll(String shop, CommandSender sender) long tradeLimitNextTimer = data.get().getLong(itemIndex + ".tradeLimitPerPlayer.nextTimer"); int sugMid = CalcRecommendedMedian(worth, ConfigUtil.GetNumberOfPlayer()); - DSItem temp = new DSItem(null, worth, worth, 0.01f, -1, sugMid, sugMid, -1, discount, + DSItem temp = new DSItem(null, worth, worth, 0.0001f, -1, sugMid, sugMid, -1, discount, sellLimit, buyLimit, tradeLimitInterval, tradeLimitNextTimer); ShopUtil.editShopItem(shop, i, temp); } else diff --git a/src/main/java/me/sat7/dynamicshop/utilities/TabCompleteUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/TabCompleteUtil.java index 70e7723..87cb2a1 100644 --- a/src/main/java/me/sat7/dynamicshop/utilities/TabCompleteUtil.java +++ b/src/main/java/me/sat7/dynamicshop/utilities/TabCompleteUtil.java @@ -43,10 +43,13 @@ public static List onTabCompleteBody(DynamicShop dynamicShop, CommandSen if (cmd.getName().equalsIgnoreCase("sell") && args.length == 1) { - temp.add("hand"); - temp.add("handall"); - temp.add("all"); - AddToAutoCompleteIfValid(args[0]); + if (sender.hasPermission(P_SELL)) + { + temp.add("hand"); + temp.add("handall"); + temp.add("all"); + AddToAutoCompleteIfValid(args[0]); + } return autoCompleteList; }