diff --git a/src/main/java/io/izzel/ambershop/AmberShop.java b/src/main/java/io/izzel/ambershop/AmberShop.java index 7ae4605..5ed039e 100644 --- a/src/main/java/io/izzel/ambershop/AmberShop.java +++ b/src/main/java/io/izzel/ambershop/AmberShop.java @@ -11,7 +11,9 @@ import lombok.val; import org.bstats.sponge.Metrics; import org.spongepowered.api.Sponge; +import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.event.Listener; +import org.spongepowered.api.event.game.GameReloadEvent; import org.spongepowered.api.event.game.state.GameStartedServerEvent; import org.spongepowered.api.event.game.state.GameStartingServerEvent; import org.spongepowered.api.event.game.state.GameStoppingEvent; @@ -71,6 +73,12 @@ public void onServerStart(GameStartingServerEvent event) { locale.info("startup", container.getVersion().get()); } + @Listener + public void onReload(GameReloadEvent event) { + val source = event.getCause().first(CommandSource.class).orElse(Sponge.getServer().getConsole()); + Sponge.getCommandManager().process(source, "ambershop reload"); + } + @Listener public void onServerStop(GameStoppingEvent event) { tasks.shutdown(); diff --git a/src/main/java/io/izzel/ambershop/cmd/AmberCommands.java b/src/main/java/io/izzel/ambershop/cmd/AmberCommands.java index a404ac6..09e90d2 100644 --- a/src/main/java/io/izzel/ambershop/cmd/AmberCommands.java +++ b/src/main/java/io/izzel/ambershop/cmd/AmberCommands.java @@ -57,6 +57,16 @@ public AmberCommands(AmberLocale locale, AmberConfManager cm, .executor(spe) .build(); executor.child(price, "setprice", "price", "p"); + val reload = CommandSpec.builder() + .permission("ambershop.admin.reload") + .executor((src, args) -> { + locale.init(); + cm.reload(); + src.sendMessage(locale.getText("commands.reload.complete")); + return CommandResult.success(); + }) + .build(); + executor.child(reload, "reload"); } root = executor.build(); } diff --git a/src/main/resources/assets/ambershop/locale/en_us.conf b/src/main/resources/assets/ambershop/locale/en_us.conf index 45ec7f6..c29ffbc 100644 --- a/src/main/resources/assets/ambershop/locale/en_us.conf +++ b/src/main/resources/assets/ambershop/locale/en_us.conf @@ -22,12 +22,12 @@ trade { # {4} for the type of the shop shop-info = [ "&d+------------------------------" - "&d| &aShop information" - "&d| &aOwner: &e{0}" - "&d| &aItem: &e{1}" + "&d| &b&lShop information" + "&d| &aOwner: &d{0}" + "&d| &aItem: &e{1} &7<-info" "&d| &aStock: &e{2}" "&d| &aPrice: &e{3}" - "&d| &aThis shop is {4} item." + "&d| &aThis shop is &b&l{4}&a item." "&d+------------------------------" ] input-buy = "&eEnter the amount of the item to buy." @@ -46,7 +46,7 @@ trade { type { buy = "SELLING" sell = "BUYING" - unlimited = "Unlimited" + unlimited = "INFINITE" } manage { remove = "&c[Remove]" @@ -54,7 +54,7 @@ trade { setprice-input = "&eEnter new price." setowner = "&c[Set owner]" setowner-input = "&eEnter new owner" - setunlimited = "&b[Set unlimited]" + setunlimited = "&6[Set unlimited]" } } @@ -69,7 +69,7 @@ commands { player-only = "&cOnly players can create a shop." exist-shop = "&cThis block is already a shop." } - success = "&aSuccessfully created a shop with ID {0}" + success = "&aSuccessfully created a shop with &eID {0}" } remove { desc = "Remove a shop" @@ -107,4 +107,7 @@ commands { no-perm = "&cYou do not have permission to set the price of the shop." } } + reload { + complete = "&eAmberShop reloaded." + } } diff --git a/src/main/resources/assets/ambershop/locale/zh_cn.conf b/src/main/resources/assets/ambershop/locale/zh_cn.conf index a4ad26f..6f780da 100644 --- a/src/main/resources/assets/ambershop/locale/zh_cn.conf +++ b/src/main/resources/assets/ambershop/locale/zh_cn.conf @@ -22,21 +22,21 @@ trade { # {4} 为商店模式 文本位于 trade.type 中 shop-info = [ "&d+------------------------------" - "&d| &a商店信息" - "&d| &a所有者: &e{0}" - "&d| &a物品: &e{1}" - "&d| &a库存: &e{2}" - "&d| &a单价: &e{3}" - "&d| &a本商店{4}物品" + "&d| &b&l商店信息" + "&d| &a所有者: &d{0}" + "&d| &a物品: &e{1} &7<-查看" + "&d| &a库存: &e{2}" + "&d| &a单价: &e{3}" + "&d| &a本商店&b&l{4}&a物品" "&d+------------------------------" ] input-buy = "&e请输入购买的数量" input-sell = "&e请输入出售的数量" - expire = "&c给你输入的时间已经过了。" + expire = "&c给你输入的时间已经过了" format-err = "&c输入的格式错误,请重新输入数字" non-negative = "&c请输入一个大于 0 的数字" transaction-results { - success = "&a交易成功" + success = "&a交易成功!" sold-out = "&c没有足够的物品可供出售" economy-issue = "&c余额不足或商店余额已满" inventory-full = "&c存储空间已满" @@ -54,7 +54,7 @@ trade { setprice-input = "&e请输入新的价格" setowner = "&c[设置商店主人]" setowner-input = "&e请输入新的主人" - setunlimited = "&b[设置无限商店]" + setunlimited = "&6[设置无限商店]" } } @@ -69,7 +69,7 @@ commands { player-only = "&c只有玩家能创建商店" exist-shop = "&c这个方块已经是一个商店了" } - success = "&a成功创建商店,ID {0}" + success = "&a成功创建商店,&eID {0}" } remove { desc = "移除一个商店" @@ -107,4 +107,7 @@ commands { no-perm = "&c没有权限设置这个商店的价格" } } + reload { + complete = "&eAmberShop 重载完成" + } }