加密翻译字段

This commit is contained in:
Light_Quanta 2025-02-27 16:04:56 +08:00
parent f634bddc37
commit d610b2b60a
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
4 changed files with 56 additions and 16 deletions

View file

@ -1,4 +1,4 @@
package com.atsuishio.superbwarfare.client.screens; package com.atsuishio.superbwarfare.client.screens.modsell;
import com.atsuishio.superbwarfare.config.client.ModSellWarningConfig; import com.atsuishio.superbwarfare.config.client.ModSellWarningConfig;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
@ -62,15 +62,16 @@ public class ModSellWarningScreen extends WarningScreen {
} }
} }
private static final Component TITLE = Component.translatable("multiplayer.superbwarfare.warning.title").withStyle(ChatFormatting.BOLD);
private static final Component CONTENT = Component.translatable("multiplayer.superbwarfare.warning.content");
private static final Component CHECK = Component.translatable("multiplayer.superbwarfare.warning.check");
private static final Component NARRATION = TITLE.copy().append("\n").append(CONTENT);
private final Screen lastScreen; private final Screen lastScreen;
private AbstractButton proceedButton; private AbstractButton proceedButton;
public ModSellWarningScreen(Screen lastScreen) { public ModSellWarningScreen(Screen lastScreen) {
super(TITLE, CONTENT, CHECK, NARRATION); super(
Component.literal(TranslationRecord.get(TranslationRecord.TITLE)).withStyle(ChatFormatting.BOLD),
Component.literal(TranslationRecord.get(TranslationRecord.CONTENT)),
Component.literal(TranslationRecord.get(TranslationRecord.CHECK)),
Component.literal(TranslationRecord.get(TranslationRecord.TITLE)).withStyle(ChatFormatting.BOLD).append("\n").append(Component.literal(TranslationRecord.get(TranslationRecord.CONTENT)))
);
this.lastScreen = lastScreen; this.lastScreen = lastScreen;
} }

View file

@ -0,0 +1,47 @@
package com.atsuishio.superbwarfare.client.screens.modsell;
import net.minecraft.client.Minecraft;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.util.HexFormat;
import java.util.Map;
public class TranslationRecord {
private static final String KEY = "26342ea7c1f2d105678e702dd95f3285c5e1e4ff18814f5f74946e4f02cfdc78";
public static final Map<String, String> CONTENT = Map.ofEntries(
Map.entry("zh_cn", "f07591350fc89b0ff0f7ddc537fefec2f62cbc5e80ea77467b09899754cd54067dea26eef69388d0eef680add46073380891915bbb53ac6902c8566d1ea6679652849a70b6e003e2d4c97efd714b4919bee266a8813aca3d9741dbbc0186a41d420aa3f5d0960ab3c01767f0d79eb06b58d019a3e6cdb94f07f5106c16da8ea19c4327448ac68b446ffeaae9dbd8be844d5858792b7ef2c2686205bde67726df54d05ba4d08481cd997e4d7bf001b2034f4748b5c05637d400bbd1797df3d7c13c45763868bc0261309d701fbd4d8dabe0fd5336d13cbc727bd2ba27fe958df77c9e0deb19f870561a27bce013645b1a825d05f2530680ace33b020cd3f3e7772a70758bfdd2fbdf88351c3e9db6a1dd9a4679ad402dea8bdd0566c4d9fe0a11"),
Map.entry("en_us", "f07591350fc89b0ff0f7ddc537fefec2f62cbc5e80ea77467b09899754cd54067dea26eef69388d0eef680add46073380891915bbb53ac6902c8566d1ea6679652849a70b6e003e2d4c97efd714b4919bee266a8813aca3d9741dbbc0186a41d420aa3f5d0960ab3c01767f0d79eb06b58d019a3e6cdb94f07f5106c16da8ea19c4327448ac68b446ffeaae9dbd8be844d5858792b7ef2c2686205bde67726df54d05ba4d08481cd997e4d7bf001b2034f4748b5c05637d400bbd1797df3d7c13c45763868bc0261309d701fbd4d8dabe0fd5336d13cbc727bd2ba27fe958df77c9e0deb19f870561a27bce013645b1a825d05f2530680ace33b020cd3f3e7772a70758bfdd2fbdf88351c3e9db6a1dd9a4679ad402dea8bdd0566c4d9fe0a11")
);
public static final Map<String, String> TITLE = Map.ofEntries(
Map.entry("zh_cn", "f47aedcdf60b4ca63eed627b93e3d8d873638f82479c7ca3846b3f1939ad7e2f"),
Map.entry("en_us", "f47aedcdf60b4ca63eed627b93e3d8d873638f82479c7ca3846b3f1939ad7e2f")
);
public static final Map<String, String> CHECK = Map.ofEntries(
Map.entry("zh_cn", "f1eb77633be9e73e04e6f3452d3869fa2b849438b1e0bf738d61452c182c5e26c9d86d259e20a88505ad262d9daf8c1d"),
Map.entry("en_us", "f1eb77633be9e73e04e6f3452d3869fa2b849438b1e0bf738d61452c182c5e26c9d86d259e20a88505ad262d9daf8c1d")
);
public static String get(Map<String, String> map) {
try {
var selectedLanguage = Minecraft.getInstance().getLanguageManager().getSelected();
var encryptedContent = map.get(selectedLanguage);
if (encryptedContent == null) {
encryptedContent = map.get("en_us");
}
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(HexFormat.of().parseHex(KEY), "AES"));
byte[] encrypted = cipher.doFinal(HexFormat.of().parseHex(encryptedContent));
return new String(encrypted, StandardCharsets.UTF_8);
} catch (Exception e) {
System.err.println(e.getMessage());
throw new IllegalStateException("SuperbWarfare warning screen translation broken, exiting");
}
}
}

View file

@ -525,9 +525,5 @@
"config.jade.plugin_superbwarfare.vehicle_energy": "Vehicle Energy", "config.jade.plugin_superbwarfare.vehicle_energy": "Vehicle Energy",
"config.jade.plugin_superbwarfare.vehicle_health": "Vehicle Health", "config.jade.plugin_superbwarfare.vehicle_health": "Vehicle Health",
"config.jade.plugin_superbwarfare.container_entity": "Container Entity", "config.jade.plugin_superbwarfare.container_entity": "Container Entity"
"multiplayer.superbwarfare.warning.title": "【卓越前线 警示声明】",
"multiplayer.superbwarfare.warning.content": "== 本模组完全免费开源,禁止用于任何商业行为 ==\n本模组代码采用GPL-3协议开源美术资源私有禁止商用\n禁止付费下载、充值获取道具等违反协议和Mojang EULA的行为\n如遇以上行为请到本模组仓库处提交Issue进行举报",
"multiplayer.superbwarfare.warning.check": "我已阅读并同意,不再显示此警告"
} }

View file

@ -525,9 +525,5 @@
"config.jade.plugin_superbwarfare.vehicle_energy": "载具能量", "config.jade.plugin_superbwarfare.vehicle_energy": "载具能量",
"config.jade.plugin_superbwarfare.vehicle_health": "载具血量", "config.jade.plugin_superbwarfare.vehicle_health": "载具血量",
"config.jade.plugin_superbwarfare.container_entity": "集装箱实体", "config.jade.plugin_superbwarfare.container_entity": "集装箱实体"
"multiplayer.superbwarfare.warning.title": "【卓越前线 警示声明】",
"multiplayer.superbwarfare.warning.content": "== 本模组完全免费开源,禁止用于任何商业行为 ==\n本模组代码采用GPL-3协议开源美术资源私有禁止商用\n禁止付费下载、充值获取道具等违反协议和Mojang EULA的行为\n如遇以上行为请到本模组仓库处提交Issue进行举报",
"multiplayer.superbwarfare.warning.check": "我已阅读并同意,不再显示此警告"
} }