diff --git a/src/main/java/me/sat7/dynamicshop/DynaShopAPI.java b/src/main/java/me/sat7/dynamicshop/DynaShopAPI.java index 61e3aee..86c9af6 100644 --- a/src/main/java/me/sat7/dynamicshop/DynaShopAPI.java +++ b/src/main/java/me/sat7/dynamicshop/DynaShopAPI.java @@ -377,7 +377,7 @@ public static boolean isJobsPointShop(@NonNull String shopName) throws IllegalAr if (validateShopName(shopName)) { CustomConfig data = ShopUtil.shopConfigFiles.get(shopName); - return data.get().contains("Options.flag.jobpoint"); + return data.get().getString("Options.currency","").equalsIgnoreCase("jobpoint"); } else { throw new IllegalArgumentException("Shop: " + shopName + " does not exist"); @@ -396,7 +396,7 @@ public static boolean isPlayerPointShop(@NonNull String shopName) throws Illegal if (validateShopName(shopName)) { CustomConfig data = ShopUtil.shopConfigFiles.get(shopName); - return data.get().contains("Options.flag.playerpoint"); + return data.get().getString("Options.currency","").equalsIgnoreCase("playerpoint"); } else { throw new IllegalArgumentException("Shop: " + shopName + " does not exist"); diff --git a/src/main/java/me/sat7/dynamicshop/commands/CMDManager.java b/src/main/java/me/sat7/dynamicshop/commands/CMDManager.java index 8505abe..2e4b8d4 100644 --- a/src/main/java/me/sat7/dynamicshop/commands/CMDManager.java +++ b/src/main/java/me/sat7/dynamicshop/commands/CMDManager.java @@ -28,6 +28,7 @@ public class CMDManager public static EditAll editAll; public static Enable enable; public static Flag flag; + public static Currency currency; public static Fluctuation fluctuation; public static Log log; public static MaxPage maxPage; @@ -79,6 +80,7 @@ public static void Init() edit = new Edit(); editAll = new EditAll(); enable = new Enable(); + currency = new Currency(); flag = new Flag(); fluctuation = new Fluctuation(); log = new Log(); @@ -98,6 +100,7 @@ public static void Init() CMDHashMap.put("edit", edit); CMDHashMap.put("editall", editAll); CMDHashMap.put("enable", enable); + CMDHashMap.put("currency", currency); CMDHashMap.put("flag", flag); CMDHashMap.put("fluctuation", fluctuation); CMDHashMap.put("log", log); diff --git a/src/main/java/me/sat7/dynamicshop/commands/CreateShop.java b/src/main/java/me/sat7/dynamicshop/commands/CreateShop.java index b64e0d6..32ea76c 100644 --- a/src/main/java/me/sat7/dynamicshop/commands/CreateShop.java +++ b/src/main/java/me/sat7/dynamicshop/commands/CreateShop.java @@ -51,6 +51,7 @@ public void RunCMD(String[] args, CommandSender sender) data.get().set("Options.enable", false); data.get().set("Options.lore", ""); data.get().set("Options.page", 2); + data.get().set("Options.currency", "vault"); if (args.length >= 3) { if (args[2].equalsIgnoreCase("true")) diff --git a/src/main/java/me/sat7/dynamicshop/commands/Help.java b/src/main/java/me/sat7/dynamicshop/commands/Help.java index 385065d..896c772 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)) @@ -173,6 +173,9 @@ public static void showHelp(String helpcode, Player player, String[] args) } else if (helpcode.equals("max_page")) { CMDManager.maxPage.SendHelpMessage(player); + } else if (helpcode.equals("currency")) + { + CMDManager.currency.SendHelpMessage(player); } else if (helpcode.equals("flag")) { CMDManager.flag.SendHelpMessage(player); diff --git a/src/main/java/me/sat7/dynamicshop/commands/shop/Account.java b/src/main/java/me/sat7/dynamicshop/commands/shop/Account.java index 42c353d..f9c7734 100644 --- a/src/main/java/me/sat7/dynamicshop/commands/shop/Account.java +++ b/src/main/java/me/sat7/dynamicshop/commands/shop/Account.java @@ -117,8 +117,7 @@ public void RunCMD(String[] args, CommandSender sender) } // 출발 상점과 도착 상점의 통화 유형이 다름 - if ((shopData.get().contains("Options.flag.jobpoint") != targetShopData.get().contains("Options.flag.jobpoint")) || - (shopData.get().contains("Options.flag.playerpoint") != targetShopData.get().contains("Options.flag.playerpoint")) ) + if (!shopData.get().getString("Options.currency", "").equals(targetShopData.get().getString("Options.currency", ""))) { sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "ERR.SHOP_DIFF_CURRENCY")); return; @@ -157,16 +156,21 @@ public void RunCMD(String[] args, CommandSender sender) // 출발 상점에 돈이 부족 if (ShopUtil.getShopBalance(args[1]) < amount) { - if (shopData.get().contains("Options.flag.jobpoint")) + if (shopData.get().getString("Options.currency","").equalsIgnoreCase("jobpoint")) { sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "MESSAGE.NOT_ENOUGH_POINT"). replace("{bal}", n(ShopUtil.getShopBalance(args[1])))); } - else if (shopData.get().contains("Options.flag.playerpoint")) + else if (shopData.get().getString("Options.currency","").equalsIgnoreCase("playerpoint")) { sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "MESSAGE.NOT_ENOUGH_PLAYER_POINT"). replace("{bal}", n(ShopUtil.getShopBalance(args[1])))); } + else if (shopData.get().getString("Options.currency","").equalsIgnoreCase("exp")) + { + sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "MESSAGE.NOT_ENOUGH_EXP_POINT"). + replace("{bal}", n(ShopUtil.getShopBalance(args[1])))); + } else { sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "MESSAGE.NOT_ENOUGH_MONEY"). @@ -193,8 +197,7 @@ else if (shopData.get().contains("Options.flag.playerpoint")) } // 출발 상점과 도착 상점의 통화 유형이 다름 - if ((shopData.get().contains("Options.flag.jobpoint") != targetShopData.get().contains("Options.flag.jobpoint")) || - (shopData.get().contains("Options.flag.playerpoint") != targetShopData.get().contains("Options.flag.playerpoint")) ) + if (!shopData.get().getString("Options.currency", "").equals(targetShopData.get().getString("Options.currency", ""))) { sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "ERR.SHOP_DIFF_CURRENCY")); return; @@ -222,7 +225,7 @@ else if (shopData.get().contains("Options.flag.playerpoint")) return; } - if (shopData.get().contains("Options.flag.jobpoint")) + if (shopData.get().getString("Options.currency","").equalsIgnoreCase("jobpoint")) { JobsHook.addJobsPoint(target, amount); ShopUtil.addShopBalance(args[1], amount * -1); @@ -230,7 +233,7 @@ else if (shopData.get().contains("Options.flag.playerpoint")) sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "MESSAGE.TRANSFER_SUCCESS")); } - else if (shopData.get().contains("Options.flag.playerpoint")) + else if (shopData.get().getString("Options.currency","").equalsIgnoreCase("playerpoint")) { PlayerpointHook.addPP(target, amount); ShopUtil.addShopBalance(args[1], amount * -1); @@ -238,6 +241,14 @@ else if (shopData.get().contains("Options.flag.playerpoint")) sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "MESSAGE.TRANSFER_SUCCESS")); } + else if (shopData.get().getString("Options.currency","").equalsIgnoreCase("exp")) + { + target.giveExp((int)amount); + ShopUtil.addShopBalance(args[1], amount * -1); + shopData.save(); + + sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "MESSAGE.TRANSFER_SUCCESS")); + } else { Economy econ = DynamicShop.getEconomy(); diff --git a/src/main/java/me/sat7/dynamicshop/commands/shop/Currency.java b/src/main/java/me/sat7/dynamicshop/commands/shop/Currency.java new file mode 100644 index 0000000..de093fe --- /dev/null +++ b/src/main/java/me/sat7/dynamicshop/commands/shop/Currency.java @@ -0,0 +1,57 @@ +package me.sat7.dynamicshop.commands.shop; + +import me.sat7.dynamicshop.DynamicShop; +import me.sat7.dynamicshop.commands.DSCMD; +import me.sat7.dynamicshop.commands.Shop; +import me.sat7.dynamicshop.constants.Constants; +import me.sat7.dynamicshop.files.CustomConfig; +import me.sat7.dynamicshop.utilities.LangUtil; +import me.sat7.dynamicshop.utilities.ShopUtil; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import static me.sat7.dynamicshop.constants.Constants.P_ADMIN_SHOP_EDIT; +import static me.sat7.dynamicshop.utilities.LangUtil.t; + +public class Currency extends DSCMD +{ + public Currency() + { + inGameUseOnly = false; + permission = P_ADMIN_SHOP_EDIT; + validArgCount.add(4); + } + + @Override + public void SendHelpMessage(Player player) + { + player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "HELP.TITLE").replace("{command}", "currency")); + player.sendMessage(" - " + t(player, "HELP.USAGE") + ": ... currency "); + + player.sendMessage(""); + } + + @Override + public void RunCMD(String[] args, CommandSender sender) + { + if(!CheckValid(args, sender)) + return; + + String shopName = Shop.GetShopName(args); + CustomConfig shopData = ShopUtil.shopConfigFiles.get(shopName); + + if (args[3].equalsIgnoreCase("vault") || + args[3].equalsIgnoreCase("exp") || + args[3].equalsIgnoreCase("playerpoint") || + args[3].equalsIgnoreCase("jobpoint")) + { + shopData.get().set("Options.currency", args[3].toLowerCase()); + shopData.save(); + + sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "MESSAGE.CHANGES_APPLIED") + args[2] + " " + args[3]); + } else + { + sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "ERR.WRONG_USAGE")); + } + } +} diff --git a/src/main/java/me/sat7/dynamicshop/commands/shop/Flag.java b/src/main/java/me/sat7/dynamicshop/commands/shop/Flag.java index e7708af..aaa5887 100644 --- a/src/main/java/me/sat7/dynamicshop/commands/shop/Flag.java +++ b/src/main/java/me/sat7/dynamicshop/commands/shop/Flag.java @@ -59,8 +59,6 @@ public void RunCMD(String[] args, CommandSender sender) if (args[3].equalsIgnoreCase("signshop") || args[3].equalsIgnoreCase("localshop") || args[3].equalsIgnoreCase("deliverycharge") || - args[3].equalsIgnoreCase("jobpoint") || - args[3].equalsIgnoreCase("playerpoint") || args[3].equalsIgnoreCase("showValueChange") || args[3].equalsIgnoreCase("hidestock") || args[3].equalsIgnoreCase("hidepricingtype") || diff --git a/src/main/java/me/sat7/dynamicshop/guis/ItemTrade.java b/src/main/java/me/sat7/dynamicshop/guis/ItemTrade.java index 4828fc5..48dfe5c 100644 --- a/src/main/java/me/sat7/dynamicshop/guis/ItemTrade.java +++ b/src/main/java/me/sat7/dynamicshop/guis/ItemTrade.java @@ -54,7 +54,7 @@ public ItemTrade() private ItemMeta itemMeta; public enum CURRENCY - {VAULT, JOB_POINT, PLAYER_POINT} + {VAULT, EXP, JOB_POINT, PLAYER_POINT} public Inventory getGui(Player player, String shopName, String tradeIdx) { @@ -106,12 +106,15 @@ public void OnClickUpperInventory(InventoryClickEvent e) } } else if (e.getSlot() == CHECK_BALANCE) { - if (data.get().contains("Options.flag.jobpoint")) + if (data.get().getString("Options.currency","").equalsIgnoreCase("jobpoint")) { player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "TRADE.BALANCE") + ":§f " + n(JobsHook.getCurJobPoints(player)) + t(player, "JOB_POINTS")); - } else if (data.get().contains("Options.flag.playerpoint")) + } else if (data.get().getString("Options.currency","").equalsIgnoreCase("playerpoint")) { player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "TRADE.BALANCE") + ":§f " + n(PlayerpointHook.getCurrentPP(player)) + t(player, "PLAYER_POINTS")); + } else if (data.get().getString("Options.currency","").equalsIgnoreCase("exp")) + { + player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "TRADE.BALANCE") + ":§f " + n(player.getTotalExperience()) + t(player, "EXP_POINTS")); } else { player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "TRADE.BALANCE") + ":§f " + n(DynamicShop.getEconomy().getBalance(player))); @@ -186,14 +189,18 @@ private void CreateBalanceButton() String myBalanceString; ConfigurationSection optionS = shopData.getConfigurationSection("Options"); - if (optionS.contains("flag.jobpoint")) + if (optionS.getString("currency","").equalsIgnoreCase("jobpoint")) { myBalanceString = "§f" + n(JobsHook.getCurJobPoints(player)) + t(player,"JOB_POINTS"); } - else if (optionS.contains("flag.playerpoint")) + else if (optionS.getString("currency","").equalsIgnoreCase("playerpoint")) { myBalanceString = "§f" + n(PlayerpointHook.getCurrentPP(player)) + t(player,"PLAYER_POINTS"); } + else if (optionS.getString("currency","").equalsIgnoreCase("exp")) + { + myBalanceString = "§f" + n(player.getTotalExperience()) + t(player,"EXP_POINTS"); + } else { myBalanceString = "§f" + n(DynamicShop.getEconomy().getBalance(player)); @@ -202,11 +209,15 @@ else if (optionS.contains("flag.playerpoint")) if (ShopUtil.getShopBalance(shopName) >= 0) { double d = ShopUtil.getShopBalance(shopName); - balStr = n(d); - if (optionS.contains("flag.jobpoint")) - balStr += t(player, "JOB_POINTS"); - else if (optionS.contains("flag.playerpoint")) - balStr += t(player, "PLAYER_POINTS"); + + if (optionS.getString("currency","").equalsIgnoreCase("jobpoint")) + balStr = n(d) + t(player, "JOB_POINTS"); + else if (optionS.getString("currency","").equalsIgnoreCase("playerpoint")) + balStr = n(d, true) + t(player, "PLAYER_POINTS"); + else if (optionS.getString("currency","").equalsIgnoreCase("exp")) + balStr = n(d, true) + t(player, "EXP_POINTS"); + else + balStr = n(d); } else { balStr = t(player, "TRADE.SHOP_BAL_INF"); @@ -284,14 +295,21 @@ private void CreateTradeButtons(boolean sell) String lore; String priceText; + boolean isIntTypeCurrency = false; String currencyKey = ""; - if (shopData.contains("Options.flag.jobpoint")) + if (shopData.getString("Options.currency","").equalsIgnoreCase("jobpoint")) { currencyKey = "_JP"; } - else if (shopData.contains("Options.flag.playerpoint")) + else if (shopData.getString("Options.currency","").equalsIgnoreCase("playerpoint")) { currencyKey = "_PP"; + isIntTypeCurrency = true; + } + else if (shopData.getString("Options.currency","").equalsIgnoreCase("exp")) + { + currencyKey = "_EXP"; + isIntTypeCurrency = true; } if (sell) @@ -300,12 +318,12 @@ else if (shopData.contains("Options.flag.playerpoint")) if (shopData.contains(tradeIdx + ".discount")) { - String original = n(price * 100 / (double) (100 - shopData.getInt(tradeIdx + ".discount"))); - priceText = t(player, "TRADE.SELL_PRICE_DISCOUNTED" + currencyKey).replace("{num}", original).replace("{num2}", n(price)); + String original = n(price * 100 / (double) (100 - shopData.getInt(tradeIdx + ".discount")), isIntTypeCurrency); + priceText = t(player, "TRADE.SELL_PRICE_DISCOUNTED" + currencyKey).replace("{num}", original).replace("{num2}", n(price, isIntTypeCurrency)); } else { - priceText = t(player, "TRADE.SELL_PRICE" + currencyKey).replace("{num}", n(price)); + priceText = t(player, "TRADE.SELL_PRICE" + currencyKey).replace("{num}", n(price, isIntTypeCurrency)); } } else @@ -314,12 +332,12 @@ else if (shopData.contains("Options.flag.playerpoint")) if (shopData.contains(tradeIdx + ".discount")) { - String original = n(price * 100 / (double) (100 - shopData.getInt(tradeIdx + ".discount"))); - priceText = t(player, "TRADE.PRICE_DISCOUNTED" + currencyKey).replace("{num}", original).replace("{num2}", n(price)); + String original = n(price * 100 / (double) (100 - shopData.getInt(tradeIdx + ".discount")), isIntTypeCurrency); + priceText = t(player, "TRADE.PRICE_DISCOUNTED" + currencyKey).replace("{num}", original).replace("{num2}", n(price, isIntTypeCurrency)); } else { - priceText = t(player, "TRADE.PRICE" + currencyKey).replace("{num}", n(price)); + priceText = t(player, "TRADE.PRICE" + currencyKey).replace("{num}", n(price, isIntTypeCurrency)); } } @@ -426,14 +444,18 @@ private void Sell(ConfigurationSection options, ItemStack itemStack, int deliver return; } - if (options.contains("flag.jobpoint")) + if (options.getString("currency","").equalsIgnoreCase("jobpoint")) { Sell.sell(CURRENCY.JOB_POINT, player, shopName, tradeIdx, itemStack, -deliveryCharge, infiniteStock); } - else if (options.contains("flag.playerpoint")) + else if (options.getString("currency","").equalsIgnoreCase("playerpoint")) { Sell.sell(CURRENCY.PLAYER_POINT, player, shopName, tradeIdx, itemStack, -deliveryCharge, infiniteStock); } + else if (options.getString("currency","").equalsIgnoreCase("exp")) + { + Sell.sell(CURRENCY.EXP, player, shopName, tradeIdx, itemStack, -deliveryCharge, infiniteStock); + } else { Sell.sell(CURRENCY.VAULT, player, shopName, tradeIdx, itemStack, -deliveryCharge, infiniteStock); @@ -449,14 +471,18 @@ private void Buy(ConfigurationSection options, ItemStack itemStack, int delivery return; } - if (options.contains("flag.jobpoint")) + if (options.getString("currency","").equalsIgnoreCase("jobpoint")) { Buy.buy(CURRENCY.JOB_POINT, player, shopName, tradeIdx, itemStack, deliveryCharge, infiniteStock); } - else if (options.contains("flag.playerpoint")) + else if (options.getString("currency","").equalsIgnoreCase("playerpoint")) { Buy.buy(CURRENCY.PLAYER_POINT, player, shopName, tradeIdx, itemStack, deliveryCharge, infiniteStock); } + else if (options.getString("currency","").equalsIgnoreCase("exp")) + { + Buy.buy(CURRENCY.EXP, player, shopName, tradeIdx, itemStack, deliveryCharge, infiniteStock); + } else { Buy.buy(CURRENCY.VAULT, player, shopName, tradeIdx, itemStack, deliveryCharge, infiniteStock); diff --git a/src/main/java/me/sat7/dynamicshop/guis/Shop.java b/src/main/java/me/sat7/dynamicshop/guis/Shop.java index 93877b8..81965d1 100644 --- a/src/main/java/me/sat7/dynamicshop/guis/Shop.java +++ b/src/main/java/me/sat7/dynamicshop/guis/Shop.java @@ -53,12 +53,12 @@ public Inventory getGui(Player player, String shopName, int page) { shopData = ShopUtil.shopConfigFiles.get(shopName).get(); - if (!JobsHook.jobsRebornActive && shopData.contains("Options.flag.jobpoint")) + if (!JobsHook.jobsRebornActive && shopData.getString("Options.currency","").equalsIgnoreCase("jobpoint")) { player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "ERR.JOBS_REBORN_NOT_FOUND")); return null; } - if (!PlayerpointHook.isPPActive && shopData.contains("Options.flag.playerpoint")) + if (!PlayerpointHook.isPPActive && shopData.getString("Options.currency","").equalsIgnoreCase("playerpoint")) { player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "ERR.PLAYER_POINT_NOT_FOUND")); return null; @@ -218,6 +218,7 @@ private void ShowItems() boolean showValueChange = shopData.contains("Options.flag.showvaluechange"); + boolean isIntTypeCurrency = false; String currencyKey = ""; if (DynaShopAPI.isJobsPointShop(shopName)) { @@ -226,6 +227,12 @@ private void ShowItems() else if (DynaShopAPI.isPlayerPointShop(shopName)) { currencyKey = "_PP"; + isIntTypeCurrency = true; + } + else if (shopData.getString("Options.currency","").equalsIgnoreCase("exp")) + { + currencyKey = "_EXP"; + isIntTypeCurrency = true; } String buyText = ""; @@ -234,12 +241,12 @@ else if (DynaShopAPI.isPlayerPointShop(shopName)) { if(shopData.contains(s + ".discount")) { - String original = n(buyPrice * 100 / (double) (100 - shopData.getInt(s + ".discount"))); - buyText = t(player, "SHOP.BUY_PRICE_DISCOUNTED" + currencyKey).replace("{num}", original).replace("{num2}", n(buyPrice)); + String original = n(buyPrice * 100 / (double) (100 - shopData.getInt(s + ".discount")),isIntTypeCurrency); + buyText = t(player, "SHOP.BUY_PRICE_DISCOUNTED" + currencyKey).replace("{num}", original).replace("{num2}", n(buyPrice,isIntTypeCurrency)); } else { - buyText = t(player, "SHOP.BUY_PRICE" + currencyKey).replace("{num}", n(buyPrice)); + buyText = t(player, "SHOP.BUY_PRICE" + currencyKey).replace("{num}", n(buyPrice,isIntTypeCurrency)); } buyText += showValueChange ? " " + valueChanged_Buy : ""; } @@ -248,12 +255,12 @@ else if (DynaShopAPI.isPlayerPointShop(shopName)) { if(shopData.contains(s + ".discount")) { - String original = n(sellPrice * 100 / (double) (100 - shopData.getInt(s + ".discount"))); - sellText = t(player, "SHOP.SELL_PRICE_DISCOUNTED" + currencyKey).replace("{num}", original).replace("{num2}", n(sellPrice)); + String original = n(sellPrice * 100 / (double) (100 - shopData.getInt(s + ".discount")),isIntTypeCurrency); + sellText = t(player, "SHOP.SELL_PRICE_DISCOUNTED" + currencyKey).replace("{num}", original).replace("{num2}", n(sellPrice,isIntTypeCurrency)); } else { - sellText = t(player, "SHOP.SELL_PRICE" + currencyKey).replace("{num}", n(sellPrice)); + sellText = t(player, "SHOP.SELL_PRICE" + currencyKey).replace("{num}", n(sellPrice,isIntTypeCurrency)); } sellText += showValueChange ? " " + valueChanged_Sell : ""; @@ -430,11 +437,15 @@ private String CreateShopInfoText() finalShopBalanceText += t(player, "SHOP.SHOP_BAL") + "\n"; if (ShopUtil.getShopBalance(shopName) >= 0) { - String temp = n(ShopUtil.getShopBalance(shopName)); - if (shopData.contains("Options.flag.jobpoint")) - temp += t(player,"JOB_POINTS"); - else if (shopData.contains("Options.flag.playerpoint")) - temp += t(player,"PLAYER_POINTS"); + String temp; + if (shopData.getString("Options.currency","").equalsIgnoreCase("jobpoint")) + temp = n(ShopUtil.getShopBalance(shopName)) + t(player,"JOB_POINTS"); + else if (shopData.getString("Options.currency","").equalsIgnoreCase("playerpoint")) + temp = n(ShopUtil.getShopBalance(shopName), true) + t(player,"PLAYER_POINTS"); + else if (shopData.getString("Options.currency","").equalsIgnoreCase("exp")) + temp = n(ShopUtil.getShopBalance(shopName), true) + t(player,"EXP_POINTS"); + else + temp = n(ShopUtil.getShopBalance(shopName)); finalShopBalanceText += t(player, "SHOP.SHOP_INFO_DASH") + temp + "\n"; } else diff --git a/src/main/java/me/sat7/dynamicshop/guis/ShopSettings.java b/src/main/java/me/sat7/dynamicshop/guis/ShopSettings.java index d2f2893..a154add 100644 --- a/src/main/java/me/sat7/dynamicshop/guis/ShopSettings.java +++ b/src/main/java/me/sat7/dynamicshop/guis/ShopSettings.java @@ -50,18 +50,21 @@ public ShopSettings() private final int STABLE_INTERVAL = 25; private final int STABLE_STRENGTH = 26; - private final int FLAG1 = 9; - private final int FLAG2 = 10; - private final int FLAG3 = 11; - private final int FLAG4 = 12; - private final int FLAG5 = 18; - private final int FLAG6 = 19; - private final int FLAG7 = 20; - private final int FLAG8 = 21; - private final int FLAG9 = 22; - private final int FLAG10 = 13; - private final int FLAG11 = 27; - private final int FLAG12 = 28; + private final int FLAG_SIGNSHOP = 9; + private final int FLAG_LOCALSHOP = 10; + private final int FLAG_DELIVERY = 11; + private final int FLAG_SHOW_VALUE_CHANGE = 12; + private final int FLAG_HIDE_STOCK = 13; + private final int FLAG_HIDE_PRICING_TYPE = 18; + private final int FLAG_HIDE_SHOP_BALANCE = 19; + private final int FLAG_SHOW_MAX_STOCK = 20; + private final int FLAG_HIDDEN_IN_COMMAND = 21; + private final int FLAG_INT_ONLY = 22; + + private final int CURRENCY_VAULT = 27; + private final int CURRENCY_EXP = 28; + private final int CURRENCY_JP = 29; + private final int CURRENCY_PP = 30; private final int CMD_TOGGLE = 33; private final int CMD_SELL = 34; @@ -75,6 +78,7 @@ public ShopSettings() private final int CLOSE = 45; private String shopName; + private String currency; public Inventory getGui(Player player, String shopName) { @@ -301,18 +305,27 @@ public Inventory getGui(Player player, String shopName) } // 플래그 버튼들 - CreateFlagButton(FLAG1, confSec_Options.contains("flag.signshop"), "signShop", t(player, "SHOP_SETTING.SIGN_SHOP_LORE")); - CreateFlagButton(FLAG2, confSec_Options.contains("flag.localshop"), "localShop", t(player, "SHOP_SETTING.LOCAL_SHOP_LORE")); - CreateFlagButton(FLAG3, confSec_Options.contains("flag.deliverycharge"), "deliveryCharge", t(player, "SHOP_SETTING.DELIVERY_CHARGE_LORE")); - CreateFlagButton(FLAG4, confSec_Options.contains("flag.jobpoint"), "jobPoint", t(player, "SHOP_SETTING.JOB_POINT_LORE")); - CreateFlagButton(FLAG5, confSec_Options.contains("flag.showvaluechange"), "showValueChange", t(player, "SHOP_SETTING.SHOW_VALUE_CHANGE_LORE")); - CreateFlagButton(FLAG6, confSec_Options.contains("flag.hidestock"), "hideStock", t(player, "SHOP_SETTING.HIDE_STOCK")); - CreateFlagButton(FLAG7, confSec_Options.contains("flag.hidepricingtype"), "hidePricingType", t(player, "SHOP_SETTING.HIDE_PRICING_TYPE")); - CreateFlagButton(FLAG8, confSec_Options.contains("flag.hideshopbalance"), "hideShopBalance", t(player, "SHOP_SETTING.HIDE_SHOP_BALANCE")); - CreateFlagButton(FLAG9, confSec_Options.contains("flag.showmaxstock"), "showMaxStock", t(player, "SHOP_SETTING.SHOW_MAX_STOCK")); - CreateFlagButton(FLAG10, confSec_Options.contains("flag.hiddenincommand"), "hiddenInCommand", t(player, "SHOP_SETTING.HIDDEN_IN_COMMAND")); - CreateFlagButton(FLAG11, confSec_Options.contains("flag.integeronly"), "integerOnly", t(player, "SHOP_SETTING.INTEGER_ONLY")); - CreateFlagButton(FLAG12, confSec_Options.contains("flag.playerpoint"), "playerPoint", t(player, "SHOP_SETTING.PLAYER_POINT_LORE")); + CreateFlagButton(FLAG_SIGNSHOP, confSec_Options.contains("flag.signshop"), "signShop", t(player, "SHOP_SETTING.SIGN_SHOP_LORE")); + CreateFlagButton(FLAG_LOCALSHOP, confSec_Options.contains("flag.localshop"), "localShop", t(player, "SHOP_SETTING.LOCAL_SHOP_LORE")); + CreateFlagButton(FLAG_DELIVERY, confSec_Options.contains("flag.deliverycharge"), "deliveryCharge", t(player, "SHOP_SETTING.DELIVERY_CHARGE_LORE")); + CreateFlagButton(FLAG_SHOW_VALUE_CHANGE, confSec_Options.contains("flag.showvaluechange"), "showValueChange", t(player, "SHOP_SETTING.SHOW_VALUE_CHANGE_LORE")); + CreateFlagButton(FLAG_HIDE_STOCK, confSec_Options.contains("flag.hidestock"), "hideStock", t(player, "SHOP_SETTING.HIDE_STOCK")); + CreateFlagButton(FLAG_HIDE_PRICING_TYPE, confSec_Options.contains("flag.hidepricingtype"), "hidePricingType", t(player, "SHOP_SETTING.HIDE_PRICING_TYPE")); + CreateFlagButton(FLAG_HIDE_SHOP_BALANCE, confSec_Options.contains("flag.hideshopbalance"), "hideShopBalance", t(player, "SHOP_SETTING.HIDE_SHOP_BALANCE")); + CreateFlagButton(FLAG_SHOW_MAX_STOCK, confSec_Options.contains("flag.showmaxstock"), "showMaxStock", t(player, "SHOP_SETTING.SHOW_MAX_STOCK")); + CreateFlagButton(FLAG_HIDDEN_IN_COMMAND, confSec_Options.contains("flag.hiddenincommand"), "hiddenInCommand", t(player, "SHOP_SETTING.HIDDEN_IN_COMMAND")); + CreateFlagButton(FLAG_INT_ONLY, confSec_Options.contains("flag.integeronly"), "integerOnly", t(player, "SHOP_SETTING.INTEGER_ONLY")); + + currency = confSec_Options.getString("currency", ""); + if (!currency.equalsIgnoreCase("JobPoint") && + !currency.equalsIgnoreCase("PlayerPoint") && + !currency.equalsIgnoreCase("Exp")) + currency = "Vault"; + + CreateCurrencyButton(CURRENCY_VAULT, currency.equalsIgnoreCase("Vault"), t(player, "SHOP_SETTING.CURRENCY") + "Vault", t(player, "SHOP_SETTING.VAULT_LORE")); + CreateCurrencyButton(CURRENCY_EXP, currency.equalsIgnoreCase("Exp"), t(player, "SHOP_SETTING.CURRENCY") + "Exp", t(player, "SHOP_SETTING.EXP_LORE")); + CreateCurrencyButton(CURRENCY_JP, currency.equalsIgnoreCase("JobPoint"), t(player, "SHOP_SETTING.CURRENCY") + "JobPoint", t(player, "SHOP_SETTING.JOB_POINT_LORE")); + CreateCurrencyButton(CURRENCY_PP, currency.equalsIgnoreCase("PlayerPoint"), t(player, "SHOP_SETTING.CURRENCY") + "PlayerPoint", t(player, "SHOP_SETTING.PLAYER_POINT_LORE")); // 로그 버튼 String log_cur; @@ -621,7 +634,7 @@ else if (data.get().contains("Options.SalesTax")) data.save(); } // signshop - else if (e.getSlot() == FLAG1) + else if (e.getSlot() == FLAG_SIGNSHOP) { if (data.get().contains("Options.flag.signshop")) { @@ -633,7 +646,7 @@ else if (e.getSlot() == FLAG1) DynaShopAPI.openShopSettingGui(player, shopName); } // localshop - else if (e.getSlot() == FLAG2) + else if (e.getSlot() == FLAG_LOCALSHOP) { if (data.get().contains("Options.flag.localshop")) { @@ -645,7 +658,7 @@ else if (e.getSlot() == FLAG2) DynaShopAPI.openShopSettingGui(player, shopName); } // deliverycharge - else if (e.getSlot() == FLAG3) + else if (e.getSlot() == FLAG_DELIVERY) { if (data.get().contains("Options.flag.deliverycharge")) { @@ -656,31 +669,8 @@ else if (e.getSlot() == FLAG3) } DynaShopAPI.openShopSettingGui(player, shopName); } - // jobpoint - else if (e.getSlot() == FLAG4) - { - if (data.get().contains("Options.flag.jobpoint")) - { - Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag jobPoint unset"); - } else - { - if (!JobsHook.jobsRebornActive) - { - player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "ERR.JOBS_REBORN_NOT_FOUND")); - return; - } - - if (data.get().contains("Options.flag.playerpoint")) - { - Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag playerpoint unset"); - } - - Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag jobPoint set"); - } - DynaShopAPI.openShopSettingGui(player, shopName); - } // showValueChange - else if (e.getSlot() == FLAG5) + else if (e.getSlot() == FLAG_SHOW_VALUE_CHANGE) { if (data.get().contains("Options.flag.showvaluechange")) { @@ -692,7 +682,7 @@ else if (e.getSlot() == FLAG5) DynaShopAPI.openShopSettingGui(player, shopName); } // HIDE_STOCK - else if (e.getSlot() == FLAG6) + else if (e.getSlot() == FLAG_HIDE_STOCK) { if (data.get().contains("Options.flag.hidestock")) { @@ -704,7 +694,7 @@ else if (e.getSlot() == FLAG6) DynaShopAPI.openShopSettingGui(player, shopName); } // HIDE_PRICING_TYPE - else if (e.getSlot() == FLAG7) + else if (e.getSlot() == FLAG_HIDE_PRICING_TYPE) { if (data.get().contains("Options.flag.hidepricingtype")) { @@ -716,7 +706,7 @@ else if (e.getSlot() == FLAG7) DynaShopAPI.openShopSettingGui(player, shopName); } // HIDE_SHOP_BALANCE - else if (e.getSlot() == FLAG8) + else if (e.getSlot() == FLAG_HIDE_SHOP_BALANCE) { if (data.get().contains("Options.flag.hideshopbalance")) { @@ -728,7 +718,7 @@ else if (e.getSlot() == FLAG8) DynaShopAPI.openShopSettingGui(player, shopName); } // SHOW_MAX_STOCK - else if (e.getSlot() == FLAG9) + else if (e.getSlot() == FLAG_SHOW_MAX_STOCK) { if (data.get().contains("Options.flag.showmaxstock")) { @@ -740,7 +730,7 @@ else if (e.getSlot() == FLAG9) DynaShopAPI.openShopSettingGui(player, shopName); } // HIDDEN_IN_COMMAND - else if (e.getSlot() == FLAG10) + else if (e.getSlot() == FLAG_HIDDEN_IN_COMMAND) { if (data.get().contains("Options.flag.hiddenincommand")) { @@ -751,44 +741,6 @@ else if (e.getSlot() == FLAG10) } DynaShopAPI.openShopSettingGui(player, shopName); } - // INTEGER_ONLY - else if (e.getSlot() == FLAG11) - { - if (data.get().contains("Options.flag.integeronly")) - { - Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag integerOnly unset"); - if(data.get().contains("Options.flag.playerpoint")) - Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag playerpoint unset"); - } else - { - Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag integerOnly set"); - } - DynaShopAPI.openShopSettingGui(player, shopName); - } - // Player point - else if (e.getSlot() == FLAG12) - { - if (data.get().contains("Options.flag.playerpoint")) - { - Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag playerpoint unset"); - } else - { - if (!PlayerpointHook.isPPActive) - { - player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "ERR.PLAYER_POINTS_NOT_FOUND")); - return; - } - - if (data.get().contains("Options.flag.jobpoint")) - { - Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag jobpoint unset"); - } - - Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag integerOnly set"); - Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag playerpoint set"); - } - DynaShopAPI.openShopSettingGui(player, shopName); - } // log else if (e.getSlot() == LOG_TOGGLE) { @@ -876,6 +828,72 @@ else if(e.isLeftClick()) OnChat.WaitForInput(player); } } + // INTEGER_ONLY + else if (e.getSlot() == FLAG_INT_ONLY) + { + if (data.get().contains("Options.flag.integeronly")) + { + Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag integerOnly unset"); + + if(data.get().getString("Options.currency","").equalsIgnoreCase("playerpoint") || + data.get().getString("Options.currency","").equalsIgnoreCase("exp")) + Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " currency vault"); + } else + { + Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag integerOnly set"); + } + DynaShopAPI.openShopSettingGui(player, shopName); + } + // vault + else if (e.getSlot() == CURRENCY_VAULT) + { + if (!currency.equalsIgnoreCase("vault")) + { + Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " currency vault"); + } + DynaShopAPI.openShopSettingGui(player, shopName); + } + // exp + else if (e.getSlot() == CURRENCY_EXP) + { + if (!currency.equalsIgnoreCase("exp")) + { + Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " currency exp"); + Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag integerOnly set"); + } + DynaShopAPI.openShopSettingGui(player, shopName); + } + // jobpoint + else if (e.getSlot() == CURRENCY_JP) + { + if (!JobsHook.jobsRebornActive) + { + player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "ERR.JOBS_REBORN_NOT_FOUND")); + return; + } + + if (!currency.equalsIgnoreCase("jobpoint")) + { + Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " currency jobpoint"); + } + DynaShopAPI.openShopSettingGui(player, shopName); + } + // Player point + else if (e.getSlot() == CURRENCY_PP) + { + if (!PlayerpointHook.isPPActive) + { + player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "ERR.PLAYER_POINTS_NOT_FOUND")); + return; + } + + if (!currency.equalsIgnoreCase("playerpoint")) + { + Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " currency playerpoint"); + Bukkit.dispatchCommand(player, "DynamicShop shop " + shopName + " flag integerOnly set"); + } + DynaShopAPI.openShopSettingGui(player, shopName); + } } private void CreateFlagButton(int buttonPosition, boolean isEnable, String title, String lore) @@ -909,4 +927,31 @@ private void CreateFlagButton(int buttonPosition, boolean isEnable, String title loreArray.add("§e" + t(null, "CLICK") + ": " + set); CreateButton(buttonPosition, icon, t(null, "SHOP_SETTING.FLAG") + ": " + title, loreArray); } + + private void CreateCurrencyButton(int buttonPosition, boolean isEnable, String title, String lore) + { + ArrayList loreArray = new ArrayList<>(); + if(lore.contains("\n")) + { + String[] temp = lore.split("\n"); + Collections.addAll(loreArray, temp); + } + else + { + loreArray.add(lore); + } + + Material icon; + if (isEnable) + { + icon = Material.YELLOW_STAINED_GLASS_PANE; + loreArray.add(t(null, "SHOP_SETTING.SELECTED")); + + } else + { + icon = Material.WHITE_STAINED_GLASS_PANE; + } + loreArray.add("§e" + t(null, "CLICK") + ": " + t(null, "SET")); + CreateButton(buttonPosition, icon, title, loreArray); + } } diff --git a/src/main/java/me/sat7/dynamicshop/transactions/Buy.java b/src/main/java/me/sat7/dynamicshop/transactions/Buy.java index 8440279..a9309c9 100644 --- a/src/main/java/me/sat7/dynamicshop/transactions/Buy.java +++ b/src/main/java/me/sat7/dynamicshop/transactions/Buy.java @@ -48,6 +48,10 @@ public static void buy(ItemTrade.CURRENCY currency, Player player, String shopNa { playerBalance = econ.getBalance(player); } + else if (currency == ItemTrade.CURRENCY.EXP) + { + playerBalance = player.getTotalExperience(); + } else if (currency == ItemTrade.CURRENCY.JOB_POINT) { playerBalance = JobsHook.getCurJobPoints(player); @@ -107,6 +111,10 @@ else if (currency == ItemTrade.CURRENCY.PLAYER_POINT) { message = DynamicShop.dsPrefix(player) + t(player, "MESSAGE.NOT_ENOUGH_PLAYER_POINT").replace("{bal}", n(playerBalance)); } + else if (currency == ItemTrade.CURRENCY.EXP) + { + message = DynamicShop.dsPrefix(player) + t(player, "MESSAGE.NOT_ENOUGH_EXP_POINT").replace("{bal}", n(playerBalance)); + } player.sendMessage(message); data.get().set(tradeIdx + ".stock", stockOld); @@ -146,6 +154,10 @@ else if (currency == ItemTrade.CURRENCY.PLAYER_POINT) if (!PlayerpointHook.addPP(player, priceSum * -1)) return; } + else if (currency == ItemTrade.CURRENCY.EXP) + { + player.giveExp((int)(priceSum * -1)); + } int leftAmount = tradeAmount; int maxStackSize = itemStack.getType().getMaxStackSize(); @@ -215,6 +227,13 @@ private static void SendBuyMessage(ItemTrade.CURRENCY currency, Economy econ, Pl .replace("{price}", n(priceSum)) .replace("{bal}", n(econ.getBalance(player))); } + else if (currency == ItemTrade.CURRENCY.EXP) + { + message = DynamicShop.dsPrefix(player) + t(player, "MESSAGE.BUY_SUCCESS_EXP", !useLocalizedName) + .replace("{amount}", Integer.toString(actualAmount)) + .replace("{price}", n(priceSum, true)) + .replace("{bal}", n(player.getTotalExperience())); + } else if (currency == ItemTrade.CURRENCY.JOB_POINT) { message = DynamicShop.dsPrefix(player) + t(player, "MESSAGE.BUY_SUCCESS_JP", !useLocalizedName) @@ -226,7 +245,7 @@ else if (currency == ItemTrade.CURRENCY.PLAYER_POINT) { message = DynamicShop.dsPrefix(player) + t(player, "MESSAGE.BUY_SUCCESS_PP", !useLocalizedName) .replace("{amount}", Integer.toString(actualAmount)) - .replace("{price}", n(priceSum)) + .replace("{price}", n(priceSum, true)) .replace("{bal}", n(PlayerpointHook.getCurrentPP(player))); } diff --git a/src/main/java/me/sat7/dynamicshop/transactions/Sell.java b/src/main/java/me/sat7/dynamicshop/transactions/Sell.java index 1c907eb..357575c 100644 --- a/src/main/java/me/sat7/dynamicshop/transactions/Sell.java +++ b/src/main/java/me/sat7/dynamicshop/transactions/Sell.java @@ -33,14 +33,18 @@ public static double quickSellItem(Player player, ItemStack itemStack, String sh CustomConfig data = ShopUtil.shopConfigFiles.get(shopName); ItemTrade.CURRENCY currencyType; - if (data.get().contains("Options.flag.jobpoint")) + if (data.get().getString("Options.currency","").equalsIgnoreCase("jobpoint")) { currencyType = ItemTrade.CURRENCY.JOB_POINT; } - else if (data.get().contains("Options.flag.playerpoint")) + else if (data.get().getString("Options.currency","").equalsIgnoreCase("playerpoint")) { currencyType = ItemTrade.CURRENCY.PLAYER_POINT; } + else if (data.get().getString("Options.currency","").equalsIgnoreCase("exp")) + { + currencyType = ItemTrade.CURRENCY.EXP; + } else { currencyType = ItemTrade.CURRENCY.VAULT; @@ -332,6 +336,11 @@ else if (currencyType == ItemTrade.CURRENCY.PLAYER_POINT) { return PlayerpointHook.addPP(player, priceSum); } + else if (currencyType == ItemTrade.CURRENCY.EXP) + { + player.giveExp((int)priceSum); + return true; + } return false; } @@ -359,9 +368,16 @@ else if (currency == ItemTrade.CURRENCY.PLAYER_POINT) { message = DynamicShop.dsPrefix(player) + t(player, "MESSAGE.SELL_SUCCESS_PP", !useLocalizedName) .replace("{amount}", Integer.toString(actualAmount)) - .replace("{price}", n(priceSum)) + .replace("{price}", n(priceSum, true)) .replace("{bal}", n(PlayerpointHook.getCurrentPP(player))); } + else if (currency == ItemTrade.CURRENCY.EXP) + { + message = DynamicShop.dsPrefix(player) + t(player, "MESSAGE.SELL_SUCCESS_EXP", !useLocalizedName) + .replace("{amount}", Integer.toString(actualAmount)) + .replace("{price}", n(priceSum, true)) + .replace("{bal}", n(player.getTotalExperience())); + } if (useLocalizedName) { diff --git a/src/main/java/me/sat7/dynamicshop/utilities/ConfigUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/ConfigUtil.java index 4348ea4..f047bf9 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 = 5; + public final static int PluginConfigVersion = 6; 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 0c26406..a862f59 100644 --- a/src/main/java/me/sat7/dynamicshop/utilities/LangUtil.java +++ b/src/main/java/me/sat7/dynamicshop/utilities/LangUtil.java @@ -64,6 +64,10 @@ public static void setupLangFile(String lang) ccLang.get().addDefault("SHOP.SELL_PRICE_DISCOUNTED", "§f판매: §8§m{num}§r §c{num2}"); ccLang.get().addDefault("SHOP.BUY_PRICE_PP", "§f구매: {num}PP"); ccLang.get().addDefault("SHOP.SELL_PRICE_PP", "§f판매: {num}PP"); + ccLang.get().addDefault("SHOP.BUY_PRICE_EXP", "§f구매: {num}Exp"); + ccLang.get().addDefault("SHOP.SELL_PRICE_EXP", "§f판매: {num}Exp"); + ccLang.get().addDefault("SHOP.BUY_PRICE_DISCOUNTED_EXP", "§f구매: §8§m{num}Exp§r §a{num2}Exp"); + ccLang.get().addDefault("SHOP.SELL_PRICE_DISCOUNTED_EXP", "§f판매: §8§m{num}Exp§r §c{num2}Exp"); ccLang.get().addDefault("SHOP.BUY_PRICE_DISCOUNTED_PP", "§f구매: §8§m{num}PP§r §a{num2}PP"); ccLang.get().addDefault("SHOP.SELL_PRICE_DISCOUNTED_PP", "§f판매: §8§m{num}PP§r §c{num2}PP"); ccLang.get().addDefault("SHOP.BUY_PRICE_JP", "§f구매: {num}JP"); @@ -111,6 +115,10 @@ public static void setupLangFile(String lang) ccLang.get().addDefault("SHOP_SETTING.SIGN_SHOP_LORE", "§f표지판을 통해서만 접근할 수 있습니다."); ccLang.get().addDefault("SHOP_SETTING.LOCAL_SHOP_LORE", "§f실제 상점 위치를 방문해야 합니다.\n§f상점의 위치를 설정해야만 합니다."); ccLang.get().addDefault("SHOP_SETTING.DELIVERY_CHARGE_LORE", "§f배달비를 지불하고 localshop에서 원격으로 거래합니다."); + ccLang.get().addDefault("SHOP_SETTING.SELECTED", "§2선택됨"); + ccLang.get().addDefault("SHOP_SETTING.CURRENCY", "§f화폐 유형: "); + ccLang.get().addDefault("SHOP_SETTING.VAULT_LORE", "§f기본값 입니다."); + ccLang.get().addDefault("SHOP_SETTING.EXP_LORE", "§f플레이어의 경험치로 거래합니다."); ccLang.get().addDefault("SHOP_SETTING.JOB_POINT_LORE", "§fJobs 플러그인의 job point로 거래합니다."); ccLang.get().addDefault("SHOP_SETTING.PLAYER_POINT_LORE", "§fPlayerPoint 플러그인의 point로 거래합니다."); ccLang.get().addDefault("SHOP_SETTING.SHOW_VALUE_CHANGE_LORE", "§f가격 변화량을 표시합니다."); @@ -208,6 +216,10 @@ public static void setupLangFile(String lang) ccLang.get().addDefault("TRADE.SELL_PRICE", "§f판매: {num}"); ccLang.get().addDefault("TRADE.PRICE_DISCOUNTED", "§f구매: §8§m{num}§r §a{num2}"); ccLang.get().addDefault("TRADE.SELL_PRICE_DISCOUNTED", "§f판매: §8§m{num}§r §c{num2}"); + ccLang.get().addDefault("TRADE.PRICE_EXP", "§f구매: {num}EXP"); + ccLang.get().addDefault("TRADE.SELL_PRICE_EXP", "§f판매: {num}EXP"); + ccLang.get().addDefault("TRADE.PRICE_DISCOUNTED_EXP", "§f구매: §8§m{num}EXP§r §a{num2}EXP"); + ccLang.get().addDefault("TRADE.SELL_PRICE_DISCOUNTED_EXP", "§f판매: §8§m{num}EXP§r §c{num2}EXP"); ccLang.get().addDefault("TRADE.PRICE_PP", "§f구매: {num}PP"); ccLang.get().addDefault("TRADE.SELL_PRICE_PP", "§f판매: {num}PP"); ccLang.get().addDefault("TRADE.PRICE_DISCOUNTED_PP", "§f구매: §8§m{num}PP§r §a{num2}PP"); @@ -334,6 +346,8 @@ public static void setupLangFile(String lang) ccLang.get().addDefault("MESSAGE.OUT_OF_STOCK", "§f재고 없음!"); ccLang.get().addDefault("MESSAGE.BUY_SUCCESS", "§f{item} {amount}개를 {price}에 구매함. 잔액: {bal}"); ccLang.get().addDefault("MESSAGE.SELL_SUCCESS", "§f{item} {amount}개를 {price}에 판매함. 잔액: {bal}"); + ccLang.get().addDefault("MESSAGE.BUY_SUCCESS_EXP", "§f{item} {amount}개를 {price}경험치 포인트에 구매함. 잔액: {bal}"); + ccLang.get().addDefault("MESSAGE.SELL_SUCCESS_EXP", "§f{item} {amount}개를 {price}경험치 포인트에 판매함. 잔액: {bal}"); ccLang.get().addDefault("MESSAGE.BUY_SUCCESS_JP", "§f{item} {amount}개를 {price}포인트에 구매함. 남은포인트: {bal}"); ccLang.get().addDefault("MESSAGE.SELL_SUCCESS_JP", "§f{item} {amount}개를 {price}포인트에 판매함. 남은포인트: {bal}"); ccLang.get().addDefault("MESSAGE.BUY_SUCCESS_PP", "§f{item} {amount}개를 {price}포인트에 구매함. 남은포인트: {bal}"); @@ -344,6 +358,7 @@ public static void setupLangFile(String lang) ccLang.get().addDefault("MESSAGE.NOT_ENOUGH_MONEY", "§f돈이 부족합니다. 잔액: {bal}"); ccLang.get().addDefault("MESSAGE.NOT_ENOUGH_POINT", "§f포인트가 부족합니다. 잔액: {bal}"); ccLang.get().addDefault("MESSAGE.NOT_ENOUGH_PLAYER_POINT", "§f플레이어 포인트가 부족합니다. 잔액: {bal}"); + ccLang.get().addDefault("MESSAGE.NOT_ENOUGH_EXP_POINT", "§f경험치 포인트가 부족합니다. 잔액: {bal}"); ccLang.get().addDefault("MESSAGE.NO_ITEM_TO_SELL", "§f판매 할 아이템이 없습니다."); ccLang.get().addDefault("MESSAGE.NO_ITEM_TO_SELL_2", "§f판매 가능 한 아이템이 없습니다."); ccLang.get().addDefault("MESSAGE.INVENTORY_FULL", "§4인벤토리에 빈 공간이 없습니다!"); @@ -445,6 +460,7 @@ public static void setupLangFile(String lang) ccLang.get().addDefault("CLOSE", "§f닫기"); ccLang.get().addDefault("CLOSE_LORE", "§f§n클릭: 닫기"); + ccLang.get().addDefault("EXP_POINTS", "Exp"); ccLang.get().addDefault("JOB_POINTS", "Job Points"); ccLang.get().addDefault("PLAYER_POINTS", "Player Points"); @@ -490,6 +506,10 @@ public static void setupLangFile(String lang) ccLang.get().addDefault("SHOP.SELL_PRICE", "§fSell: {num}"); ccLang.get().addDefault("SHOP.BUY_PRICE_DISCOUNTED", "§fBuy: §8§m{num}§r §a{num2}"); ccLang.get().addDefault("SHOP.SELL_PRICE_DISCOUNTED", "§fSell: §8§m{num}§r §c{num2}"); + ccLang.get().addDefault("SHOP.BUY_PRICE_EXP", "§fBuy: {num}Exp"); + ccLang.get().addDefault("SHOP.SELL_PRICE_EXP", "§fSell: {num}Exp"); + ccLang.get().addDefault("SHOP.BUY_PRICE_DISCOUNTED_EXP", "§fBuy: §8§m{num}Exp§r §a{num2}Exp"); + ccLang.get().addDefault("SHOP.SELL_PRICE_DISCOUNTED_EXP", "§fSell: §8§m{num}Exp§r §c{num2}Exp"); ccLang.get().addDefault("SHOP.BUY_PRICE_PP", "§fBuy: {num}PP"); ccLang.get().addDefault("SHOP.SELL_PRICE_PP", "§fSell: {num}PP"); ccLang.get().addDefault("SHOP.BUY_PRICE_DISCOUNTED_PP", "§fBuy: §8§m{num}PP§r §a{num2}PP"); @@ -539,6 +559,10 @@ public static void setupLangFile(String lang) ccLang.get().addDefault("SHOP_SETTING.SIGN_SHOP_LORE", "§fOnly accessible via sign."); ccLang.get().addDefault("SHOP_SETTING.LOCAL_SHOP_LORE", "§fMust visit actual store locations."); ccLang.get().addDefault("SHOP_SETTING.DELIVERY_CHARGE_LORE", "§fYou can pay for delivery without \n§fhaving to go to the shop location to transact."); + ccLang.get().addDefault("SHOP_SETTING.SELECTED", "§2Selected"); + ccLang.get().addDefault("SHOP_SETTING.CURRENCY", "§fCurrency Type: "); + ccLang.get().addDefault("SHOP_SETTING.VAULT_LORE", "§fThis is the default."); + ccLang.get().addDefault("SHOP_SETTING.EXP_LORE", "§fTrade with the player's experience points."); ccLang.get().addDefault("SHOP_SETTING.JOB_POINT_LORE", "§fTrade with job points. \n§fRequires 'Jobs Reborn' plugin"); ccLang.get().addDefault("SHOP_SETTING.PLAYER_POINT_LORE", "§fTrade with player points. \n§fRequires 'Player point' plugin"); ccLang.get().addDefault("SHOP_SETTING.SHOW_VALUE_CHANGE_LORE", "§fShows the amount of change in price."); @@ -636,6 +660,10 @@ public static void setupLangFile(String lang) ccLang.get().addDefault("TRADE.SELL_PRICE", "§fSell: {num}"); ccLang.get().addDefault("TRADE.PRICE_DISCOUNTED", "§fBuy: §8§m{num}§r §a{num2}"); ccLang.get().addDefault("TRADE.SELL_PRICE_DISCOUNTED", "§fSell: §8§m{num}§r §c{num2}"); + ccLang.get().addDefault("TRADE.PRICE_EXP", "§fBuy: {num}EXP"); + ccLang.get().addDefault("TRADE.SELL_PRICE_EXP", "§fSell: {num}EXP"); + ccLang.get().addDefault("TRADE.PRICE_DISCOUNTED_EXP", "§fBuy: §8§m{num}EXP§r §a{num2}EXP"); + ccLang.get().addDefault("TRADE.SELL_PRICE_DISCOUNTED_EXP", "§fSell: §8§m{num}EXP§r §c{num2}EXP"); ccLang.get().addDefault("TRADE.PRICE_PP", "§fBuy: {num}PP"); ccLang.get().addDefault("TRADE.SELL_PRICE_PP", "§fSell: {num}PP"); ccLang.get().addDefault("TRADE.PRICE_DISCOUNTED_PP", "§fBuy: §8§m{num}PP§r §a{num2}PP"); @@ -761,6 +789,8 @@ public static void setupLangFile(String lang) ccLang.get().addDefault("MESSAGE.OUT_OF_STOCK", "§fOut of stock!"); ccLang.get().addDefault("MESSAGE.BUY_SUCCESS", "§fBought {item} x{amount} for {price}. Balance: {bal}"); ccLang.get().addDefault("MESSAGE.SELL_SUCCESS", "§fSold {item} x{amount} for {price}. Balance: {bal}"); + ccLang.get().addDefault("MESSAGE.BUY_SUCCESS_EXP", "§fBought {item} x{amount} for {price}Exp Points. Balance: {bal}"); + ccLang.get().addDefault("MESSAGE.SELL_SUCCESS_EXP", "§fSold {item} x{amount} for {price}Exp Points. Balance: {bal}"); ccLang.get().addDefault("MESSAGE.BUY_SUCCESS_JP", "§fBought {item} x{amount} for {price}points. Remaining points: {bal}"); ccLang.get().addDefault("MESSAGE.SELL_SUCCESS_JP", "§fSold {item} x{amount} for {price}points. Remaining points: {bal}"); ccLang.get().addDefault("MESSAGE.BUY_SUCCESS_PP", "§fBought {item} x{amount} for {price}points. Remaining points: {bal}"); @@ -771,6 +801,7 @@ public static void setupLangFile(String lang) ccLang.get().addDefault("MESSAGE.NOT_ENOUGH_MONEY", "§fNot enough money. balance: {bal}"); ccLang.get().addDefault("MESSAGE.NOT_ENOUGH_POINT", "§fNot enough points. balance: {bal}"); ccLang.get().addDefault("MESSAGE.NOT_ENOUGH_PLAYER_POINT", "§fNot enough player points. balance: {bal}"); + ccLang.get().addDefault("MESSAGE.NOT_ENOUGH_EXP_POINT", "§fNot enough Exp points. balance: {bal}"); ccLang.get().addDefault("MESSAGE.NO_ITEM_TO_SELL", "§fThere are no items for sale."); ccLang.get().addDefault("MESSAGE.NO_ITEM_TO_SELL_2", "§fThere are no items available for sale."); ccLang.get().addDefault("MESSAGE.INVENTORY_FULL", "§4There are no empty spaces in your inventory!"); @@ -872,6 +903,7 @@ public static void setupLangFile(String lang) ccLang.get().addDefault("CLOSE", "§fClose"); ccLang.get().addDefault("CLOSE_LORE", "§f§nClick: Close"); + ccLang.get().addDefault("EXP_POINTS", "Exp Points"); ccLang.get().addDefault("JOB_POINTS", "Job Points"); ccLang.get().addDefault("PLAYER_POINTS", "Player Points"); @@ -1052,4 +1084,12 @@ public static String n(double i) { return doubleFormat.format(i); } + + public static String n(double i, boolean toInt) + { + if (toInt) + return intFormat.format((int)i); + else + return doubleFormat.format(i); + } } diff --git a/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java index eb5f08c..2d290d1 100644 --- a/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java +++ b/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java @@ -165,6 +165,24 @@ else if (old > 0) } } } + + if (userVersion < 6) + { + for(Map.Entry entry : shopConfigFiles.entrySet()) + { + FileConfiguration fc = entry.getValue().get(); + if (fc.contains("Options.flag.jobpoint")) + { + fc.set("Options.flag.jobpoint", null); + fc.set("Options.currency", "jobpoint"); + } + if (fc.contains("Options.flag.playerpoint")) + { + fc.set("Options.flag.playerpoint", null); + fc.set("Options.currency", "playerpoint"); + } + } + } } // 상점에서 빈 슬롯 찾기 @@ -881,14 +899,18 @@ public static String[] FindTheBestShopToSell(Player player, ItemStack itemStack) // 여러 재화로 취급중인 경우 지원 안함. int tempCurrencyIndex = 0; - if (data.get().contains("Options.flag.jobpoint")) + if (data.get().getString("Options.currency","").equalsIgnoreCase("jobpoint")) { tempCurrencyIndex = 1; } - else if (data.get().contains("Options.flag.playerpoint")) + else if (data.get().getString("Options.currency","").equalsIgnoreCase("playerpoint")) { tempCurrencyIndex = 2; } + else if (data.get().getString("Options.currency","").equalsIgnoreCase("exp")) + { + tempCurrencyIndex = 3; + } if (currencyInt == -1) { @@ -998,14 +1020,18 @@ public static String[] FindTheBestShopToBuy(Player player, ItemStack itemStack) // 여러 재화로 취급중인 경우 지원 안함. int tempCurrencyIndex = 0; - if (data.get().contains("Options.flag.jobpoint")) + if (data.get().getString("Options.currency","").equalsIgnoreCase("jobpoint")) { tempCurrencyIndex = 1; } - else if (data.get().contains("Options.flag.playerpoint")) + else if (data.get().getString("Options.currency","").equalsIgnoreCase("playerpoint")) { tempCurrencyIndex = 2; } + else if (data.get().getString("Options.currency","").equalsIgnoreCase("exp")) + { + tempCurrencyIndex = 3; + } if (currencyInt == -1) { diff --git a/src/main/java/me/sat7/dynamicshop/utilities/StringUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/StringUtil.java index ad35713..5812d8d 100644 --- a/src/main/java/me/sat7/dynamicshop/utilities/StringUtil.java +++ b/src/main/java/me/sat7/dynamicshop/utilities/StringUtil.java @@ -157,6 +157,10 @@ else if (currency == ItemTrade.CURRENCY.PLAYER_POINT) { return "playerPoint"; } + else if (currency == ItemTrade.CURRENCY.EXP) + { + return "exp"; + } return "vault"; } diff --git a/src/main/java/me/sat7/dynamicshop/utilities/TabCompleteUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/TabCompleteUtil.java index 9f5b6ef..70e7723 100644 --- a/src/main/java/me/sat7/dynamicshop/utilities/TabCompleteUtil.java +++ b/src/main/java/me/sat7/dynamicshop/utilities/TabCompleteUtil.java @@ -140,6 +140,7 @@ else if (cmd.getName().equalsIgnoreCase("shop") && args.length == 1) temp.add("setToRecAll"); temp.add("permission"); temp.add("maxpage"); + temp.add("currency"); temp.add("flag"); temp.add("position"); temp.add("shophours"); @@ -283,6 +284,18 @@ else if (cmd.getName().equalsIgnoreCase("shop") && args.length == 1) } else if (args[2].equalsIgnoreCase("maxpage") && sender.hasPermission(P_ADMIN_SHOP_EDIT)) { Help.showHelp("max_page", (Player) sender, args); + } else if (args[2].equalsIgnoreCase("currency") && sender.hasPermission(P_ADMIN_SHOP_EDIT)) + { + if (args.length == 4) + { + temp.add("vault"); + temp.add("exp"); + temp.add("jobpoint"); + temp.add("playerpoint"); + AddToAutoCompleteIfValid(args[3]); + } + + Help.showHelp("currency", (Player) sender, args); } else if (args[2].equalsIgnoreCase("flag") && sender.hasPermission(P_ADMIN_SHOP_EDIT)) { if (args.length == 4) @@ -290,8 +303,6 @@ else if (cmd.getName().equalsIgnoreCase("shop") && args.length == 1) temp.add("signShop"); temp.add("localShop"); temp.add("deliveryCharge"); - temp.add("jobPoint"); - temp.add("playerPoint"); temp.add("showValueChange"); temp.add("hideStock"); temp.add("hidePricingType"); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index fe013d6..7dd5050 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -13,7 +13,7 @@ commands: shop: description: "Open shop menu" sell: - description: "Sell items" + description: "Sell items" permissions: dshop.use: description: Allows use of the /ds command