Skip to content

Commit

Permalink
Add reload & language
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzelAliz committed Jun 23, 2019
1 parent 4c253ae commit 17de5e3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 17 deletions.
8 changes: 8 additions & 0 deletions src/main/java/io/izzel/ambershop/AmberShop.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/io/izzel/ambershop/cmd/AmberCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
17 changes: 10 additions & 7 deletions src/main/resources/assets/ambershop/locale/en_us.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -46,15 +46,15 @@ trade {
type {
buy = "SELLING"
sell = "BUYING"
unlimited = "Unlimited"
unlimited = "INFINITE"
}
manage {
remove = "&c[Remove]"
setprice = "&a[Set price]"
setprice-input = "&eEnter new price."
setowner = "&c[Set owner]"
setowner-input = "&eEnter new owner"
setunlimited = "&b[Set unlimited]"
setunlimited = "&6[Set unlimited]"
}
}

Expand All @@ -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"
Expand Down Expand Up @@ -107,4 +107,7 @@ commands {
no-perm = "&cYou do not have permission to set the price of the shop."
}
}
reload {
complete = "&eAmberShop reloaded."
}
}
23 changes: 13 additions & 10 deletions src/main/resources/assets/ambershop/locale/zh_cn.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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存储空间已满"
Expand All @@ -54,7 +54,7 @@ trade {
setprice-input = "&e请输入新的价格"
setowner = "&c[设置商店主人]"
setowner-input = "&e请输入新的主人"
setunlimited = "&b[设置无限商店]"
setunlimited = "&6[设置无限商店]"
}
}

Expand All @@ -69,7 +69,7 @@ commands {
player-only = "&c只有玩家能创建商店"
exist-shop = "&c这个方块已经是一个商店了"
}
success = "&a成功创建商店,ID {0}"
success = "&a成功创建商店,&eID {0}"
}
remove {
desc = "移除一个商店"
Expand Down Expand Up @@ -107,4 +107,7 @@ commands {
no-perm = "&c没有权限设置这个商店的价格"
}
}
reload {
complete = "&eAmberShop 重载完成"
}
}

0 comments on commit 17de5e3

Please sign in to comment.