From 5b0be0e8cda78f5d0c102dc082726c8a2b89304f Mon Sep 17 00:00:00 2001 From: Tining123 <13301145@bjtu.edu.cn> Date: Sat, 27 Aug 2022 11:15:42 +0800 Subject: [PATCH] supporting Arclight Server --- pom.xml | 2 +- .../com/tining/demonmarket/command/UserCommand.java | 6 ++++-- .../com/tining/demonmarket/economy/MarketEconomy.java | 10 +++++----- .../com/tining/demonmarket/gui/AcquireListGui.java | 2 +- src/main/java/com/tining/demonmarket/gui/ChestGui.java | 4 ++-- src/main/resources/plugin.yml | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 96b2791..caa339f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.Tining DemonMarket - 1.3.9 + 1.4.0 diff --git a/src/main/java/com/tining/demonmarket/command/UserCommand.java b/src/main/java/com/tining/demonmarket/command/UserCommand.java index 224ba42..25c0e70 100644 --- a/src/main/java/com/tining/demonmarket/command/UserCommand.java +++ b/src/main/java/com/tining/demonmarket/command/UserCommand.java @@ -174,10 +174,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St // 给收款人发消息 try{ Player onlineReceiver = Bukkit.getPlayer(args[1]); - onlineReceiver.sendMessage(ChatColor.YELLOW + String.format(LangUtil.get("收款成功,从%s收到%s"), player.getName(), totalPrice)); + onlineReceiver.sendMessage(ChatColor.YELLOW + + String.format(LangUtil.get("收款成功,从%s收到%s"), player.getName(), MarketEconomy.formatMoney(totalPrice))); }catch (Exception ignore){} - player.sendMessage(ChatColor.YELLOW + String.format(LangUtil.get("转账成功,花费%S,转账%s"), totalValue, totalPrice)); + player.sendMessage(ChatColor.YELLOW + String.format(LangUtil.get("转账成功,花费%S,转账%s"), + totalValue, MarketEconomy.formatMoney(totalPrice))); return true; } diff --git a/src/main/java/com/tining/demonmarket/economy/MarketEconomy.java b/src/main/java/com/tining/demonmarket/economy/MarketEconomy.java index 7f6a121..197aa38 100644 --- a/src/main/java/com/tining/demonmarket/economy/MarketEconomy.java +++ b/src/main/java/com/tining/demonmarket/economy/MarketEconomy.java @@ -20,11 +20,11 @@ public class MarketEconomy { * @param money * @return */ - public static double formatMoney(double money) { + public static String formatMoney(double money) { if (ConfigReader.getRoundSetting().toLowerCase(Locale.ROOT).equals("true")) { - return Double.parseDouble(String.format("%.2f", money)); + return String.format("%.2f", money); } - return money; + return money + ""; } /** @@ -44,7 +44,7 @@ public static double getSellingPrice(double value, int count, double money) { price += onePrice; money += onePrice; } - return formatMoney(price); + return price; } /** @@ -78,7 +78,7 @@ public static boolean isIllegalItem(ItemStack itemStack) { } public static double getTax(double price) { - return formatMoney(price * ConfigReader.getTaxRate()); + return price * ConfigReader.getTaxRate(); } diff --git a/src/main/java/com/tining/demonmarket/gui/AcquireListGui.java b/src/main/java/com/tining/demonmarket/gui/AcquireListGui.java index 6c66b60..6e6b590 100644 --- a/src/main/java/com/tining/demonmarket/gui/AcquireListGui.java +++ b/src/main/java/com/tining/demonmarket/gui/AcquireListGui.java @@ -225,7 +225,7 @@ private static ItemMeta getNBTPriceLore(ItemStack is, Player player) { lore = new ArrayList<>(); } lore.add(ChatColor.YELLOW + LangUtil.get("原价:") + price); - lore.add(ChatColor.YELLOW + LangUtil.get("现价:") + String.format("%.2f", value)); + lore.add(ChatColor.YELLOW + LangUtil.get("现价:") + MarketEconomy.formatMoney(value)); ItemMeta itemMeta = is.getItemMeta(); itemMeta.setLore(lore); diff --git a/src/main/java/com/tining/demonmarket/gui/ChestGui.java b/src/main/java/com/tining/demonmarket/gui/ChestGui.java index 9e21a01..b3ff261 100644 --- a/src/main/java/com/tining/demonmarket/gui/ChestGui.java +++ b/src/main/java/com/tining/demonmarket/gui/ChestGui.java @@ -264,10 +264,10 @@ private static void drawPage(Inventory inventory, Player player) { } //更新paper double count = ChestGui.preCheckOut(inventory,player); - count = MarketEconomy.formatMoney(count); + String countStr = MarketEconomy.formatMoney(count); ItemMeta itemMeta = priceToken.getItemMeta(); itemMeta.setDisplayName(LangUtil.get("合计:")); - itemMeta.setLore(Collections.singletonList(ChatColor.YELLOW + LangUtil.get("总价:$") + count)); + itemMeta.setLore(Collections.singletonList(ChatColor.YELLOW + LangUtil.get("总价:$") + countStr)); priceToken.setItemMeta(itemMeta); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 1d40415..4db9f9a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: DemonMarket main: com.tining.demonmarket.Main -version: 1.3.9 +version: 1.4.0 api-version: 1.13 # YAML 中的注释,一行有效 # 以上是插件基本信息,以下是命令注册