From 424a511cfdbf17ccdd71680d88d7ae1830096e08 Mon Sep 17 00:00:00 2001 From: Wulian233 <71213467+Wulian233@users.noreply.github.com> Date: Sun, 10 Sep 2023 20:00:52 +0800 Subject: [PATCH] Add files via upload --- .../vmctcn/vmtranslationupdate/VMTranslationUpdate.java | 5 +++-- .../vmtranslationupdate/util/PackDownloadUtil.java | 4 ++++ .../top/vmctcn/vmtranslationupdate/util/TipsUtil.java | 3 +++ .../vmtranslationupdate/util/VersionCheckUtil.java | 2 +- .../resources/assets/vmtranslationupdate/lang/en_us.json | 9 +++++---- .../resources/assets/vmtranslationupdate/lang/zh_cn.json | 3 ++- .../resources/assets/vmtranslationupdate/lang/zh_tw.json | 5 +++-- fabric/src/main/resources/fabric.mod.json | 2 +- forge/src/main/resources/META-INF/mods.toml | 2 +- gradle.properties | 2 +- 10 files changed, 24 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/top/vmctcn/vmtranslationupdate/VMTranslationUpdate.java b/common/src/main/java/top/vmctcn/vmtranslationupdate/VMTranslationUpdate.java index 142ba84..2f7b70a 100644 --- a/common/src/main/java/top/vmctcn/vmtranslationupdate/VMTranslationUpdate.java +++ b/common/src/main/java/top/vmctcn/vmtranslationupdate/VMTranslationUpdate.java @@ -53,7 +53,7 @@ public static void init() { PlayerEvent.PLAYER_JOIN.register((player) -> { String localVersion = ModConfigUtil.getConfig().translationVersion; - String onlineVersion = VersionCheckUtil.getOnlineVersion(player).substring(0,5); + String onlineVersion = VersionCheckUtil.getOnlineVersion(player); String name = player.getName().getString(); if (name.equals("Zi__Min")) { @@ -75,7 +75,8 @@ public static void init() { player.sendSystemMessage(message, Util.NIL_UUID); } - if (new File(PackDownloadUtil.resourcePackDir.toFile(), PackDownloadUtil.resourcePackName).exists() &&!client.options.resourcePacks.contains(PackDownloadUtil.resourcePackName) && !client.options.resourcePacks.contains("file/" + PackDownloadUtil.resourcePackName)) { + if (new File(PackDownloadUtil.resourcePackDir.toFile(), PackDownloadUtil.resourcePackName).exists() + &&!client.options.resourcePacks.contains(PackDownloadUtil.resourcePackName) && !client.options.resourcePacks.contains("file/" + PackDownloadUtil.resourcePackName)) { Text message = new TranslatableText("vmtranslationupdate.message.pack", ModConfigUtil.getConfig().packName).setStyle(Style.EMPTY.withColor(Formatting.GOLD)); player.sendSystemMessage(message, Util.NIL_UUID); } diff --git a/common/src/main/java/top/vmctcn/vmtranslationupdate/util/PackDownloadUtil.java b/common/src/main/java/top/vmctcn/vmtranslationupdate/util/PackDownloadUtil.java index 940e2c2..e4d6136 100644 --- a/common/src/main/java/top/vmctcn/vmtranslationupdate/util/PackDownloadUtil.java +++ b/common/src/main/java/top/vmctcn/vmtranslationupdate/util/PackDownloadUtil.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.net.URLConnection; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; @@ -55,6 +56,9 @@ public static void downloadResPack() { public static void downloadResPackFile(Path savePath) throws IOException { URL url = new URL(ModConfigUtil.getConfig().packUrl + ".zip"); + URLConnection connection = url.openConnection(); + connection.setConnectTimeout(10000); + try (InputStream in = url.openStream()) { Files.copy(in, savePath, StandardCopyOption.REPLACE_EXISTING); } diff --git a/common/src/main/java/top/vmctcn/vmtranslationupdate/util/TipsUtil.java b/common/src/main/java/top/vmctcn/vmtranslationupdate/util/TipsUtil.java index 2b525f0..47ecc59 100644 --- a/common/src/main/java/top/vmctcn/vmtranslationupdate/util/TipsUtil.java +++ b/common/src/main/java/top/vmctcn/vmtranslationupdate/util/TipsUtil.java @@ -6,6 +6,7 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; +import java.net.URLConnection; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -26,6 +27,8 @@ public static String getRandomMessageFromURL(String tipsUrl) { public static void loadMessagesFromURL(String tipsUrl) { try { URL url = new URL(tipsUrl); + URLConnection connection = url.openConnection(); + connection.setConnectTimeout(10000); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8)); String line; while ((line = reader.readLine()) != null) { diff --git a/common/src/main/java/top/vmctcn/vmtranslationupdate/util/VersionCheckUtil.java b/common/src/main/java/top/vmctcn/vmtranslationupdate/util/VersionCheckUtil.java index 49b80a2..49a18ea 100644 --- a/common/src/main/java/top/vmctcn/vmtranslationupdate/util/VersionCheckUtil.java +++ b/common/src/main/java/top/vmctcn/vmtranslationupdate/util/VersionCheckUtil.java @@ -16,9 +16,9 @@ public static String getOnlineVersion(PlayerEntity player) { URL url = new URL(ModConfigUtil.getConfig().updateUrl); URLConnection connection = url.openConnection(); - connection.setConnectTimeout(10000); String userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.5414.120 Safari/537.36 MCMod/VmUpdate"; connection.setRequestProperty("User-Agent", userAgent); + connection.setConnectTimeout(10000); try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) { return reader.readLine(); diff --git a/common/src/main/resources/assets/vmtranslationupdate/lang/en_us.json b/common/src/main/resources/assets/vmtranslationupdate/lang/en_us.json index 1c3469d..64c16c8 100644 --- a/common/src/main/resources/assets/vmtranslationupdate/lang/en_us.json +++ b/common/src/main/resources/assets/vmtranslationupdate/lang/en_us.json @@ -3,18 +3,19 @@ "vmtranslationupdate.message.update2": "Please click on the right ", "vmtranslationupdate.message.update3": " to download the new version.", "vmtranslationupdate.message.error": "[VM Chinese Group]: Error! There is an issue with the Chinese localization update detection.", - "vmtranslationupdate.message.hover": "Click me to download the new version on the official website!", + "vmtranslationupdate.message.hover": "Click me to download the new version!", "vmtranslationupdate.message.zimin": "Welcome to ZiMin's Minecraft world!", - "vmtranslationupdate.message.pack": "VM Chinese update auto reprint failed! Please enable \"%s\" packages manually in \"Options -> Resource Packs\".", + "vmtranslationupdate.message.pack": "VM Chinese Update auto enable localization failed! Please enable \"%s\" pack manually in \"Options -> Resource Packs\".", "text.autoconfig.vmtranslationupdate.title": "VM Translation Update Config", + "text.autoconfig.vmtranslationupdate.option.autoSwitchLanguage": "Auto switch languages by region", "text.autoconfig.vmtranslationupdate.option.updateUrl": "Update link", "text.autoconfig.vmtranslationupdate.option.downloadUrl": "Download link", "text.autoconfig.vmtranslationupdate.option.tipsUrl": "Get knowledge link", - "text.autoconfig.vmtranslationupdate.option.translationVersion": "Modpack Version", + "text.autoconfig.vmtranslationupdate.option.translationVersion": "Modpack translation version", "text.autoconfig.vmtranslationupdate.option.minutes": "Time interval for sending knowledge (minutes)", "text.autoconfig.vmtranslationupdate.option.packUrl": "Download resource pack link", "text.autoconfig.vmtranslationupdate.option.packName": "File name of the resource pack", - "modmenu.descriptionTranslation.vmtranslationupdate": "A mod for checking for updates to VMChineseTranslationGroup's localization patches and automatically downloading resource packs." + "modmenu.descriptionTranslation.vmtranslationupdate": "A mod for checking for updates to VM Chinese Group's localization patches and automatically downloading resource packs." } \ No newline at end of file diff --git a/common/src/main/resources/assets/vmtranslationupdate/lang/zh_cn.json b/common/src/main/resources/assets/vmtranslationupdate/lang/zh_cn.json index d119c3b..b46d930 100644 --- a/common/src/main/resources/assets/vmtranslationupdate/lang/zh_cn.json +++ b/common/src/main/resources/assets/vmtranslationupdate/lang/zh_cn.json @@ -5,9 +5,10 @@ "vmtranslationupdate.message.error": "[VM汉化组]:错误!汉化更新检测出现问题。", "vmtranslationupdate.message.hover": "点我到官网下载新版本!", "vmtranslationupdate.message.zimin": "欢迎来到籽岷的Minecraft游戏世界!", - "vmtranslationupdate.message.pack": "VM汉化更新自动转载失败!请在 “选项 -> 资源包” 中手动启用 “%s” 资源包", + "vmtranslationupdate.message.pack": "VM汉化更新自动启用汉化失败!请在 “选项 -> 资源包” 中手动启用 “%s” 资源包", "text.autoconfig.vmtranslationupdate.title": "VM汉化更新检测配置", + "text.autoconfig.vmtranslationupdate.option.autoSwitchLanguage": "自动根据地区切换语言", "text.autoconfig.vmtranslationupdate.option.updateUrl": "更新检测链接", "text.autoconfig.vmtranslationupdate.option.downloadUrl": "下载链接", "text.autoconfig.vmtranslationupdate.option.tipsUrl": "获取知识内容的链接", diff --git a/common/src/main/resources/assets/vmtranslationupdate/lang/zh_tw.json b/common/src/main/resources/assets/vmtranslationupdate/lang/zh_tw.json index f3656ed..8400ec7 100644 --- a/common/src/main/resources/assets/vmtranslationupdate/lang/zh_tw.json +++ b/common/src/main/resources/assets/vmtranslationupdate/lang/zh_tw.json @@ -5,9 +5,10 @@ "vmtranslationupdate.message.error": "[VM漢化組]:錯誤!漢化更新檢測出現問題。", "vmtranslationupdate.message.hover": "點我到官網下載新版本!", "vmtranslationupdate.message.zimin": "歡迎來到籽岷的Minecraft遊戲世界!", - "vmtranslationupdate.message.pack": "VM漢化更新自動轉載失敗!請在 「選項 -> 資源包」 中手動啟用 「%s」 資源包", + "vmtranslationupdate.message.pack": "VM漢化更新自動啟用漢化失敗!請在 「選項 -> 資源包」 中手動啟用 「%s」 資源包", "text.autoconfig.vmtranslationupdate.title": "VM漢化更新檢測配寘", + "text.autoconfig.vmtranslationupdate.option.autoSwitchLanguage": "自動根據地區切換語言", "text.autoconfig.vmtranslationupdate.option.updateUrl": "更新檢測鏈接", "text.autoconfig.vmtranslationupdate.option.downloadUrl": "下載鏈接", "text.autoconfig.vmtranslationupdate.option.tipsUrl": "獲取知識內容的鏈接", @@ -16,5 +17,5 @@ "text.autoconfig.vmtranslationupdate.option.packUrl": "下載資源包的連結", "text.autoconfig.vmtranslationupdate.option.packName": "資源包的名字", - "modmenu.descriptionTranslation.vmtranslationupdate": "一個用於檢查VMChineseTranslationGroup的漢化補丁更新和自動下載資源包的模組。" + "modmenu.descriptionTranslation.vmtranslationupdate": "一個用於檢查VM漢化組的漢化補丁更新和自動下載資源包的模組。" } \ No newline at end of file diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 89e48ed..425ca90 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -3,7 +3,7 @@ "id": "vmtranslationupdate", "version": "${version}", "name": "VM Translation Update", - "description": "A mod for checking for updates to VMChineseTranslationGroup's localization patches and automatically downloading resource packs.", + "description": "A mod for checking for updates to VM Chinese Group's localization patches and automatically downloading resource packs.", "authors": [ "Wulian233", "TexTrue", "Litchiiiiiii" ], diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index d2dabf0..fc10a62 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -10,7 +10,7 @@ displayName = "VM Translation Update" displayURL = "https://github.com/VM-Chinese-translate-group/VM-Chinese-Group-Update" authors = "Wulian233, TexTrue, Litchiiiiiii" description = ''' -A mod for checking for updates to VMChineseTranslationGroup's localization patches +A mod for checking for updates to VM Chinese Group's localization patches and automatically downloading resource packs. 一个用于检查汉化补丁更新和自动下载资源包的模组。 diff --git a/gradle.properties b/gradle.properties index b72d1ec..a528deb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ enabled_platforms=fabric,forge yarn_mappings=1.18.2+build.4 archives_base_name=VMTranslationUpdate -mod_version=2.0.1 +mod_version=2.1.0 maven_group=top.vmctcn architectury_version=4.11.93