Skip to content

Commit

Permalink
[1.6.3-dev2]消息文本支持多语言,新增繁体中文,英文
Browse files Browse the repository at this point in the history
  • Loading branch information
YufiriaMazenta committed Dec 16, 2023
1 parent d31619f commit f188fd7
Show file tree
Hide file tree
Showing 41 changed files with 467 additions and 237 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-dev1"
version = "1.6.3-dev2"

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.7.2")
implementation("com.crypticlib:CrypticLib:0.8.8")
}

group = "com.github.yufiriamazenta"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void enable() {
initArcenciel();
loadBStat();

LangUtil.info(Languages.LOAD_FINISH.value());
LangUtil.info(Languages.LOAD_FINISH);
UpdateUtil.pullUpdateCheckRequest(Bukkit.getConsoleSender());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import com.github.yufiriamazenta.craftorithm.arcenciel.obj.ReturnObj;
import com.github.yufiriamazenta.craftorithm.arcenciel.token.*;
import com.github.yufiriamazenta.craftorithm.util.PluginHookUtil;
import crypticlib.config.yaml.YamlConfigWrapper;
import crypticlib.config.ConfigWrapper;
import org.bukkit.entity.Player;

import java.util.List;

public enum ArcencielDispatcher implements IArcencielDispatcher {

INSTANCE;
private YamlConfigWrapper functionFile;
private ConfigWrapper functionFile;

ArcencielDispatcher() {
regDefScriptKeyword();
Expand Down Expand Up @@ -65,7 +65,7 @@ private void regDefScriptKeyword() {
}
}

public YamlConfigWrapper functionFile() {
public ConfigWrapper functionFile() {
return functionFile;
}

Expand All @@ -75,7 +75,7 @@ public List<String> getFunc(String funcName) {

public void loadFuncFile() {
if (functionFile == null)
functionFile = new YamlConfigWrapper(Craftorithm.instance(), "function.yml");
functionFile = new ConfigWrapper(Craftorithm.instance(), "function.yml");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.github.yufiriamazenta.craftorithm.config.Languages;
import com.github.yufiriamazenta.craftorithm.util.CollectionsUtil;
import com.github.yufiriamazenta.craftorithm.util.LangUtil;
import crypticlib.chat.MessageSender;
import org.bukkit.entity.Player;

import java.util.ArrayList;
Expand Down Expand Up @@ -39,7 +40,7 @@ public ReturnObj<Object> exec(Player player) {
if (keyword == null) {
List<String> func = ArcencielDispatcher.INSTANCE.getFunc(keywordStr);
if (func.isEmpty()) {
LangUtil.sendLang(player, Languages.ARCENCIEL_UNKNOWN_TOKEN.value(), CollectionsUtil.newStringHashMap("<token>", keywordStr));
LangUtil.sendLang(player, Languages.ARCENCIEL_UNKNOWN_TOKEN, CollectionsUtil.newStringHashMap("<token>", keywordStr));
return new ReturnObj<>(ArcencielSignal.CONTINUE);
} else {
return ArcencielDispatcher.INSTANCE.dispatchArcencielFunc(player, func);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.github.yufiriamazenta.craftorithm.arcenciel.obj.ReturnObj;
import com.github.yufiriamazenta.craftorithm.util.CollectionsUtil;
import crypticlib.util.TextUtil;
import crypticlib.chat.TextProcessor;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

Expand All @@ -18,7 +18,7 @@ protected TokenConsole() {

@Override
public ReturnObj<Boolean> exec(Player player, List<String> args) {
String command = TextUtil.placeholder(player, CollectionsUtil.list2ArcencielBlock(args));
String command = TextProcessor.placeholder(player, CollectionsUtil.list2ArcencielBlock(args));
return new ReturnObj<>(Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected TokenHasPerm() {
@Override
public ReturnObj<Boolean> exec(Player player, List<String> args) {
if (args.isEmpty()) {
LangUtil.sendLang(player, Languages.ARCENCIEL_NOT_ENOUGH_PARAM.value(), CollectionsUtil.newStringHashMap("<statement>", "if"));
LangUtil.sendLang(player, Languages.ARCENCIEL_NOT_ENOUGH_PARAM, CollectionsUtil.newStringHashMap("<statement>", "if"));
return new ReturnObj<>(false);
}
return new ReturnObj<>(player.hasPermission(args.get(0)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.github.yufiriamazenta.craftorithm.arcenciel.obj.ReturnObj;
import com.github.yufiriamazenta.craftorithm.util.CollectionsUtil;
import com.github.yufiriamazenta.craftorithm.util.ScriptValueUtil;
import crypticlib.util.TextUtil;
import crypticlib.chat.TextProcessor;
import org.bukkit.entity.Player;

import java.util.List;
Expand All @@ -21,14 +21,14 @@ public ReturnObj<Boolean> exec(Player player, List<String> args) {
String papiStr;
if (args.size() > 2) {
papiStr = args.get(0);
papiStr = TextUtil.placeholder(player, papiStr);
papiStr = TextProcessor.placeholder(player, papiStr);
String operator = args.get(1);
String valueStr = CollectionsUtil.list2ArcencielBlock(args.subList(2, args.size()));
return new ReturnObj<>(ScriptValueUtil.compare(papiStr, valueStr, operator));
} else {
papiStr = CollectionsUtil.list2ArcencielBlock(args);
papiStr = TextUtil.placeholder(player, papiStr);
return new ReturnObj<>(Boolean.parseBoolean(TextUtil.placeholder(player, papiStr)));
papiStr = TextProcessor.placeholder(player, papiStr);
return new ReturnObj<>(Boolean.parseBoolean(TextProcessor.placeholder(player, papiStr)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.github.yufiriamazenta.craftorithm.arcenciel.obj.ReturnObj;
import com.github.yufiriamazenta.craftorithm.util.CollectionsUtil;
import crypticlib.util.TextUtil;
import crypticlib.chat.TextProcessor;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

Expand All @@ -18,7 +18,7 @@ protected TokenRunCmd() {

@Override
public ReturnObj<Boolean> exec(Player player, List<String> args) {
String command = TextUtil.placeholder(player, CollectionsUtil.list2ArcencielBlock(args));
String command = TextProcessor.placeholder(player, CollectionsUtil.list2ArcencielBlock(args));
return new ReturnObj<>(Bukkit.dispatchCommand(player, command));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ public class PluginCommand extends RootCmdExecutor {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
List<String> argList = Arrays.asList(args);
if (argList.isEmpty()) {
LangUtil.sendLang(sender, Languages.COMMAND_NOT_ENOUGH_PARAM.value(), CollectionsUtil.newStringHashMap("<number>", String.valueOf(1)));
LangUtil.sendLang(sender, Languages.COMMAND_NOT_ENOUGH_PARAM, CollectionsUtil.newStringHashMap("<number>", String.valueOf(1)));
return true;
}
ISubcmdExecutor subCommand = subcommands().get(argList.get(0));
if (subCommand != null) {
String perm = subCommand.permission();
if (perm != null) {
if (!sender.hasPermission(perm)) {
LangUtil.sendLang(sender, Languages.COMMAND_NO_PERM.value());
LangUtil.sendLang(sender, Languages.COMMAND_NO_PERM);
return true;
}
}
return subCommand.onCommand(sender, argList.subList(1, argList.size()));
}
else {
LangUtil.sendLang(sender, Languages.COMMAND_UNDEFINED_SUBCMD.value());
LangUtil.sendLang(sender, Languages.COMMAND_UNDEFINED_SUBCMD);
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ protected AbstractSubCommand(String command) {
public boolean onCommand(CommandSender sender, List<String> args) {
ISubcmdExecutor subCommand = subcommands().get(args.get(0));
if (subCommand == null) {
LangUtil.sendLang(sender, Languages.COMMAND_UNDEFINED_SUBCMD.value());
LangUtil.sendLang(sender, Languages.COMMAND_UNDEFINED_SUBCMD);
} else {
String perm = subCommand.permission();
if (perm != null) {
if (!sender.hasPermission(perm)) {
LangUtil.sendLang(sender, Languages.COMMAND_NO_PERM.value());
LangUtil.sendLang(sender, Languages.COMMAND_NO_PERM);
return true;
}
}
Expand All @@ -43,14 +43,14 @@ public void sendNotEnoughCmdParamMsg(CommandSender sender, int paramNum) {
}

public void sendNotEnoughCmdParamMsg(CommandSender sender, String paramStr) {
LangUtil.sendLang(sender, Languages.COMMAND_NOT_ENOUGH_PARAM.value(), CollectionsUtil.newStringHashMap("<number>", paramStr));
LangUtil.sendLang(sender, Languages.COMMAND_NOT_ENOUGH_PARAM, CollectionsUtil.newStringHashMap("<number>", paramStr));
}

public boolean checkSenderIsPlayer(CommandSender sender) {
if (sender instanceof Player) {
return true;
} else {
LangUtil.sendLang(sender, Languages.COMMAND_PLAYER_ONLY.value());
LangUtil.sendLang(sender, Languages.COMMAND_PLAYER_ONLY);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ public boolean onCommand(CommandSender sender, List<String> args) {
}
String recipeTypeStr = args.get(0).toLowerCase(Locale.ROOT);
if (!recipeTypeList.contains(recipeTypeStr)) {
LangUtil.sendLang(sender, Languages.COMMAND_CREATE_UNSUPPORTED_RECIPE_TYPE.value());
LangUtil.sendLang(sender, Languages.COMMAND_CREATE_UNSUPPORTED_RECIPE_TYPE);
return true;
}
String recipeName = args.get(1);
Matcher matcher = recipeNamePattern.matcher(recipeName);
if (!matcher.matches()) {
LangUtil.sendLang(sender, Languages.COMMAND_CREATE_UNSUPPORTED_RECIPE_NAME.value());
LangUtil.sendLang(sender, Languages.COMMAND_CREATE_UNSUPPORTED_RECIPE_NAME);
return true;
}
if (RecipeManager.INSTANCE.hasCraftorithmRecipe(recipeName)) {
LangUtil.sendLang(sender, Languages.COMMAND_CREATE_NAME_USED.value());
LangUtil.sendLang(sender, Languages.COMMAND_CREATE_NAME_USED);
return true;
}
RecipeType recipeType = RecipeType.valueOf(recipeTypeStr.toUpperCase(Locale.ROOT));
Expand All @@ -86,7 +86,7 @@ public boolean onCommand(CommandSender sender, List<String> args) {
new AnvilRecipeCreator(player, recipeName).openMenu();
break;
default:
LangUtil.sendLang(sender, Languages.COMMAND_CREATE_UNSUPPORTED_RECIPE_TYPE.value());
LangUtil.sendLang(sender, Languages.COMMAND_CREATE_UNSUPPORTED_RECIPE_TYPE);
break;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public boolean onCommand(CommandSender sender, List<String> args) {
}
NamespacedKey removeRecipeKey = NamespacedKey.fromString(args.get(0));
if (!RecipeManager.INSTANCE.serverRecipesCache().containsKey(removeRecipeKey)) {
LangUtil.sendLang(sender, Languages.COMMAND_DISABLE_NOT_EXIST.value());
LangUtil.sendLang(sender, Languages.COMMAND_DISABLE_NOT_EXIST);
return true;
}
List<NamespacedKey> removeRecipeKeys = Collections.singletonList(removeRecipeKey);
if (RecipeManager.INSTANCE.disableOtherPluginsRecipe(removeRecipeKeys, true)) {
LangUtil.sendLang(sender, Languages.COMMAND_DISABLE_SUCCESS.value());
LangUtil.sendLang(sender, Languages.COMMAND_DISABLE_SUCCESS);
}
else
LangUtil.sendLang(sender, Languages.COMMAND_DISABLE_FAILED.value());
LangUtil.sendLang(sender, Languages.COMMAND_DISABLE_FAILED);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private RecipeListCommand() {
@Override
public boolean onCommand(CommandSender sender, List<String> args) {
if (CrypticLib.minecraftVersion() < 11600) {
LangUtil.sendLang(sender, Languages.COMMAND_LIST_UNSUPPORTED_VERSION.value());
LangUtil.sendLang(sender, Languages.COMMAND_LIST_UNSUPPORTED_VERSION);
return true;
}
if (!checkSenderIsPlayer(sender)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ private ReloadCommand() {
public boolean onCommand(CommandSender sender, List<String> args) {
try {
reloadPlugin();
LangUtil.sendLang(sender, Languages.COMMAND_RELOAD_SUCCESS.value());
LangUtil.sendLang(sender, Languages.COMMAND_RELOAD_SUCCESS);
} catch (Exception e) {
e.printStackTrace();
LangUtil.sendLang(sender, Languages.COMMAND_RELOAD_EXCEPTION.value());
LangUtil.sendLang(sender, Languages.COMMAND_RELOAD_EXCEPTION);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public boolean onCommand(CommandSender sender, List<String> args) {
}

if (RecipeManager.INSTANCE.removeCraftorithmRecipe(args.get(0), true)) {
LangUtil.sendLang(sender, Languages.COMMAND_REMOVE_SUCCESS.value());
LangUtil.sendLang(sender, Languages.COMMAND_REMOVE_SUCCESS);
}
else
LangUtil.sendLang(sender, Languages.COMMAND_REMOVE_NOT_EXIST.value());
LangUtil.sendLang(sender, Languages.COMMAND_REMOVE_NOT_EXIST);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public boolean onCommand(CommandSender sender, List<String> args) {
}
ArcencielDispatcher.INSTANCE.dispatchArcencielBlock((Player) sender, arcencielBlock.toString());
long execTime = System.currentTimeMillis() - startTime;
LangUtil.sendLang(sender, Languages.COMMAND_RUN_ARCENCIEL_SUCCESS.value(), CollectionsUtil.newStringHashMap("<time>", String.valueOf(execTime)));
LangUtil.sendLang(sender, Languages.COMMAND_RUN_ARCENCIEL_SUCCESS, CollectionsUtil.newStringHashMap("<time>", String.valueOf(execTime)));
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private VersionCommand() {

@Override
public boolean onCommand(CommandSender sender, List<String> args) {
LangUtil.sendLang(sender, Languages.COMMAND_VERSION.value());
LangUtil.sendLang(sender, Languages.COMMAND_VERSION);
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public boolean onCommand(CommandSender sender, List<String> args) {
if (args.size() >= 2) {
player = Bukkit.getPlayer(args.get(1));
if (player == null) {
LangUtil.sendLang(sender, Languages.COMMAND_ITEM_GIVE_PLAYER_OFFLINE.value());
LangUtil.sendLang(sender, Languages.COMMAND_ITEM_GIVE_PLAYER_OFFLINE);
return true;
}
} else {
Expand All @@ -46,12 +46,12 @@ public boolean onCommand(CommandSender sender, List<String> args) {

ItemStack itemStack = CraftorithmItemProvider.INSTANCE.getItem(args.get(0));
if (itemStack == null) {
LangUtil.sendLang(sender, Languages.COMMAND_ITEM_GIVE_NOT_EXIST_ITEM.value(), CollectionsUtil.newStringHashMap("<item_name>", args.get(0)));
LangUtil.sendLang(sender, Languages.COMMAND_ITEM_GIVE_NOT_EXIST_ITEM, CollectionsUtil.newStringHashMap("<item_name>", args.get(0)));
return true;
}

player.getInventory().addItem(itemStack);
LangUtil.sendLang(sender, Languages.COMMAND_ITEM_GIVE_SUCCESS.value());
LangUtil.sendLang(sender, Languages.COMMAND_ITEM_GIVE_SUCCESS);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public boolean onCommand(CommandSender sender, List<String> args) {

ItemStack item = ((Player) sender).getInventory().getItemInMainHand();
if (item.getType().equals(Material.AIR)) {
LangUtil.sendLang(sender, Languages.COMMAND_ITEM_SAVE_FAILED_SAVE_AIR.value());
LangUtil.sendLang(sender, Languages.COMMAND_ITEM_SAVE_FAILED_SAVE_AIR);
return true;
}

CraftorithmItemProvider.INSTANCE.regCraftorithmItem(args.get(0), args.get(1), item.clone());
LangUtil.sendLang(sender, Languages.COMMAND_ITEM_SAVE_SUCCESS.value());
LangUtil.sendLang(sender, Languages.COMMAND_ITEM_SAVE_SUCCESS);
return true;
}

Expand Down
Loading

0 comments on commit f188fd7

Please sign in to comment.