diff --git a/pom.xml b/pom.xml index 1ef29fd..7e65ac7 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.maxgamer QuickShop - 1.6.3.2 + 1.6.4 快捷商店重置版本... ${project.name} @@ -54,7 +54,7 @@ http://ci.citycraft.cn:8080 - &a修改扫描流程 &c修复设置玩家命令错误... + &b补全丢失的词条 &a修改金额格式化方式... UTF-8 diff --git a/src/main/java/org/maxgamer/QuickShop/Economy/Economy.java b/src/main/java/org/maxgamer/QuickShop/Economy/Economy.java index df79d56..abb2826 100644 --- a/src/main/java/org/maxgamer/QuickShop/Economy/Economy.java +++ b/src/main/java/org/maxgamer/QuickShop/Economy/Economy.java @@ -3,53 +3,91 @@ package org.maxgamer.QuickShop.Economy; import java.util.UUID; public class Economy implements EconomyCore { - private EconomyCore core; + private final EconomyCore core; - public Economy(EconomyCore core) { + public Economy(final EconomyCore core) { this.core = core; } - /** - * Checks that this economy is valid. Returns false if it is not valid. - * - * @return True if this economy will work, false if it will not. - */ - public boolean isValid() { - return core.isValid(); + @Override + public String currencyNamePlural() { + return this.core.currencyNamePlural(); } /** * Deposits a given amount of money from thin air to the given username. - * + * * @param name * The exact (case insensitive) username to give money to * @param amount * The amount to give them * @return True if success (Should be almost always) */ + @Override @Deprecated - public boolean deposit(String name, double amount) { - return core.deposit(name, amount); + public boolean deposit(final String name, final double amount) { + return this.core.deposit(name, amount); + } + + @Override + public boolean deposit(final UUID name, final double amount) { + return this.core.deposit(name, amount); } /** - * Withdraws a given amount of money from the given username and turns it to - * thin air. - * - * @param name - * The exact (case insensitive) username to take money from - * @param amount - * The amount to take from them - * @return True if success, false if they didn't have enough cash + * Formats the given number... E.g. 50.5 becomes $50.5 Dollars, or 50 + * Dollars 5 Cents + * + * @param balance + * The given number + * @return The balance in human readable text. */ + @Override + public String format(final double balance) { + return this.core.format(balance); + } + + /** + * Fetches the balance of the given account name + * + * @param name + * The name of the account + * @return Their current balance. + */ + @Override @Deprecated - public boolean withdraw(String name, double amount) { - return core.withdraw(name, amount); + public double getBalance(final String name) { + return this.core.getBalance(name); + } + + @Override + public double getBalance(final UUID name) { + return this.core.getBalance(name); + } + + @Deprecated + public boolean has(final String name, final double amount) { + return this.core.getBalance(name) >= amount; + } + + /** + * Checks that this economy is valid. Returns false if it is not valid. + * + * @return True if this economy will work, false if it will not. + */ + @Override + public boolean isValid() { + return this.core.isValid(); + } + + @Override + public String toString() { + return this.core.getClass().getName().split("_")[1]; } /** * Transfers the given amount of money from Player1 to Player2 - * + * * @param from * The player who is paying money * @param to @@ -59,61 +97,35 @@ public class Economy implements EconomyCore { * @return true if success (Payer had enough cash, receiver was able to * receive the funds) */ + @Override @Deprecated - public boolean transfer(String from, String to, double amount) { - return core.transfer(from, to, amount); + public boolean transfer(final String from, final String to, final double amount) { + return this.core.transfer(from, to, amount); + } + + @Override + public boolean transfer(final UUID from, final UUID to, final double amount) { + return this.core.transfer(from, to, amount); } /** - * Fetches the balance of the given account name - * + * Withdraws a given amount of money from the given username and turns it to + * thin air. + * * @param name - * The name of the account - * @return Their current balance. + * The exact (case insensitive) username to take money from + * @param amount + * The amount to take from them + * @return True if success, false if they didn't have enough cash */ + @Override @Deprecated - public double getBalance(String name) { - return core.getBalance(name); - } - - /** - * Formats the given number... E.g. 50.5 becomes $50.5 Dollars, or 50 - * Dollars 5 Cents - * - * @param balance - * The given number - * @return The balance in human readable text. - */ - public String format(double balance) { - return core.format(balance); - } - @Deprecated - public boolean has(String name, double amount) { - return core.getBalance(name) >= amount; + public boolean withdraw(final String name, final double amount) { + return this.core.withdraw(name, amount); } @Override - public String toString() { - return core.getClass().getName().split("_")[1]; - } - - @Override - public boolean deposit(UUID name, double amount) { - return core.deposit(name,amount); - } - - @Override - public boolean withdraw(UUID name, double amount) { - return core.withdraw(name, amount); - } - - @Override - public boolean transfer(UUID from, UUID to, double amount) { - return core.transfer(from, to, amount); - } - - @Override - public double getBalance(UUID name) { - return core.getBalance(name); + public boolean withdraw(final UUID name, final double amount) { + return this.core.withdraw(name, amount); } } \ No newline at end of file diff --git a/src/main/java/org/maxgamer/QuickShop/Economy/EconomyCore.java b/src/main/java/org/maxgamer/QuickShop/Economy/EconomyCore.java index 2587a0e..1d8269d 100644 --- a/src/main/java/org/maxgamer/QuickShop/Economy/EconomyCore.java +++ b/src/main/java/org/maxgamer/QuickShop/Economy/EconomyCore.java @@ -6,16 +6,11 @@ import java.util.UUID; * @author netherfoam Represents an economy. */ public interface EconomyCore { - /** - * Checks that this economy is valid. Returns false if it is not valid. - * - * @return True if this economy will work, false if it will not. - */ - public boolean isValid(); + public String currencyNamePlural(); /** * Deposits a given amount of money from thin air to the given username. - * + * * @param name * The exact (case insensitive) username to give money to * @param amount @@ -26,21 +21,55 @@ public interface EconomyCore { public boolean deposit(String name, double amount); /** - * Withdraws a given amount of money from the given username and turns it to - * thin air. - * + * Deposits a given amount of money from thin air to the given username. + * * @param name - * The exact (case insensitive) username to take money from + * The exact (case insensitive) username to give money to * @param amount - * The amount to take from them - * @return True if success, false if they didn't have enough cash + * The amount to give them + * @return True if success (Should be almost always) + */ + public boolean deposit(UUID name, double amount); + + /** + * Formats the given number... E.g. 50.5 becomes $50.5 Dollars, or 50 + * Dollars 5 Cents + * + * @param balance + * The given number + * @return The balance in human readable text. + */ + public String format(double balance); + + /** + * Fetches the balance of the given account name + * + * @param name + * The name of the account + * @return Their current balance. */ @Deprecated - public boolean withdraw(String name, double amount); + public double getBalance(String name); + + /** + * Fetches the balance of the given account name + * + * @param name + * The name of the account + * @return Their current balance. + */ + public double getBalance(UUID name); + + /** + * Checks that this economy is valid. Returns false if it is not valid. + * + * @return True if this economy will work, false if it will not. + */ + public boolean isValid(); /** * Transfers the given amount of money from Player1 to Player2 - * + * * @param from * The player who is paying money * @param to @@ -53,58 +82,9 @@ public interface EconomyCore { @Deprecated public boolean transfer(String from, String to, double amount); - /** - * Fetches the balance of the given account name - * - * @param name - * The name of the account - * @return Their current balance. - */ - @Deprecated - public double getBalance(String name); - - /** - * Formats the given number... E.g. 50.5 becomes $50.5 Dollars, or 50 - * Dollars 5 Cents - * - * @param balance - * The given number - * @return The balance in human readable text. - */ - public String format(double balance); - - - - - - - - /** - * Deposits a given amount of money from thin air to the given username. - * - * @param name - * The exact (case insensitive) username to give money to - * @param amount - * The amount to give them - * @return True if success (Should be almost always) - */ - public boolean deposit(UUID name, double amount); - - /** - * Withdraws a given amount of money from the given username and turns it to - * thin air. - * - * @param name - * The exact (case insensitive) username to take money from - * @param amount - * The amount to take from them - * @return True if success, false if they didn't have enough cash - */ - public boolean withdraw(UUID name, double amount); - /** * Transfers the given amount of money from Player1 to Player2 - * + * * @param from * The player who is paying money * @param to @@ -117,11 +97,27 @@ public interface EconomyCore { public boolean transfer(UUID from, UUID to, double amount); /** - * Fetches the balance of the given account name - * + * Withdraws a given amount of money from the given username and turns it to + * thin air. + * * @param name - * The name of the account - * @return Their current balance. + * The exact (case insensitive) username to take money from + * @param amount + * The amount to take from them + * @return True if success, false if they didn't have enough cash */ - public double getBalance(UUID name); + @Deprecated + public boolean withdraw(String name, double amount); + + /** + * Withdraws a given amount of money from the given username and turns it to + * thin air. + * + * @param name + * The exact (case insensitive) username to take money from + * @param amount + * The amount to take from them + * @return True if success, false if they didn't have enough cash + */ + public boolean withdraw(UUID name, double amount); } diff --git a/src/main/java/org/maxgamer/QuickShop/Economy/Economy_Vault.java b/src/main/java/org/maxgamer/QuickShop/Economy/Economy_Vault.java index a85cc0b..a4cf1b2 100644 --- a/src/main/java/org/maxgamer/QuickShop/Economy/Economy_Vault.java +++ b/src/main/java/org/maxgamer/QuickShop/Economy/Economy_Vault.java @@ -15,6 +15,11 @@ public class Economy_Vault implements EconomyCore { setupEconomy(); } + @Override + public String currencyNamePlural() { + return this.vault.currencyNamePlural(); + } + @Override @Deprecated public boolean deposit(final String name, final double amount) { diff --git a/src/main/java/org/maxgamer/QuickShop/Util/Util.java b/src/main/java/org/maxgamer/QuickShop/Util/Util.java index 5029bcd..f044f7f 100644 --- a/src/main/java/org/maxgamer/QuickShop/Util/Util.java +++ b/src/main/java/org/maxgamer/QuickShop/Util/Util.java @@ -1,5 +1,6 @@ package org.maxgamer.QuickShop.Util; +import java.text.DecimalFormat; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -27,6 +28,7 @@ import cn.citycraft.PluginHelper.utils.LocalUtil; @SuppressWarnings("deprecation") public class Util { private static HashSet blacklist = new HashSet(); + private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##"); private static QuickShop plugin; private static HashSet shoppables = new HashSet(); private static HashSet tools = new HashSet(); @@ -128,9 +130,9 @@ public class Util { */ public static String format(final double n) { try { - return plugin.getEcon().format(n); + return DECIMAL_FORMAT.format(n) + plugin.getEcon().currencyNamePlural(); } catch (final NumberFormatException e) { - return "" + n; + return n + "元"; } } diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index 963be55..80c43ae 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -1,4 +1,4 @@ -Version: 1.4 +Version: 1.5 not-looking-at-shop: '&c没找到快捷商店. 你必须看着那个商店.' no-permission: '&4你没有此命令的权限.' @@ -19,7 +19,8 @@ shop-purchase-cancelled: '&c取消购买.' shop-stock-too-low: '&c商店库存仅剩 {0} {1} ' you-cant-afford-to-buy: '&c此商品需要 {0}, 但是你只有 {1}' negative-amount: '&c警告, 错误的物品数量.' -player-bought-from-your-store: '&d{0} 购买了 {1} {2} 从你的商店.' +player-bought-from-your-store: '&d{0} 从你的商店买走了 {1} 个 {2}.' +player-bought-from-your-store-tax: '&d{0} 从你的商店买走了 {1} 个 {2} &c你上缴了 {3} 的税金.' shop-out-of-stock: '&5你在 {0}, {1}, {2} 的商店, {3} 库存不足了' shop-has-no-space: '&c商店只能收购 {0} 个 {1} 商品.' you-dont-have-that-many-items: '&c你只有 {0} {1}.' @@ -53,7 +54,9 @@ menu: damage-percent-remaining: '&a耐久剩余: &e{0}.' this-shop-is-buying: '&a此商店只 &d收购&a 物品.' this-shop-is-selling: '&a此商店只 &b出售&a 商品.' - + sell-tax: '&a你上缴了 &e{0} &a的税金.' + sell-tax-self: '&a你拥有这家商店,所以你不用交税.' + info: title: '&a当前加载的 &e{0} &a个区块中 共有 &e{1} &a个商店 覆盖 &e{2} &a个世界.' selling: '&b出售商店&a有 &e{0} &a个.'