Skip to content

Commit

Permalink
[1.6.3-dev3]菜单页面文本添加支持多语言组件,增加德语、俄语、日语、香港繁体中文的语言文件
Browse files Browse the repository at this point in the history
  • Loading branch information
YufiriaMazenta committed Dec 16, 2023
1 parent f188fd7 commit 35dc2cc
Show file tree
Hide file tree
Showing 19 changed files with 596 additions and 84 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import java.text.SimpleDateFormat
version = "1.6.3-dev2"
version = "1.6.3-dev3"

plugins {
`java-library`
Expand Down Expand Up @@ -40,7 +40,7 @@ dependencies {
compileOnly("io.lumine:Mythic-Dist:5.3.5")
compileOnly("io.lumine:MythicLib-dist:1.6.2-SNAPSHOT")
compileOnly("net.Indyuce:MMOItems-API:6.9.5-SNAPSHOT")
implementation("com.crypticlib:CrypticLib:0.8.8")
implementation("com.crypticlib:CrypticLib:0.8.10")
}

group = "com.github.yufiriamazenta"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import crypticlib.chat.LangConfigHandler;
import crypticlib.chat.entry.StringLangConfigEntry;
import crypticlib.config.entry.StringListConfigEntry;
import crypticlib.chat.entry.StringListLangConfigEntry;

import java.util.Collections;

Expand Down Expand Up @@ -66,13 +66,13 @@ public class Languages {
public static final StringLangConfigEntry MENU_RECIPE_CREATOR_ICON_ANVIL_FRAME = new StringLangConfigEntry("menu.recipe_creator.icon.anvil_frame", "&a打造原料");
public static final StringLangConfigEntry MENU_RECIPE_CREATOR_ICON_ANVIL_COPY_NBT_TOGGLE = new StringLangConfigEntry("menu.recipe_creator.icon.anvil_copy_nbt_toggle", "&a保留物品NBT: <enable>");
public static final StringLangConfigEntry MENU_RECIPE_CREATOR_ICON_ANVIL_COST_LEVEL_NAME = new StringLangConfigEntry("menu.recipe_creator.icon.anvil_cost_level.name", "&a所需等级: <level>");
public static final StringListConfigEntry MENU_RECIPE_CREATOR_ICON_ANVIL_COST_LEVEL_LORE = new StringListConfigEntry("menu.recipe_creator.icon.anvil_cost_level.lore", Collections.singletonList("&3点击修改所需等级"));
public static final StringListLangConfigEntry MENU_RECIPE_CREATOR_ICON_ANVIL_COST_LEVEL_LORE = new StringListLangConfigEntry("menu.recipe_creator.icon.anvil_cost_level.lore", Collections.singletonList("&3点击修改所需等级"));
public static final StringLangConfigEntry MENU_RECIPE_CREATOR_ICON_ANVIL_COST_LEVEL_INPUT_HINT = new StringLangConfigEntry("menu.recipe_creator.icon.anvil_cost_level.input_hint", "&a请输入所需等级, 输入cancel取消");
public static final StringLangConfigEntry MENU_RECIPE_CREATOR_ICON_COOKING_TIME_NAME = new StringLangConfigEntry("menu.recipe_creator.icon.cooking_time.name", "&a烧炼时间: <time> tick");
public static final StringListConfigEntry MENU_RECIPE_CREATOR_ICON_COOKING_TIME_LORE = new StringListConfigEntry("menu.recipe_creator.icon.cooking_time.lore", Collections.singletonList("&3点击修改烧炼时间"));
public static final StringListLangConfigEntry MENU_RECIPE_CREATOR_ICON_COOKING_TIME_LORE = new StringListLangConfigEntry("menu.recipe_creator.icon.cooking_time.lore", Collections.singletonList("&3点击修改烧炼时间"));
public static final StringLangConfigEntry MENU_RECIPE_CREATOR_ICON_COOKING_TIME_INPUT_HINT = new StringLangConfigEntry("menu.recipe_creator.icon.cooking_time.input_hint", "&a请输入烧炼时间, 单位为tick, 输入cancel取消");
public static final StringLangConfigEntry MENU_RECIPE_CREATOR_ICON_COOKING_EXP_NAME = new StringLangConfigEntry("menu.recipe_creator.icon.cooking_exp.name", "&a奖励经验: <exp>");
public static final StringListConfigEntry MENU_RECIPE_CREATOR_ICON_COOKING_EXP_LORE = new StringListConfigEntry("menu.recipe_creator.icon.cooking_exp.lore", Collections.singletonList("&3点击修改奖励经验"));
public static final StringListLangConfigEntry MENU_RECIPE_CREATOR_ICON_COOKING_EXP_LORE = new StringListLangConfigEntry("menu.recipe_creator.icon.cooking_exp.lore", Collections.singletonList("&3点击修改奖励经验"));
public static final StringLangConfigEntry MENU_RECIPE_CREATOR_ICON_COOKING_EXP_INPUT_HINT = new StringLangConfigEntry("menu.recipe_creator.icon.cooking_exp.input_hint", "&a请输入奖励经验, 输入cancel取消");
public static final StringLangConfigEntry MENU_RECIPE_CREATOR_ICON_FURNACE_TOGGLE = new StringLangConfigEntry("menu.recipe_creator.icon.furnace_toggle", "&a启用熔炉配方:<enable>");
public static final StringLangConfigEntry MENU_RECIPE_CREATOR_ICON_BLAST_FURNACE_TOGGLE = new StringLangConfigEntry("menu.recipe_creator.icon.blast_furnace_toggle", "&a启用高炉配方:<enable>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public AnvilRecipeCreator(@NotNull Player player, @NotNull String recipeName) {
Map<Character, Icon> layoutMap = new HashMap<>();
layoutMap.put('#', getFrameIcon());
layoutMap.put('%', getResultFrameIcon());
layoutMap.put('*', new Icon(Material.CYAN_STAINED_GLASS_PANE, Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_FRAME.value()));
layoutMap.put('*', new Icon(Material.CYAN_STAINED_GLASS_PANE, Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_FRAME.value(player)));
layoutMap.put('B', getCopyNbtIcon());
layoutMap.put('C', getCostLevelIcon());
layoutMap.put('A', new Icon(Material.ANVIL, Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(),
layoutMap.put('A', new Icon(Material.ANVIL, Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(player),
event -> {
StoredMenu creator = (StoredMenu) event.getClickedInventory().getHolder();
ItemStack result = Objects.requireNonNull(creator).storedItems().get(24);
Expand Down Expand Up @@ -113,7 +113,7 @@ protected Icon getCopyNbtIcon() {
Icon icon = new Icon(
Material.NAME_TAG,
Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_COPY_NBT_TOGGLE
.value()
.value(player())
.replace("<enable>", String.valueOf(copyNbt)),
event -> toggleCopyNbt(event.getSlot(), event)
);
Expand All @@ -130,7 +130,7 @@ protected void toggleCopyNbt(int slot, InventoryClickEvent event) {
itemMeta.setDisplayName(
TextProcessor.color(
Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_COPY_NBT_TOGGLE
.value()
.value(player())
.replace("<enable>", String.valueOf(copyNbt))
)
);
Expand All @@ -140,7 +140,7 @@ protected void toggleCopyNbt(int slot, InventoryClickEvent event) {
protected Icon getCostLevelIcon() {
Icon icon = new Icon(
Material.EXPERIENCE_BOTTLE,
TextProcessor.color(Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_COST_LEVEL_NAME.value())
TextProcessor.color(Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_COST_LEVEL_NAME.value(player()))
.replace("<level>", String.valueOf(costLevel)),
event -> {
Player player = (Player) event.getWhoClicked();
Expand All @@ -155,7 +155,7 @@ protected Icon getCostLevelIcon() {
player.closeInventory();
}
);
ItemUtils.setLore(icon.display(), Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_COST_LEVEL_LORE.value());
ItemUtils.setLore(icon.display(), Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_COST_LEVEL_LORE.value(player()));
return icon;
}

Expand All @@ -164,7 +164,7 @@ public void updateCostLevelIcon() {
if (costLevelIcon == null)
return;
ItemMeta itemMeta = costLevelIcon.getItemMeta();
itemMeta.setDisplayName(TextProcessor.color(Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_COST_LEVEL_NAME.value())
itemMeta.setDisplayName(TextProcessor.color(Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_COST_LEVEL_NAME.value(player()))
.replace("<level>", String.valueOf(costLevel)));
costLevelIcon.setItemMeta(itemMeta);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ public CookingRecipeCreator(@NotNull Player player, @NotNull String recipeName)
Map<Character, Icon> layoutMap = new HashMap<>();
layoutMap.put('#', getFrameIcon());
layoutMap.put('%', getResultFrameIcon());
layoutMap.put('*', new Icon(Material.CYAN_STAINED_GLASS_PANE, Languages.MENU_RECIPE_CREATOR_ICON_COOKING_FRAME.value()));
layoutMap.put('*', new Icon(
Material.CYAN_STAINED_GLASS_PANE,
Languages.MENU_RECIPE_CREATOR_ICON_COOKING_FRAME.value(player)
));
layoutMap.put('B', getCookingToggleIcon(Material.FURNACE));
layoutMap.put('C', getCookingToggleIcon(Material.BLAST_FURNACE));
layoutMap.put('D', getCookingToggleIcon(Material.SMOKER));
Expand All @@ -69,7 +72,7 @@ public CookingRecipeCreator(@NotNull Player player, @NotNull String recipeName)
layoutMap.put('H', getExpIcon());
layoutMap.put('A', new Icon(
Material.FURNACE,
Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(),
Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(player),
event -> {
StoredMenu creator = (StoredMenu) Objects.requireNonNull(event.getClickedInventory()).getHolder();
ItemStack source = Objects.requireNonNull(creator).storedItems().get(20);
Expand Down Expand Up @@ -134,16 +137,16 @@ protected Icon getCookingToggleIcon(Material material) {
switch (material) {
case FURNACE:
default:
displayName = Languages.MENU_RECIPE_CREATOR_ICON_FURNACE_TOGGLE.value();
displayName = Languages.MENU_RECIPE_CREATOR_ICON_FURNACE_TOGGLE.value(player());
break;
case BLAST_FURNACE:
displayName = Languages.MENU_RECIPE_CREATOR_ICON_BLAST_FURNACE_TOGGLE.value();
displayName = Languages.MENU_RECIPE_CREATOR_ICON_BLAST_FURNACE_TOGGLE.value(player());
break;
case SMOKER:
displayName = Languages.MENU_RECIPE_CREATOR_ICON_SMOKER_TOGGLE.value();
displayName = Languages.MENU_RECIPE_CREATOR_ICON_SMOKER_TOGGLE.value(player());
break;
case CAMPFIRE:
displayName = Languages.MENU_RECIPE_CREATOR_ICON_CAMPFIRE_TOGGLE.value();
displayName = Languages.MENU_RECIPE_CREATOR_ICON_CAMPFIRE_TOGGLE.value(player());
break;
}
displayName = displayName.replace("<enable>", String.valueOf(enable));
Expand All @@ -165,16 +168,16 @@ protected void toggleCookingIcon(int slot, InventoryClickEvent event) {
switch (display.getType()) {
case FURNACE:
default:
displayName = Languages.MENU_RECIPE_CREATOR_ICON_FURNACE_TOGGLE.value();
displayName = Languages.MENU_RECIPE_CREATOR_ICON_FURNACE_TOGGLE.value(player());
break;
case BLAST_FURNACE:
displayName = Languages.MENU_RECIPE_CREATOR_ICON_BLAST_FURNACE_TOGGLE.value();
displayName = Languages.MENU_RECIPE_CREATOR_ICON_BLAST_FURNACE_TOGGLE.value(player());
break;
case SMOKER:
displayName = Languages.MENU_RECIPE_CREATOR_ICON_SMOKER_TOGGLE.value();
displayName = Languages.MENU_RECIPE_CREATOR_ICON_SMOKER_TOGGLE.value(player());
break;
case CAMPFIRE:
displayName = Languages.MENU_RECIPE_CREATOR_ICON_CAMPFIRE_TOGGLE.value();
displayName = Languages.MENU_RECIPE_CREATOR_ICON_CAMPFIRE_TOGGLE.value(player());
break;
}
boolean enable = !cookingToggleMap.getOrDefault(display.getType(), false);
Expand All @@ -192,7 +195,7 @@ protected void toggleCookingIcon(int slot, InventoryClickEvent event) {
protected Icon getCookingTimeIcon() {
Icon icon = new Icon(
Material.CLOCK,
TextProcessor.color(Languages.MENU_RECIPE_CREATOR_ICON_COOKING_TIME_NAME.value())
TextProcessor.color(Languages.MENU_RECIPE_CREATOR_ICON_COOKING_TIME_NAME.value(player()))
.replace("<time>", String.valueOf(cookingTime)),
event -> {
Player player = (Player) event.getWhoClicked();
Expand All @@ -207,14 +210,14 @@ protected Icon getCookingTimeIcon() {
player.closeInventory();
}
);
ItemUtils.setLore(icon.display(), Languages.MENU_RECIPE_CREATOR_ICON_COOKING_TIME_LORE.value());
ItemUtils.setLore(icon.display(), Languages.MENU_RECIPE_CREATOR_ICON_COOKING_TIME_LORE.value(player()));
return icon;
}

protected Icon getExpIcon() {
Icon icon = new Icon(
Material.EXPERIENCE_BOTTLE,
TextProcessor.color(Languages.MENU_RECIPE_CREATOR_ICON_COOKING_EXP_NAME.value())
TextProcessor.color(Languages.MENU_RECIPE_CREATOR_ICON_COOKING_EXP_NAME.value(player()))
.replace("<exp>", String.valueOf(exp)),
event -> {
Player player = (Player) event.getWhoClicked();
Expand All @@ -229,7 +232,7 @@ protected Icon getExpIcon() {
player.closeInventory();
}
);
ItemUtils.setLore(icon.display(), Languages.MENU_RECIPE_CREATOR_ICON_COOKING_EXP_LORE.value());
ItemUtils.setLore(icon.display(), Languages.MENU_RECIPE_CREATOR_ICON_COOKING_EXP_LORE.value(player()));
return icon;
}

Expand All @@ -238,7 +241,7 @@ protected void updateCookingTimeIcon() {
if (cookingTimeIcon == null)
return;
ItemMeta itemMeta = cookingTimeIcon.getItemMeta();
itemMeta.setDisplayName(TextProcessor.color(Languages.MENU_RECIPE_CREATOR_ICON_COOKING_TIME_NAME.value())
itemMeta.setDisplayName(TextProcessor.color(Languages.MENU_RECIPE_CREATOR_ICON_COOKING_TIME_NAME.value(player()))
.replace("<time>", String.valueOf(cookingTime)));
cookingTimeIcon.setItemMeta(itemMeta);
}
Expand All @@ -248,7 +251,7 @@ protected void updateExpIcon() {
if (expIcon == null)
return;
ItemMeta itemMeta = expIcon.getItemMeta();
itemMeta.setDisplayName(TextProcessor.color(Languages.MENU_RECIPE_CREATOR_ICON_COOKING_EXP_NAME.value())
itemMeta.setDisplayName(TextProcessor.color(Languages.MENU_RECIPE_CREATOR_ICON_COOKING_EXP_NAME.value(player()))
.replace("<exp>", String.valueOf(exp)));
expIcon.setItemMeta(itemMeta);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public CraftingRecipeCreator(@NotNull Player player, RecipeType recipeType, @Not
layoutMap.put('F', getUnlockIcon());
layoutMap.put('A', new Icon(
Material.CRAFTING_TABLE,
Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(),
Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(player),
event -> {
StoredMenu creator = (StoredMenu) Objects.requireNonNull(event.getClickedInventory()).getHolder();
Map<Integer, ItemStack> storedItems = Objects.requireNonNull(creator).storedItems();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ public PotionMixCreator(@NotNull Player player, @NotNull String recipeName) {
Map<Character, Icon> layoutMap = new HashMap<>();
layoutMap.put('#', getFrameIcon());
layoutMap.put('%', getResultFrameIcon());
layoutMap.put('*', new Icon(Material.CYAN_STAINED_GLASS_PANE, Languages.MENU_RECIPE_CREATOR_ICON_POTION_FRAME.value()));
layoutMap.put('A', new Icon(Material.BREWING_STAND, Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(),
layoutMap.put('*', new Icon(
Material.CYAN_STAINED_GLASS_PANE,
Languages.MENU_RECIPE_CREATOR_ICON_POTION_FRAME.value(player)
));
layoutMap.put('A', new Icon(
Material.BREWING_STAND,
Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(player),
event -> {
StoredMenu creator = (StoredMenu) event.getClickedInventory().getHolder();
ItemStack result = Objects.requireNonNull(creator).storedItems().get(24);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public RecipeCreator(
super(player);
this.recipeName = recipeName;
this.recipeType = recipeType;
this.title = Languages.MENU_RECIPE_CREATOR_TITLE.value()
.replace("<recipe_type>", RecipeManager.INSTANCE.getRecipeTypeName(recipeType))
this.title = Languages.MENU_RECIPE_CREATOR_TITLE.value(player)
.replace("<recipe_type>", RecipeManager.INSTANCE.getRecipeTypeName(recipeType).value(player))
.replace("<recipe_name>", recipeName);
}

Expand All @@ -64,14 +64,19 @@ protected void toggleIconGlowing(int slot, InventoryClickEvent event) {
}

protected Icon getFrameIcon() {
return new Icon(Material.BLACK_STAINED_GLASS_PANE, Languages.MENU_RECIPE_CREATOR_ICON_FRAME.value());
return new Icon(Material.BLACK_STAINED_GLASS_PANE, Languages.MENU_RECIPE_CREATOR_ICON_FRAME.value(player()));
}

protected void sendSuccessMsg(HumanEntity receiver, String recipeName) {
LangUtil.sendLang(
receiver,
Languages.COMMAND_CREATE_SUCCESS,
CollectionsUtil.newStringHashMap("<recipe_type>", RecipeManager.INSTANCE.getRecipeTypeName(recipeType), "<recipe_name>", recipeName)
CollectionsUtil.newStringHashMap(
"<recipe_type>",
RecipeManager.INSTANCE.getRecipeTypeName(recipeType).value((Player) receiver),
"<recipe_name>",
recipeName
)
);
}

Expand All @@ -84,7 +89,7 @@ protected ConfigWrapper createRecipeConfig(String recipeName) {
}

protected Icon getResultFrameIcon() {
return new Icon(Material.LIME_STAINED_GLASS_PANE, Languages.MENU_RECIPE_CREATOR_ICON_RESULT_FRAME.value());
return new Icon(Material.LIME_STAINED_GLASS_PANE, Languages.MENU_RECIPE_CREATOR_ICON_RESULT_FRAME.value(player()));
}

public RecipeType recipeType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ public SmithingRecipeCreator(@NotNull Player player, @NotNull String recipeName)
() -> {
Map<Character, Icon> layoutMap = new HashMap<>();
layoutMap.put('#', getFrameIcon());
layoutMap.put('*', new Icon(Material.CYAN_STAINED_GLASS_PANE, Languages.MENU_RECIPE_CREATOR_ICON_SMITHING_FRAME.value()));
layoutMap.put('*', new Icon(
Material.CYAN_STAINED_GLASS_PANE,
Languages.MENU_RECIPE_CREATOR_ICON_SMITHING_FRAME.value(player)
));
layoutMap.put('%', getResultFrameIcon());
layoutMap.put('F', getUnlockIcon());
layoutMap.put('A', new Icon(
Material.SMITHING_TABLE,
Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(),
Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(player),
event -> {
StoredMenu creator = (StoredMenu) Objects.requireNonNull(event.getClickedInventory()).getHolder();
ItemStack result = Objects.requireNonNull(creator).storedItems().get(24);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public StoneCuttingRecipeCreator(@NotNull Player player, @NotNull String recipeN
Map<Character, Icon> layoutMap = new HashMap<>();
layoutMap.put('#', getFrameIcon());
layoutMap.put('F', getUnlockIcon());
layoutMap.put('A', new Icon(Material.STONECUTTER, Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(),
layoutMap.put('A', new Icon(
Material.STONECUTTER,
Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(player),
event -> {
StoredMenu creator = (StoredMenu) event.getClickedInventory().getHolder();
List<String> sourceList = new ArrayList<>();
Expand Down
Loading

0 comments on commit 35dc2cc

Please sign in to comment.