Skip to content

Commit

Permalink
Multi-language support
Browse files Browse the repository at this point in the history
  • Loading branch information
JWJUN233233 committed Jan 20, 2024
1 parent cac0a0d commit 2a29b1a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) {
List<World> worlds = new ArrayList<>();
List<String> availableClearTypes = List.of("block", "oil");
List<String> clearTypes = new ArrayList<>();
String block = Slimefun.getLocalization().getMessage("commands.cleardata.block");
String oil = Slimefun.getLocalization().getMessage("commands.cleardata.oil");
SlimefunDatabaseManager database = Slimefun.getDatabaseManager();
BlockDataController controller = database.getBlockDataController();
if (arg1.equals("*")) {
worlds.addAll(Bukkit.getWorlds());
} else {
World toAdd = Bukkit.getWorld(arg1);
if (toAdd == null) {
sender.sendMessage(ChatColor.RED + "未找到世界", arg1);
Slimefun.getLocalization().sendMessage(sender, "commands.cleardata.worldNotFound", true);
return;
}
}
Expand All @@ -52,23 +54,31 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) {
if (cleartype.equals("block")) {
controller.removeAllDataInWorldAsync(
world,
() -> Slimefun.runSync(() -> sender.sendMessage(ChatColor.GREEN + "已清除"
+ ChatColor.YELLOW + world.getName() + ChatColor.GREEN + "的方块数据")));
() -> Slimefun.runSync(() -> Slimefun.getLocalization()
.sendMessage(
sender,
"commands.cleardata.success",
true,
msg -> String.format(msg, world.getName(), block))));
} else if (cleartype.equals("oil")) {
GEOResource oil = null;
GEOResource oilresource = null;
for (GEOResource resource :
Slimefun.getRegistry().getGEOResources().values()) {
if (resource.getKey()
.toString()
.equals(new NamespacedKey(Slimefun.instance(), "oil").toString())) {
oil = resource;
oilresource = resource;
}
}
controller.removeDataInWorldAsync(
world,
oil.getKey().toString().replace(":", "-"),
() -> Slimefun.runSync(() -> sender.sendMessage(ChatColor.GREEN + "已清除"
+ ChatColor.YELLOW + world.getName() + ChatColor.GREEN + "的石油数据")));
oilresource.getKey().toString().replace(":", "-"),
() -> Slimefun.runSync(() -> Slimefun.getLocalization()
.sendMessage(
sender,
"commands.cleardata.success",
true,
msg -> String.format(msg, world.getName(), oil))));
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/languages/zh-CN/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ commands:
stats: 查看玩家的统计数据
transform: 将物品转换为英文物品
id: 获取手持物品的 Slimefun ID
cleardata:
description: 清理世界数据
success: '&a已清除&c{0}&a的&c{1}&a数据'
block: 方块
oil: 石油
worldNotFound: '&c未找到世界'
banitem:
description: 禁用 Slimefun 物品
success: '&a禁用成功'
Expand Down

0 comments on commit 2a29b1a

Please sign in to comment.