diff --git a/pom.xml b/pom.xml
index 0a5ca20..0b62476 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.sat7
DynamicShop
- 3.13.0
+ 3.14.0
jar
DynamicShop
diff --git a/src/main/java/me/sat7/dynamicshop/DynaShopAPI.java b/src/main/java/me/sat7/dynamicshop/DynaShopAPI.java
index 932cfdb..61e3aee 100644
--- a/src/main/java/me/sat7/dynamicshop/DynaShopAPI.java
+++ b/src/main/java/me/sat7/dynamicshop/DynaShopAPI.java
@@ -442,6 +442,13 @@ public static String[] FindTheBestShopToSell(Player player, ItemStack itemStack,
*/
public static double QuickSell(Player player, ItemStack itemStack)
{
+ return QuickSell(player, itemStack, -1);
+ }
+ public static double QuickSell(Player player, ItemStack itemStack, int slot)
+ {
+ if (itemStack == null || itemStack.getType().isAir())
+ return 0;
+
String[] ret = ShopUtil.FindTheBestShopToSell(player, itemStack);
if (ret[1].equals("-2"))
@@ -450,7 +457,7 @@ public static double QuickSell(Player player, ItemStack itemStack)
if (!validateShopName(ret[0]))
return 0;
- return Sell.quickSellItem(player, itemStack, ret[0], Integer.parseInt(ret[1]), true, -1);
+ return Sell.quickSellItem(player, itemStack, ret[0], Integer.parseInt(ret[1]), slot == -1, slot);
}
/**
diff --git a/src/main/java/me/sat7/dynamicshop/DynamicShop.java b/src/main/java/me/sat7/dynamicshop/DynamicShop.java
index 364b5c6..94356d9 100644
--- a/src/main/java/me/sat7/dynamicshop/DynamicShop.java
+++ b/src/main/java/me/sat7/dynamicshop/DynamicShop.java
@@ -5,6 +5,7 @@
import me.sat7.dynamicshop.commands.CMDManager;
import me.sat7.dynamicshop.commands.Optional;
import me.sat7.dynamicshop.commands.Root;
+import me.sat7.dynamicshop.commands.Sell;
import me.sat7.dynamicshop.constants.Constants;
import me.sat7.dynamicshop.economyhook.JobsHook;
import me.sat7.dynamicshop.economyhook.PlayerpointHook;
@@ -438,10 +439,12 @@ private void initCommands()
// 명령어 등록 (개별 클레스로 되어있는것들)
getCommand("DynamicShop").setExecutor(new Root());
getCommand("shop").setExecutor(new Optional());
+ getCommand("sell").setExecutor(new Sell());
// 자동완성
getCommand("DynamicShop").setTabCompleter(this);
getCommand("shop").setTabCompleter(this);
+ getCommand("sell").setTabCompleter(this);
}
private void registerEvents()
diff --git a/src/main/java/me/sat7/dynamicshop/commands/Help.java b/src/main/java/me/sat7/dynamicshop/commands/Help.java
index 416f1af..385065d 100644
--- a/src/main/java/me/sat7/dynamicshop/commands/Help.java
+++ b/src/main/java/me/sat7/dynamicshop/commands/Help.java
@@ -55,7 +55,7 @@ public static void showHelp(String helpcode, Player player, String[] args)
if (player.hasPermission(P_ADMIN_SHOP_EDIT) || player.hasPermission(P_ADMIN_EDIT_ALL))
{
player.sendMessage(" - " + t(player, "HELP.USAGE")
- + ": /ds shop ");
+ + ": /ds shop ");
}
if (player.hasPermission(P_ADMIN_SHOP_EDIT))
diff --git a/src/main/java/me/sat7/dynamicshop/commands/Root.java b/src/main/java/me/sat7/dynamicshop/commands/Root.java
index 8474be0..28adafd 100644
--- a/src/main/java/me/sat7/dynamicshop/commands/Root.java
+++ b/src/main/java/me/sat7/dynamicshop/commands/Root.java
@@ -66,7 +66,7 @@ else if (args[0].equalsIgnoreCase("qsell"))
return true;
}
}
- else if (args[0].equalsIgnoreCase("dummyUUID") && DynamicShop.DEBUG_MODE)
+ else if (args[0].equalsIgnoreCase("dummyUUID") && DynamicShop.DEBUG_MODE && player.hasPermission(Constants.P_ADMIN_SHOP_EDIT))
{
UserUtil.CreateDummyPlayerData(player, 1000);
return true;
diff --git a/src/main/java/me/sat7/dynamicshop/commands/Sell.java b/src/main/java/me/sat7/dynamicshop/commands/Sell.java
new file mode 100644
index 0000000..8dca930
--- /dev/null
+++ b/src/main/java/me/sat7/dynamicshop/commands/Sell.java
@@ -0,0 +1,92 @@
+package me.sat7.dynamicshop.commands;
+
+import me.sat7.dynamicshop.DynaShopAPI;
+import me.sat7.dynamicshop.DynamicShop;
+import me.sat7.dynamicshop.constants.Constants;
+
+import me.sat7.dynamicshop.utilities.ConfigUtil;
+import me.sat7.dynamicshop.utilities.HashUtil;
+import org.bukkit.Bukkit;
+import org.bukkit.GameMode;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+import java.util.ArrayList;
+
+import static me.sat7.dynamicshop.utilities.LangUtil.t;
+
+public class Sell implements CommandExecutor
+{
+ public void SendHelpMessage(Player player)
+ {
+ player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "HELP.TITLE").replace("{command}", "sell"));
+ player.sendMessage(" - " + t(player, "HELP.USAGE") + ": sell ");
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
+ {
+ if (!(sender instanceof Player))
+ return false;
+
+ Player player = (Player) sender;
+
+ if (!player.hasPermission(Constants.P_USE))
+ {
+ player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "ERR.NO_PERMISSION"));
+ return true;
+ }
+
+ if (player.getGameMode() == GameMode.CREATIVE && !player.hasPermission(Constants.P_ADMIN_CREATIVE))
+ {
+ player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "ERR.CREATIVE"));
+ return true;
+ }
+
+ if (args.length != 1)
+ {
+ player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "ERR.WRONG_USAGE"));
+ SendHelpMessage(player);
+ return false;
+ }
+
+ if (args[0].equalsIgnoreCase("hand"))
+ {
+ DynaShopAPI.QuickSell(player, player.getInventory().getItemInMainHand(), player.getInventory().getHeldItemSlot());
+ return true;
+ }
+ else if (args[0].equalsIgnoreCase("handall"))
+ {
+ DynaShopAPI.QuickSell(player, player.getInventory().getItemInMainHand());
+ return true;
+ }
+ else if (args[0].equalsIgnoreCase("all"))
+ {
+ ArrayList temp = new ArrayList<>();
+
+ for (ItemStack stack : player.getInventory().getStorageContents())
+ {
+ if (stack == null || stack.getType().isAir())
+ continue;
+
+ String hash = HashUtil.GetItemHash(stack);
+ if (temp.contains(hash))
+ continue;
+
+ DynaShopAPI.QuickSell(player, stack);
+ temp.add(hash);
+ }
+
+ return true;
+ }
+ else
+ {
+ player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "ERR.WRONG_USAGE"));
+ SendHelpMessage(player);
+ return false;
+ }
+ }
+}
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 c91ee97..a59a0df 100644
--- a/src/main/java/me/sat7/dynamicshop/commands/shop/Edit.java
+++ b/src/main/java/me/sat7/dynamicshop/commands/shop/Edit.java
@@ -117,12 +117,13 @@ public void RunCMD(String[] args, CommandSender sender)
// 수정
int discount = shopData.get().getInt(idx + ".discount");
- int tradeLimit = shopData.get().getInt(idx + ".tradeLimitPerPlayer.value");
+ int sellLimit = shopData.get().getInt(idx + ".tradeLimitPerPlayer.sell");
+ int buyLimit = shopData.get().getInt(idx + ".tradeLimitPerPlayer.buy");
long tradeLimitInterval = shopData.get().getLong(idx + ".tradeLimitPerPlayer.interval");
long tradeLimitNextTimer = shopData.get().getLong(idx + ".tradeLimitPerPlayer.nextTimer");
DSItem temp = new DSItem(null, buyValue, buyValue, valueMin, valueMax, median, stock, maxStock, discount,
- tradeLimit, tradeLimitInterval, tradeLimitNextTimer);
+ sellLimit, buyLimit, tradeLimitInterval, tradeLimitNextTimer);
ShopUtil.editShopItem(shopName, idx, temp);
sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "MESSAGE.ITEM_UPDATED"));
ItemsUtil.sendItemInfo(sender, shopName, idx, "HELP.ITEM_INFO");
diff --git a/src/main/java/me/sat7/dynamicshop/guis/ItemSettings.java b/src/main/java/me/sat7/dynamicshop/guis/ItemSettings.java
index 7d71c43..18b98d2 100644
--- a/src/main/java/me/sat7/dynamicshop/guis/ItemSettings.java
+++ b/src/main/java/me/sat7/dynamicshop/guis/ItemSettings.java
@@ -35,7 +35,8 @@ public ItemSettings()
private final int DONE = 8;
private final int CLOSE = 45;
- private final int TRADE_LIMIT_AMOUNT = 46;
+ private final int TRADE_LIMIT_SELL = 37;
+ private final int TRADE_LIMIT_BUY = 46;
private final int TRADE_LIMIT_INTERVAL = 47;
private final int TRADE_LIMIT_INTERVAL_TIMER = 48;
private final int RECOMMEND = 49;
@@ -273,11 +274,14 @@ public Inventory getGui(Player player, String shopName, int shopSlotIndex, int t
String tradeLimitIntervalString = String.valueOf(dsItem.tradeLimitInterval / 1000 / 60 / 60);
String tradeLimitNextTimerString = sdf.format(dsItem.tradeLimitNextTimer);
- CreateButton(TRADE_LIMIT_AMOUNT, Material.PLAYER_HEAD,
- t(player, "ITEM_SETTING.TRADE_LIMIT_AMOUNT"),
- t(player, "ITEM_SETTING.TRADE_LIMIT_AMOUNT_LORE").replace("{num}", String.valueOf(dsItem.tradeLimit)));
+ CreateButton(TRADE_LIMIT_SELL, Material.PLAYER_HEAD,
+ t(player, "ITEM_SETTING.TRADE_LIMIT_SELL"),
+ t(player, "ITEM_SETTING.TRADE_LIMIT_SELL_LORE").replace("{num}", String.valueOf(dsItem.sellLimit)));
+ CreateButton(TRADE_LIMIT_BUY, Material.PLAYER_HEAD,
+ t(player, "ITEM_SETTING.TRADE_LIMIT_BUY"),
+ t(player, "ITEM_SETTING.TRADE_LIMIT_BUY_LORE").replace("{num}", String.valueOf(dsItem.buyLimit)));
- if (dsItem.tradeLimit != 0)
+ if (dsItem.sellLimit != 0 || dsItem.buyLimit != 0)
{
CreateButton(TRADE_LIMIT_INTERVAL, Material.CLOCK,
t(player, "ITEM_SETTING.TRADE_LIMIT_INTERVAL"),
@@ -314,7 +318,8 @@ public void OnClickUpperInventory(InventoryClickEvent e)
else if (e.getSlot() == REMOVE) RemoveItem();
else if (e.getSlot() == RECOMMEND) SetToRecommend();
else if (e.getSlot() == DISCOUNT) OnDiscountButtonClick(e.isLeftClick());
- else if (e.getSlot() == TRADE_LIMIT_AMOUNT) OnTradeLimitAmountButtonClick(e.isLeftClick(), e.isShiftClick());
+ else if (e.getSlot() == TRADE_LIMIT_SELL) OnSellLimitAmountButtonClick(e.isLeftClick(), e.isShiftClick());
+ else if (e.getSlot() == TRADE_LIMIT_BUY) OnBuyLimitAmountButtonClick(e.isLeftClick(), e.isShiftClick());
else if (e.getSlot() == TRADE_LIMIT_INTERVAL) OnTradeLimitIntervalButtonClick(e.isLeftClick(), e.isShiftClick());
else if (e.getSlot() == TRADE_LIMIT_INTERVAL_TIMER) OnTradeLimitTimerAdjustButtonClick(e.isLeftClick(), e.isShiftClick());
else if (e.getSlot() >= TAB_START && e.getSlot() <= TAB_END) ChangeTab(e.getSlot());
@@ -397,7 +402,7 @@ private void OnDiscountButtonClick(boolean isLeftClick)
RefreshWindow();
}
- private void OnTradeLimitAmountButtonClick(boolean isLeftClick, boolean isShift)
+ private void OnSellLimitAmountButtonClick(boolean isLeftClick, boolean isShift)
{
int mod;
if (isLeftClick)
@@ -412,8 +417,39 @@ private void OnTradeLimitAmountButtonClick(boolean isLeftClick, boolean isShift)
if (isShift)
mod *= 10;
- dsItem.tradeLimit += mod;
- if (dsItem.tradeLimit != 0 && dsItem.tradeLimitNextTimer == 0)
+ dsItem.sellLimit += mod;
+
+ if (dsItem.sellLimit < 0)
+ dsItem.sellLimit = 0;
+
+ if (dsItem.sellLimit != 0 && dsItem.tradeLimitNextTimer == 0)
+ {
+ CalcTradeLimitNextTimer();
+ }
+ RefreshWindow();
+ }
+
+ private void OnBuyLimitAmountButtonClick(boolean isLeftClick, boolean isShift)
+ {
+ int mod;
+ if (isLeftClick)
+ {
+ mod = -1;
+ }
+ else
+ {
+ mod = 1;
+ }
+
+ if (isShift)
+ mod *= 10;
+
+ dsItem.buyLimit += mod;
+
+ if (dsItem.buyLimit < 0)
+ dsItem.buyLimit = 0;
+
+ if (dsItem.buyLimit != 0 && dsItem.tradeLimitNextTimer == 0)
{
CalcTradeLimitNextTimer();
}
@@ -422,7 +458,7 @@ private void OnTradeLimitAmountButtonClick(boolean isLeftClick, boolean isShift)
private void OnTradeLimitIntervalButtonClick(boolean isLeftClick, boolean isShift)
{
- if (dsItem.tradeLimit == 0)
+ if (dsItem.sellLimit == 0 && dsItem.buyLimit == 0)
return;
long mod = 1000 * 60 * 60;
@@ -446,7 +482,7 @@ private void OnTradeLimitIntervalButtonClick(boolean isLeftClick, boolean isShif
private void OnTradeLimitTimerAdjustButtonClick(boolean isLeftClick, boolean isShift)
{
- if (dsItem.tradeLimit == 0)
+ if (dsItem.sellLimit == 0 && dsItem.buyLimit == 0)
return;
long mod = 1000 * 60 * 60;
@@ -481,7 +517,7 @@ private void SetToRecommend()
{
int sugMid = ShopUtil.CalcRecommendedMedian(worth, ConfigUtil.GetNumberOfPlayer());
DSItem newDSItem = new DSItem(inventory.getItem(SAMPLE_ITEM), worth, worth, dsItem.minPrice, dsItem.maxPrice, sugMid, sugMid, dsItem.maxStock, dsItem.discount,
- dsItem.tradeLimit, dsItem.tradeLimitInterval, dsItem.tradeLimitNextTimer);
+ dsItem.sellLimit, dsItem.buyLimit, dsItem.tradeLimitInterval, dsItem.tradeLimitNextTimer);
DynaShopAPI.openItemSettingGui(player, shopName, shopSlotIndex, currentTab, newDSItem, timerOffset);
player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "MESSAGE.RECOMMEND_APPLIED").replace("{playerNum}", String.valueOf(ConfigUtil.GetNumberOfPlayer())));
diff --git a/src/main/java/me/sat7/dynamicshop/guis/ItemTrade.java b/src/main/java/me/sat7/dynamicshop/guis/ItemTrade.java
index 1f74b06..4828fc5 100644
--- a/src/main/java/me/sat7/dynamicshop/guis/ItemTrade.java
+++ b/src/main/java/me/sat7/dynamicshop/guis/ItemTrade.java
@@ -261,11 +261,10 @@ private void CreateTradeButtons(boolean sell)
// 플레이어당 거래 제한
String tradeLimitString = "";
int tradeIdxInt = Integer.parseInt(tradeIdx);
- int tradeLimitLeft = UserUtil.GetTradingLimitLeft(player, shopName, tradeIdxInt, HashUtil.GetItemHash(new ItemStack(Material.getMaterial(material))));
+ int tradeLimitLeft = UserUtil.GetTradingLimitLeft(player, shopName, tradeIdxInt, HashUtil.GetItemHash(new ItemStack(Material.getMaterial(material))), sell);
if (tradeLimitLeft != Integer.MAX_VALUE)
{
- int limit = ShopUtil.GetTradeLimitPerPlayer(shopName, tradeIdxInt);
- String limitString = limit > 0 ? t(player, "SHOP.PURCHASE_LIMIT_PER_PLAYER") : t(player, "SHOP.SALES_LIMIT_PER_PLAYER");
+ String limitString = sell ? t(player, "SHOP.SALES_LIMIT_PER_PLAYER") : t(player, "SHOP.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/guis/Shop.java b/src/main/java/me/sat7/dynamicshop/guis/Shop.java
index a4f5cdf..93877b8 100644
--- a/src/main/java/me/sat7/dynamicshop/guis/Shop.java
+++ b/src/main/java/me/sat7/dynamicshop/guis/Shop.java
@@ -255,7 +255,7 @@ else if (DynaShopAPI.isPlayerPointShop(shopName))
{
sellText = t(player, "SHOP.SELL_PRICE" + currencyKey).replace("{num}", n(sellPrice));
}
-
+
sellText += showValueChange ? " " + valueChanged_Sell : "";
}
@@ -277,16 +277,25 @@ else if (DynaShopAPI.isPlayerPointShop(shopName))
stockText = t(player, "SHOP.STOCK").replace("{num}", stockStr);
}
- int tradeLimitLeft = UserUtil.GetTradingLimitLeft(player, shopName, tradeIdx, HashUtil.GetItemHash(itemStack));
- if (tradeLimitLeft != Integer.MAX_VALUE)
+ int sellLimitLeft = UserUtil.GetTradingLimitLeft(player, shopName, tradeIdx, HashUtil.GetItemHash(itemStack), true);
+ if (sellLimitLeft != Integer.MAX_VALUE)
{
- int limit = ShopUtil.GetTradeLimitPerPlayer(shopName, tradeIdx);
- String limitString = limit > 0 ? t(player, "SHOP.PURCHASE_LIMIT_PER_PLAYER") : t(player, "SHOP.SALES_LIMIT_PER_PLAYER");
- String tradeLimitResetTime = ShopUtil.GetTradeLimitNextResetTime(shopName, tradeIdx);
-
if (!stockText.isEmpty())
stockText += "\n";
- stockText += limitString.replace("{num}", String.valueOf(tradeLimitLeft)).replace("{time}", tradeLimitResetTime);
+ stockText += t(player, "SHOP.TRADE_LIMIT_SELL").replace("{num}", String.valueOf(sellLimitLeft));
+ }
+ int buyLimitLeft = UserUtil.GetTradingLimitLeft(player, shopName, tradeIdx, HashUtil.GetItemHash(itemStack), false);
+ if (buyLimitLeft != Integer.MAX_VALUE)
+ {
+ if (!stockText.isEmpty())
+ stockText += "\n";
+ stockText += t(player, "SHOP.TRADE_LIMIT_BUY").replace("{num}", String.valueOf(buyLimitLeft));
+ }
+
+ if (sellLimitLeft != Integer.MAX_VALUE || buyLimitLeft != Integer.MAX_VALUE)
+ {
+ String tradeLimitResetTime = ShopUtil.GetTradeLimitNextResetTime(shopName, tradeIdx);
+ stockText += "\n" + t(player, "SHOP.TRADE_LIMIT_TIMER").replace("{time}", tradeLimitResetTime);
}
String tradeLoreText = "";
@@ -597,7 +606,8 @@ else if (e.isRightClick() && player.hasPermission(P_ADMIN_SHOP_EDIT))
int stock = shopData.getInt(idx + ".stock");
int maxStock = shopData.getInt(idx + ".maxStock", -1);
int discount = shopData.getInt(idx + ".discount", 0);
- int tradeLimit = shopData.getInt(idx + ".tradeLimitPerPlayer.value", 0);
+ int sellLimit = shopData.getInt(idx + ".tradeLimitPerPlayer.sell", 0);
+ int buyLimit = shopData.getInt(idx + ".tradeLimitPerPlayer.buy", 0);
long tradeLimitInterval = shopData.getLong(idx + ".tradeLimitPerPlayer.interval", MathUtil.dayInMilliSeconds);
long tradeLimitNextTimer = shopData.getLong(idx + ".tradeLimitPerPlayer.nextTimer");
@@ -605,7 +615,7 @@ else if (e.isRightClick() && player.hasPermission(P_ADMIN_SHOP_EDIT))
iStack.setItemMeta((ItemMeta) shopData.get(idx + ".itemStack"));
DSItem dsItem = new DSItem(iStack, buyValue, sellValue, valueMin, valueMax, median, stock, maxStock, discount,
- tradeLimit, tradeLimitInterval, tradeLimitNextTimer);
+ sellLimit, buyLimit, tradeLimitInterval, tradeLimitNextTimer);
DynaShopAPI.openItemSettingGui(player, shopName, idx, 0, dsItem);
} else
{
diff --git a/src/main/java/me/sat7/dynamicshop/models/DSItem.java b/src/main/java/me/sat7/dynamicshop/models/DSItem.java
index b662871..974597e 100644
--- a/src/main/java/me/sat7/dynamicshop/models/DSItem.java
+++ b/src/main/java/me/sat7/dynamicshop/models/DSItem.java
@@ -18,7 +18,8 @@ public class DSItem
public int stock;
public int maxStock;
public int discount;
- public int tradeLimit;
+ public int sellLimit;
+ public int buyLimit;
public long tradeLimitInterval; // ms
public long tradeLimitNextTimer;
@@ -33,7 +34,7 @@ public DSItem(ItemStack itemStack, double buyValue, double sellValue, double min
setStock(stock);
maxStock = -1;
}
- public DSItem(ItemStack itemStack, double buyValue, double sellValue, double minPrice, double maxPrice, int median, int stock, int maxStock, int discount, int tradeLimit, long tradeLimitInterval, long tradeLimitNextTimer)
+ 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);
@@ -44,7 +45,8 @@ public DSItem(ItemStack itemStack, double buyValue, double sellValue, double min
setStock(stock);
setMaxStock(maxStock);
setDiscount(discount);
- setTradeLimit(tradeLimit);
+ setSellLimit(sellLimit);
+ setBuyLimit(buyLimit);
setTradeLimitInterval(tradeLimitInterval);
setTradeLimitNextTimer(tradeLimitNextTimer);
}
diff --git a/src/main/java/me/sat7/dynamicshop/transactions/Buy.java b/src/main/java/me/sat7/dynamicshop/transactions/Buy.java
index 7bcfbe5..8440279 100644
--- a/src/main/java/me/sat7/dynamicshop/transactions/Buy.java
+++ b/src/main/java/me/sat7/dynamicshop/transactions/Buy.java
@@ -59,7 +59,7 @@ else if (currency == ItemTrade.CURRENCY.PLAYER_POINT)
// 플레이어 당 거래량 제한 확인
int tradeIdxInt = Integer.parseInt(tradeIdx);
- int tradeLimitPerPlayer = ShopUtil.GetTradeLimitPerPlayer(shopName, tradeIdxInt);
+ int tradeLimitPerPlayer = ShopUtil.GetBuyLimitPerPlayer(shopName, tradeIdxInt);
int playerTradingVolume = UserUtil.GetPlayerTradingVolume(player, shopName, HashUtil.GetItemHash(itemStack));
for (int i = 0; i < itemStack.getAmount(); i++)
diff --git a/src/main/java/me/sat7/dynamicshop/transactions/Sell.java b/src/main/java/me/sat7/dynamicshop/transactions/Sell.java
index 14e4069..1c907eb 100644
--- a/src/main/java/me/sat7/dynamicshop/transactions/Sell.java
+++ b/src/main/java/me/sat7/dynamicshop/transactions/Sell.java
@@ -88,7 +88,7 @@ else if (data.get().contains("Options.flag.playerpoint"))
}
// 플레이어 당 거래량 제한 확인
- int sellLimit = ShopUtil.GetTradeLimitPerPlayer(shopName, tradeIdx);
+ int sellLimit = ShopUtil.GetSellLimitPerPlayer(shopName, tradeIdx);
if (player != null && sellLimit != 0)
{
tradeAmount = UserUtil.CheckTradeLimitPerPlayer(player, shopName, tradeIdx, HashUtil.GetItemHash(itemStack), tradeAmount, true);
@@ -251,7 +251,7 @@ public static void sell(ItemTrade.CURRENCY currency, Player player, String shopN
// 플레이어 당 거래량 제한 확인
int tradeIdxInt = Integer.parseInt(tradeIdx);
- int tradeLimitPerPlayer = ShopUtil.GetTradeLimitPerPlayer(shopName, tradeIdxInt);
+ int tradeLimitPerPlayer = ShopUtil.GetSellLimitPerPlayer(shopName, tradeIdxInt);
if (tradeLimitPerPlayer != 0)
{
tradeAmount = UserUtil.CheckTradeLimitPerPlayer(player, shopName, tradeIdxInt, HashUtil.GetItemHash(itemStack), tradeAmount, true);
diff --git a/src/main/java/me/sat7/dynamicshop/utilities/ConfigUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/ConfigUtil.java
index 96b8b61..4348ea4 100644
--- a/src/main/java/me/sat7/dynamicshop/utilities/ConfigUtil.java
+++ b/src/main/java/me/sat7/dynamicshop/utilities/ConfigUtil.java
@@ -14,7 +14,7 @@
public final class ConfigUtil
{
- public final static int PluginConfigVersion = 4;
+ public final static int PluginConfigVersion = 5;
public static int GetConfigVersion()
{
diff --git a/src/main/java/me/sat7/dynamicshop/utilities/LangUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/LangUtil.java
index 6f32423..2bc0ab7 100644
--- a/src/main/java/me/sat7/dynamicshop/utilities/LangUtil.java
+++ b/src/main/java/me/sat7/dynamicshop/utilities/LangUtil.java
@@ -95,8 +95,9 @@ public static void setupLangFile(String lang)
ccLang.get().addDefault("SHOP.DISABLED", "§c비활성§8|§f");
ccLang.get().addDefault("SHOP.INCOMPLETE_DATA", "불완전한 데이터");
ccLang.get().addDefault("SHOP.INCOMPLETE_DATA_Lore", "이 아이템은 어드민이 아닌\n유저에게는 보이지 않습니다.\nIndex: ");
- ccLang.get().addDefault("SHOP.PURCHASE_LIMIT_PER_PLAYER", "§a구매량 제한 : {num} 남음\n§a다음 리셋: {time}");
- ccLang.get().addDefault("SHOP.SALES_LIMIT_PER_PLAYER", "§a판매량 제한 : {num} 남음\n§a다음 리셋: {time}");
+ ccLang.get().addDefault("SHOP.TRADE_LIMIT_BUY", "§a구매량 제한 : {num} 남음");
+ ccLang.get().addDefault("SHOP.TRADE_LIMIT_SELL", "§a판매량 제한 : {num} 남음");
+ ccLang.get().addDefault("SHOP.TRADE_LIMIT_TIMER", "§a다음 리셋: {time}");
ccLang.get().addDefault("SHOP_SETTING_TITLE", "§3상점 설정");
ccLang.get().addDefault("SHOP_SETTING.LOG_TOGGLE_LORE", "§e우클릭: 로그 뷰어");
@@ -188,8 +189,10 @@ public static void setupLangFile(String lang)
ccLang.get().addDefault("ITEM_SETTING.REMOVE_LORE", "§f이 아이탬을 상점에서 제거합니다.");
ccLang.get().addDefault("ITEM_SETTING.BUY", "§3§l구매: {num}");
ccLang.get().addDefault("ITEM_SETTING.SELL", "§3§l판매: {num}");
- ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_AMOUNT", "§f플레이어 당 거래량 제한");
- ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_AMOUNT_LORE", "§f{num}\n§e좌클릭: -1, 우클릭: +1, 씨프트 = x10");
+ ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_SELL", "§f플레이어 당 판매량 제한");
+ ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_SELL_LORE", "§f{num}\n§eLMB: -1, RMB: +1, Shift = x10");
+ ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_BUY", "§f플레이어 당 구매량 제한");
+ ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_BUY_LORE", "§f{num}\n§eLMB: -1, RMB: +1, Shift = x10");
ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_INTERVAL", "§f거래량 제한 리셋 주기");
ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_INTERVAL_LORE", "§f주기: {interval}\n§f다음 리셋: {time}\n§e좌클릭: -1시간, 우클릭: +1시간, 씨프트 = x12");
ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_TIMER", "§f타이머 조정");
@@ -519,8 +522,9 @@ public static void setupLangFile(String lang)
ccLang.get().addDefault("SHOP.DISABLED", "§cDisabled§8|§f");
ccLang.get().addDefault("SHOP.INCOMPLETE_DATA", "INCOMPLETE DATA");
ccLang.get().addDefault("SHOP.INCOMPLETE_DATA_Lore", "This item is not visible\nto non-op users.\nIndex: ");
- ccLang.get().addDefault("SHOP.PURCHASE_LIMIT_PER_PLAYER", "§aPurchase limit: {num}left\n§aNext reset: {time}");
- ccLang.get().addDefault("SHOP.SALES_LIMIT_PER_PLAYER", "§aSales limit: {num}left\n§aNext reset: {time}");
+ ccLang.get().addDefault("SHOP.TRADE_LIMIT_BUY", "§aPurchase limit: {num}left");
+ ccLang.get().addDefault("SHOP.TRADE_LIMIT_SELL", "§aSales limit: {num}left");
+ ccLang.get().addDefault("SHOP.TRADE_LIMIT_TIMER", "§aNext reset: {time}");
ccLang.get().addDefault("SHOP_SETTING_TITLE", "§3Shop Settings");
ccLang.get().addDefault("SHOP_SETTING.LOG_TOGGLE_LORE", "§eRMB: Log Viewer");
@@ -612,8 +616,10 @@ public static void setupLangFile(String lang)
ccLang.get().addDefault("ITEM_SETTING.REMOVE_LORE", "§fRemove this item from the shop.");
ccLang.get().addDefault("ITEM_SETTING.BUY", "§3§lBuy: {num}");
ccLang.get().addDefault("ITEM_SETTING.SELL", "§3§lSell: {num}");
- ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_AMOUNT", "§fTrading volume limit per player");
- ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_AMOUNT_LORE", "§f{num}\n§eLMB: -1, RMB: +1, Shift = x10");
+ ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_SELL", "§fSales limit per player");
+ ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_SELL_LORE", "§f{num}\n§eLMB: -1, RMB: +1, Shift = x10");
+ ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_BUY", "§fPurchase limit per player");
+ ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_BUY_LORE", "§f{num}\n§eLMB: -1, RMB: +1, Shift = x10");
ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_INTERVAL", "§fTrading volume limit reset cycle");
ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_INTERVAL_LORE", "§fInterval: {interval}\n§fNext reset: {time}\n§eLMB: -1h, RMB: +1h, Shift = x12");
ccLang.get().addDefault("ITEM_SETTING.TRADE_LIMIT_TIMER", "§fAdjust Timer");
diff --git a/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java
index e5cb145..eb5f08c 100644
--- a/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java
+++ b/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java
@@ -10,6 +10,7 @@
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -34,6 +35,7 @@ public static void Reload()
{
ReloadAllShop();
ConvertOldShopData();
+ BackwardCompatibility();
SetupSampleShopFile();
SortShopDataAll();
}
@@ -59,6 +61,112 @@ public static void ReloadAllShop()
}
}
+ public static void SetupSampleShopFile()
+ {
+ if(ShopUtil.shopConfigFiles.isEmpty())
+ {
+ CustomConfig data = new CustomConfig();
+ data.setup("SampleShop", "Shop");
+
+ data.get().options().header("Shop name can not contain formatting codes, '/' and ' '");
+ data.get().options().copyHeader(true);
+
+ data.get().set("Options.page", 2);
+ data.get().set("Options.title", "Sample Shop");
+ data.get().set("Options.lore", "This is sample shop");
+ data.get().set("Options.permission", "");
+ data.get().set("0.mat", "DIRT");
+ data.get().set("0.value", 1);
+ data.get().set("0.median", 10000);
+ data.get().set("0.stock", 10000);
+ data.get().set("1.mat", "COBBLESTONE");
+ data.get().set("1.value", 1.5);
+ data.get().set("1.median", 10000);
+ data.get().set("1.stock", 10000);
+
+ shopConfigFiles.put("SampleShop", data);
+ shopDirty.put("SampleShop", false);
+
+ data.get().options().copyDefaults(true);
+ data.save();
+ }
+ }
+
+ // Shop.yml 한덩어리로 되있는 데이터를 새 버전 방식으로 변환함 (v2 -> v3)
+ public static void ConvertOldShopData()
+ {
+ File file = new File(DynamicShop.plugin.getDataFolder(), "Shop.yml");
+ if (file.exists())
+ {
+ CustomConfig oldShopData = new CustomConfig();
+ oldShopData.setup("Shop", null);
+
+ for(String oldShopName : oldShopData.get().getKeys(false))
+ {
+ ConfigurationSection oldData = oldShopData.get().getConfigurationSection(oldShopName);
+
+ CustomConfig data = new CustomConfig();
+ data.setup(oldShopName, "Shop");
+
+ for(String s : oldData.getKeys(false))
+ {
+ data.get().set(s, oldData.get(s));
+ }
+
+ if(data.get().contains("Options.hideStock"))
+ {
+ data.get().set("Options.flag.hidestock", "");
+ data.get().set("Options.hideStock", null);
+ }
+ if(data.get().contains("Options.hidePricingType"))
+ {
+ data.get().set("Options.flag.hidepricingtype", "");
+ data.get().set("Options.hidePricingType", null);
+ }
+ if(!data.get().contains("Options.lore"))
+ {
+ data.get().set("Options.lore","");
+ }
+
+ data.save();
+
+ ShopUtil.shopConfigFiles.put(oldShopName, data);
+ ShopUtil.shopDirty.put(oldShopName,false);
+ }
+
+ file.delete();
+ }
+ }
+
+ public static void BackwardCompatibility()
+ {
+ int userVersion = ConfigUtil.GetConfigVersion();
+ if (userVersion < 5)
+ {
+ for(Map.Entry entry : shopConfigFiles.entrySet())
+ {
+ FileConfiguration fc = entry.getValue().get();
+ for(String key : fc.getKeys(false))
+ {
+ if (fc.contains(key + ".tradeLimitPerPlayer.value"))
+ {
+ int old = fc.getInt(key + ".tradeLimitPerPlayer.value");
+ if (old < 0)
+ {
+ fc.set(key + ".tradeLimitPerPlayer.sell", old * -1);
+ }
+ else if (old > 0)
+ {
+ fc.set(key + ".tradeLimitPerPlayer.buy", old);
+ }
+
+ fc.set(key + ".tradeLimitPerPlayer.value", null);
+ }
+ }
+ }
+ }
+ }
+
// 상점에서 빈 슬롯 찾기
public static int findEmptyShopSlot(String shopName, int startIdx, boolean addPage)
{
@@ -230,9 +338,10 @@ public static boolean addItemToShop(String shopName, int idx, DSItem dsItem)
data.get().set(idx + ".discount", null);
}
- if (dsItem.tradeLimit != 0)
+ if (dsItem.sellLimit != 0 || dsItem.buyLimit != 0)
{
- data.get().set(idx + ".tradeLimitPerPlayer.value", dsItem.tradeLimit);
+ data.get().set(idx + ".tradeLimitPerPlayer.sell", dsItem.sellLimit);
+ data.get().set(idx + ".tradeLimitPerPlayer.buy", dsItem.buyLimit);
data.get().set(idx + ".tradeLimitPerPlayer.interval", dsItem.tradeLimitInterval);
data.get().set(idx + ".tradeLimitPerPlayer.nextTimer", dsItem.tradeLimitNextTimer);
}
@@ -322,9 +431,10 @@ public static void editShopItem(String shopName, int idx, DSItem dsItem)
else
data.get().set(idx + ".discount", null);
- if (dsItem.tradeLimit != 0)
+ if (dsItem.sellLimit != 0 || dsItem.buyLimit != 0)
{
- data.get().set(idx + ".tradeLimitPerPlayer.value", dsItem.tradeLimit);
+ data.get().set(idx + ".tradeLimitPerPlayer.sell", dsItem.sellLimit);
+ data.get().set(idx + ".tradeLimitPerPlayer.buy", dsItem.buyLimit);
data.get().set(idx + ".tradeLimitPerPlayer.interval", dsItem.tradeLimitInterval);
data.get().set(idx + ".tradeLimitPerPlayer.nextTimer", dsItem.tradeLimitNextTimer);
}
@@ -690,13 +800,14 @@ public static void SetToRecommendedValueAll(String shop, CommandSender sender)
if (worth != 0)
{
int discount = data.get().getInt(itemIndex + ".discount");
- int tradeLimit = data.get().getInt(itemIndex + ".tradeLimitPerPlayer.value");
+ int sellLimit = data.get().getInt(itemIndex + ".tradeLimitPerPlayer.sell");
+ int buyLimit = data.get().getInt(itemIndex + ".tradeLimitPerPlayer.buy");
long tradeLimitInterval = data.get().getLong(itemIndex + ".tradeLimitPerPlayer.interval");
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,
- tradeLimit, tradeLimitInterval, tradeLimitNextTimer);
+ sellLimit, buyLimit, tradeLimitInterval, tradeLimitNextTimer);
ShopUtil.editShopItem(shop, i, temp);
} else
{
@@ -805,7 +916,7 @@ else if (currencyInt != tempCurrencyIndex)
continue;
// 플레이어 당 거래량 제한 확인
- int sellLimit = ShopUtil.GetTradeLimitPerPlayer(entry.getKey(), sameItemIdx);
+ int sellLimit = ShopUtil.GetSellLimitPerPlayer(entry.getKey(), sameItemIdx);
if (player != null && sellLimit != 0)
{
int tradeAmount = UserUtil.CheckTradeLimitPerPlayer(player, entry.getKey(), sameItemIdx, HashUtil.GetItemHash(itemStack), itemStack.getAmount(), true);
@@ -909,7 +1020,7 @@ else if (currencyInt != tempCurrencyIndex)
}
// 플레이어 당 거래량 제한 확인
- int buyLimit = ShopUtil.GetTradeLimitPerPlayer(entry.getKey(), sameItemIdx);
+ int buyLimit = ShopUtil.GetBuyLimitPerPlayer(entry.getKey(), sameItemIdx);
if (player != null && buyLimit != 0)
{
int tradeAmount = UserUtil.CheckTradeLimitPerPlayer(player, entry.getKey(), sameItemIdx, HashUtil.GetItemHash(itemStack), itemStack.getAmount(), false);
@@ -1127,83 +1238,6 @@ public static int CalcShipping(String shopName, Player player)
return deliverycharge;
}
- public static void SetupSampleShopFile()
- {
- if(ShopUtil.shopConfigFiles.isEmpty())
- {
- CustomConfig data = new CustomConfig();
- data.setup("SampleShop", "Shop");
-
- data.get().options().header("Shop name can not contain formatting codes, '/' and ' '");
- data.get().options().copyHeader(true);
-
- data.get().set("Options.page", 2);
- data.get().set("Options.title", "Sample Shop");
- data.get().set("Options.lore", "This is sample shop");
- data.get().set("Options.permission", "");
- data.get().set("0.mat", "DIRT");
- data.get().set("0.value", 1);
- data.get().set("0.median", 10000);
- data.get().set("0.stock", 10000);
- data.get().set("1.mat", "COBBLESTONE");
- data.get().set("1.value", 1.5);
- data.get().set("1.median", 10000);
- data.get().set("1.stock", 10000);
-
- shopConfigFiles.put("SampleShop", data);
- shopDirty.put("SampleShop", false);
-
- data.get().options().copyDefaults(true);
- data.save();
- }
- }
-
- // Shop.yml 한덩어리로 되있는 데이터를 새 버전 방식으로 변환함
- public static void ConvertOldShopData()
- {
- File file = new File(DynamicShop.plugin.getDataFolder(), "Shop.yml");
- if (file.exists())
- {
- CustomConfig oldShopData = new CustomConfig();
- oldShopData.setup("Shop", null);
-
- for(String oldShopName : oldShopData.get().getKeys(false))
- {
- ConfigurationSection oldData = oldShopData.get().getConfigurationSection(oldShopName);
-
- CustomConfig data = new CustomConfig();
- data.setup(oldShopName, "Shop");
-
- for(String s : oldData.getKeys(false))
- {
- data.get().set(s, oldData.get(s));
- }
-
- if(data.get().contains("Options.hideStock"))
- {
- data.get().set("Options.flag.hidestock", "");
- data.get().set("Options.hideStock", null);
- }
- if(data.get().contains("Options.hidePricingType"))
- {
- data.get().set("Options.flag.hidepricingtype", "");
- data.get().set("Options.hidePricingType", null);
- }
- if(!data.get().contains("Options.lore"))
- {
- data.get().set("Options.lore","");
- }
-
- data.save();
-
- ShopUtil.shopConfigFiles.put(oldShopName, data);
- ShopUtil.shopDirty.put(oldShopName,false);
- }
-
- file.delete();
- }
- }
-
public static void SortShopDataAll()
{
for(String s : shopConfigFiles.keySet())
@@ -1405,7 +1439,19 @@ public static void ForceSaveAllShop()
}
}
- public static int GetTradeLimitPerPlayer(String shopName, int idx)
+ public static int GetSellLimitPerPlayer(String shopName, int idx)
+ {
+ CustomConfig data = ShopUtil.shopConfigFiles.get(shopName);
+
+ if (!data.get().contains(idx + ".tradeLimitPerPlayer"))
+ {
+ return 0;
+ }
+
+ return data.get().getInt(idx + ".tradeLimitPerPlayer.sell");
+ }
+
+ public static int GetBuyLimitPerPlayer(String shopName, int idx)
{
CustomConfig data = ShopUtil.shopConfigFiles.get(shopName);
@@ -1414,7 +1460,7 @@ public static int GetTradeLimitPerPlayer(String shopName, int idx)
return 0;
}
- return data.get().getInt(idx + ".tradeLimitPerPlayer.value");
+ return data.get().getInt(idx + ".tradeLimitPerPlayer.buy");
}
private final static SimpleDateFormat sdf = new SimpleDateFormat("MM.dd.yyyy HH:mm:ss");
diff --git a/src/main/java/me/sat7/dynamicshop/utilities/TabCompleteUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/TabCompleteUtil.java
index e9f7b6b..9f5b6ef 100644
--- a/src/main/java/me/sat7/dynamicshop/utilities/TabCompleteUtil.java
+++ b/src/main/java/me/sat7/dynamicshop/utilities/TabCompleteUtil.java
@@ -41,7 +41,16 @@ public static List onTabCompleteBody(DynamicShop dynamicShop, CommandSen
temp.clear();
autoCompleteList.clear();
- if (cmd.getName().equalsIgnoreCase("shop") && args.length == 1)
+ if (cmd.getName().equalsIgnoreCase("sell") && args.length == 1)
+ {
+ temp.add("hand");
+ temp.add("handall");
+ temp.add("all");
+ AddToAutoCompleteIfValid(args[0]);
+
+ return autoCompleteList;
+ }
+ else if (cmd.getName().equalsIgnoreCase("shop") && args.length == 1)
{
if (!ConfigUtil.GetUseShopCommand()) return autoCompleteList;
diff --git a/src/main/java/me/sat7/dynamicshop/utilities/UserUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/UserUtil.java
index 91cf555..0d56567 100644
--- a/src/main/java/me/sat7/dynamicshop/utilities/UserUtil.java
+++ b/src/main/java/me/sat7/dynamicshop/utilities/UserUtil.java
@@ -102,6 +102,8 @@ public static void OnPluginDisable()
ccUser.save();
}
+ // ----------------------------------------------------------------------
+
// 구매 & 판매 수량 제한
// - 상점의 데이터는 [상점+idx] 로 관리.
// - 유저의 데이터는 [상점+hash] 로 관리.
@@ -207,41 +209,31 @@ public static void OnPlayerTradeLimitedItem(Player player, String shopName, Stri
public static int CheckTradeLimitPerPlayer(Player player, String shopName, int tradeIdx, String hash, int tradeAmount, boolean isSell)
{
- int limit = ShopUtil.GetTradeLimitPerPlayer(shopName, tradeIdx);
- int userData = GetPlayerTradingVolume(player, shopName, hash);
-
- if (isSell && limit < 0 && limit > userData - tradeAmount)
- {
- tradeAmount = (limit - userData) * -1;
- }
- else if (!isSell && limit > 0 && limit < userData + tradeAmount)
- {
- tradeAmount = limit - userData;
- }
+ int limit = isSell ? ShopUtil.GetSellLimitPerPlayer(shopName, tradeIdx) : ShopUtil.GetBuyLimitPerPlayer(shopName, tradeIdx);
+ if (limit == 0)
+ return tradeAmount;
- return tradeAmount;
+ int left = GetTradingLimitLeft(player, shopName, tradeIdx, hash, isSell);
+ return Math.min(left, tradeAmount);
}
- public static int GetTradingLimitLeft(Player player, String shopName, int itemIdx, String hash)
+ public static int GetTradingLimitLeft(Player player, String shopName, int itemIdx, String hash, boolean isSell)
{
int playerCurrent = GetPlayerTradingVolume(player, shopName, hash);
- int limit = ShopUtil.GetTradeLimitPerPlayer(shopName, itemIdx);
+ int limit = isSell ? ShopUtil.GetSellLimitPerPlayer(shopName, itemIdx) : ShopUtil.GetBuyLimitPerPlayer(shopName, itemIdx);
+ if (limit == 0)
+ return Integer.MAX_VALUE;
- if (limit < 0)
+ if (isSell)
{
- int temp = limit - playerCurrent;
- temp *= -1;
-
+ int temp = limit + playerCurrent;
return Math.max(0, temp);
}
- else if (limit > 0)
+ else
{
int temp = limit - playerCurrent;
-
return Math.max(0, temp);
}
-
- return Integer.MAX_VALUE;
}
public static void ClearTradeLimitData(String shopName)
@@ -251,7 +243,6 @@ public static void ClearTradeLimitData(String shopName)
tradingVolume.remove(shopName);
}
-
public static void ClearTradeLimitData(UUID player, String shopName)
{
for (Map.Entry>> shopMap : tradingVolume.entrySet())
@@ -271,7 +262,6 @@ public static void ClearTradeLimitData(UUID player, String shopName)
}
}
}
-
public static void ClearTradeLimitData(String shopName, int idx)
{
CustomConfig data = ShopUtil.shopConfigFiles.get(shopName);
@@ -299,7 +289,6 @@ public static void OnRenameShop(String shopName, String newName)
tradingVolume.put(newName, tradingVolume.get(shopName));
tradingVolume.remove(shopName);
}
-
public static void OnMergeShop(String shopA, String shopB)
{
if (!tradingVolume.containsKey(shopB) || tradingVolume.get(shopB) == null)
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index bd7c42b..8faaf82 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -12,6 +12,8 @@ commands:
aliases: [ds]
shop:
description: "Open shop menu"
+ sell:
+ description: "Sell items"
permissions:
dshop.use:
description: Allows use of the /ds command