Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Wulian233 authored Sep 10, 2023
1 parent 6af3208 commit 424a511
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
Original file line number Diff line number Diff line change
Expand Up @@ -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": "获取知识内容的链接",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "獲取知識內容的鏈接",
Expand All @@ -16,5 +17,5 @@
"text.autoconfig.vmtranslationupdate.option.packUrl": "下載資源包的連結",
"text.autoconfig.vmtranslationupdate.option.packName": "資源包的名字",

"modmenu.descriptionTranslation.vmtranslationupdate": "一個用於檢查VMChineseTranslationGroup的漢化補丁更新和自動下載資源包的模組"
"modmenu.descriptionTranslation.vmtranslationupdate": "一個用於檢查VM漢化組的漢化補丁更新和自動下載資源包的模組"
}
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
一个用于检查汉化补丁更新和自动下载资源包的模组。
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 424a511

Please sign in to comment.