mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-12 05:16:13 -04:00
忽略版本更新功能
This commit is contained in:
parent
3afff687b2
commit
b2ea6d449e
@ -194,7 +194,10 @@ public final class Main implements Runnable {
|
||||
}
|
||||
|
||||
public static void invokeUpdate() {
|
||||
MainFrame.INSTANCE.invokeUpdate();
|
||||
if (!Settings.getInstance().ignoreUpdate(
|
||||
Settings.UPDATE_CHECKER.getNewVersion() )) {
|
||||
MainFrame.INSTANCE.invokeUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public static ImageIcon getIcon(String path) {
|
||||
|
@ -28,6 +28,8 @@ import java.util.UUID;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
|
||||
import org.jackhuang.hellominecraft.lookandfeel.Theme;
|
||||
import org.jackhuang.hellominecraft.util.EventHandler;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.util.VersionNumber;
|
||||
import org.jackhuang.hellominecraft.util.system.JdkVersion;
|
||||
import org.jackhuang.hellominecraft.util.system.OS;
|
||||
|
||||
@ -72,10 +74,35 @@ public final class Config implements Cloneable {
|
||||
@SerializedName("auth")
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
private Map<String, Map> auth;
|
||||
|
||||
@SerializedName("ignoreUpdateVersion")
|
||||
private String ignoreUpdateVersion;
|
||||
|
||||
public List<JdkVersion> getJava() {
|
||||
return java == null ? java = new ArrayList<>() : java;
|
||||
}
|
||||
|
||||
public boolean ignoreUpdate(VersionNumber versionNumber) {
|
||||
boolean ignore = false;
|
||||
do
|
||||
{
|
||||
if (StrUtils.isBlank(ignoreUpdateVersion))
|
||||
continue;
|
||||
|
||||
VersionNumber ignoreVersion = VersionNumber.check(ignoreUpdateVersion);
|
||||
if (ignoreVersion == null)
|
||||
continue;
|
||||
|
||||
if (versionNumber.compareTo(ignoreVersion) == 0)
|
||||
ignore = true;
|
||||
|
||||
} while(false);
|
||||
return ignore;
|
||||
}
|
||||
|
||||
public void setIgnoreUpdate(VersionNumber versionNumber) {
|
||||
ignoreUpdateVersion = versionNumber.toString();
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public transient final EventHandler<Theme> themeChangedEvent = new EventHandler<>(this);
|
||||
public transient final EventHandler<DownloadType> downloadTypeChangedEvent = new EventHandler<>(this);
|
||||
|
@ -36,6 +36,7 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||
|
||||
@ -55,7 +56,7 @@ public class RecommendPanel extends JPanel {
|
||||
public RecommendPanel() {
|
||||
recommends = new ArrayList<RecommendInfo>();
|
||||
new LoadImages().execute();
|
||||
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
@ -179,6 +180,7 @@ public class RecommendPanel extends JPanel {
|
||||
public void setImage(String key, Image image) {
|
||||
this.imageKey = key;
|
||||
this.currImage = image;
|
||||
setToolTipText(C.i18n("ui.message.recommend_tip"));
|
||||
setSize(image.getWidth(this), image.getHeight(this));
|
||||
SwingUtilities.updateComponentTreeUI(this.getRootPane());
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ import java.util.jar.JarFile;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.jar.Pack200;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import javax.swing.JCheckBox;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.core.MCUtils;
|
||||
@ -100,18 +101,32 @@ public class AppDataUpgrader extends IUpgrader {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean askUpdateVersion(VersionNumber versionNumber) {
|
||||
if (!Settings.UPDATE_CHECKER.isManualUpdate() &&
|
||||
Settings.getInstance().ignoreUpdate(versionNumber))
|
||||
return false;
|
||||
|
||||
String content = C.i18n("update.newest_version") +
|
||||
versionNumber.firstVer + "." + versionNumber.secondVer + "." +
|
||||
versionNumber.thirdVer + "\n" +
|
||||
C.i18n("update.should_open_link");
|
||||
JCheckBox checkbox = new JCheckBox(C.i18n("update.ignore"));
|
||||
int ret = MessageBox.Show(new Object[]{content, checkbox}, MessageBox.YES_NO_OPTION);
|
||||
if (ret == MessageBox.NO_OPTION) {
|
||||
Settings.getInstance().setIgnoreUpdate(versionNumber);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean call(Object sender, final VersionNumber number) {
|
||||
((UpdateChecker) sender).requestDownloadLink().reg(new Consumer<Map<String, String>>() {
|
||||
@Override
|
||||
public void accept(Map<String, String> map) {
|
||||
boolean isForceUpdate = Settings.UPDATE_CHECKER.isForceUpdate();
|
||||
if (isForceUpdate || MessageBox.Show(C.i18n("update.newest_version") +
|
||||
number.firstVer + "." +
|
||||
number.secondVer + "." +
|
||||
number.thirdVer + "\n" +
|
||||
C.i18n("update.should_open_link"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
if (isForceUpdate || askUpdateVersion(number))
|
||||
if (map != null && map.containsKey("pack"))
|
||||
try {
|
||||
String hash = null;
|
||||
|
@ -32,6 +32,8 @@ public interface IUpdateChecker {
|
||||
|
||||
boolean isForceUpdate();
|
||||
|
||||
boolean isManualUpdate();
|
||||
|
||||
/**
|
||||
* Get the <b>cached</b> newest version number, use "process" method to
|
||||
* download!
|
||||
|
@ -86,23 +86,23 @@ public class MessageBox {
|
||||
/**
|
||||
* Show MsgBox with title and options
|
||||
*
|
||||
* @param Msg The Message
|
||||
* @param Title The title of MsgBox.
|
||||
* @param Option The type of MsgBox.
|
||||
* @param msg The Message
|
||||
* @param title The title of MsgBox.
|
||||
* @param optionType The type of MsgBox.
|
||||
*
|
||||
* @return user operation.
|
||||
*/
|
||||
public static int Show(String Msg, String Title, int Option) {
|
||||
switch (Option) {
|
||||
public static int Show(Object msg, String title, int optionType) {
|
||||
switch (optionType) {
|
||||
case YES_NO_OPTION:
|
||||
case YES_NO_CANCEL_OPTION:
|
||||
case OK_CANCEL_OPTION:
|
||||
return SwingUtils.invokeAndWait(() -> JOptionPane.showConfirmDialog(null, Msg, Title, Option - 10));
|
||||
return SwingUtils.invokeAndWait(() -> JOptionPane.showConfirmDialog(null, msg, title, optionType - 10));
|
||||
default:
|
||||
SwingUtils.invokeAndWait(() -> JOptionPane.showMessageDialog(null, Msg, Title, Option));
|
||||
SwingUtils.invokeAndWait(() -> JOptionPane.showMessageDialog(null, msg, title, optionType));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show MsgBox with options
|
||||
@ -112,8 +112,8 @@ public class MessageBox {
|
||||
*
|
||||
* @return User Operation
|
||||
*/
|
||||
public static int Show(String Msg, int Option) {
|
||||
return Show(Msg, TITLE, Option);
|
||||
public static int Show(Object msg, int optionType) {
|
||||
return Show(msg, TITLE, optionType);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,8 +123,8 @@ public class MessageBox {
|
||||
*
|
||||
* @return User Operation
|
||||
*/
|
||||
public static int Show(String Msg) {
|
||||
return Show(Msg, TITLE, INFORMATION_MESSAGE);
|
||||
public static int Show(Object msg) {
|
||||
return Show(msg, TITLE, INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
public static int ShowLocalized(String msg) {
|
||||
|
@ -29,13 +29,13 @@ public final class UpdateChecker implements IUpdateChecker {
|
||||
public static final String VERSION_URL = "http://client.api.mcgogogo.com:81/version.php?type=";
|
||||
public static final String UPDATE_LINK_URL = "http://client.api.mcgogogo.com:81/update_link.php?type=";
|
||||
|
||||
|
||||
public boolean OUT_DATED = false;
|
||||
|
||||
public String versionString;
|
||||
public VersionNumber base;
|
||||
private VersionNumber value;
|
||||
private boolean isforceUpdate = false;
|
||||
private boolean isManualUpdate = false;
|
||||
|
||||
public String type;
|
||||
private Map<String, String> download_link = null;
|
||||
@ -50,6 +50,8 @@ public final class UpdateChecker implements IUpdateChecker {
|
||||
return new OverridableSwingWorker() {
|
||||
@Override
|
||||
protected void work() throws Exception {
|
||||
isManualUpdate = showMessage;
|
||||
|
||||
if (value == null) {
|
||||
versionString = NetUtils.get(VERSION_URL + type);
|
||||
Map<String, Object> versionInfo = C.GSON.fromJson(versionString, Map.class);
|
||||
@ -58,15 +60,19 @@ public final class UpdateChecker implements IUpdateChecker {
|
||||
if (versionInfo.containsKey("force"))
|
||||
isforceUpdate = (boolean)versionInfo.get("force");
|
||||
}
|
||||
|
||||
|
||||
if (value == null) {
|
||||
HMCLog.warn("Failed to check update...");
|
||||
if (showMessage)
|
||||
if (showMessage) {
|
||||
MessageBox.Show(C.i18n("update.failed"));
|
||||
} else if (VersionNumber.isOlder(base, value))
|
||||
}
|
||||
} else if (VersionNumber.isOlder(base, value)) {
|
||||
OUT_DATED = true;
|
||||
if (OUT_DATED)
|
||||
}
|
||||
|
||||
if (OUT_DATED) {
|
||||
publish(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -81,6 +87,11 @@ public final class UpdateChecker implements IUpdateChecker {
|
||||
return isforceUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isManualUpdate() {
|
||||
return isManualUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized OverridableSwingWorker<Map<String, String>> requestDownloadLink() {
|
||||
return new OverridableSwingWorker() {
|
||||
|
@ -168,6 +168,7 @@ ui.message.launching=启动中
|
||||
ui.message.making=生成中
|
||||
ui.message.sure_remove=真的要删除配置%s吗?
|
||||
ui.message.update_java=请更新您的Java
|
||||
ui.message.recommend_tip=点击打开链接
|
||||
|
||||
ui.label.settings=选项
|
||||
ui.label.crashing=<html>Hello Minecraft!遇到了无法处理的错误,请复制下列内容并通过mcbbs、贴吧、Github或Minecraft Forum反馈bug。</html>
|
||||
@ -369,6 +370,7 @@ update.should_open_link=是否更新?
|
||||
update.newest_version=最新版本为:
|
||||
update.failed=检查更新失败
|
||||
update.found=(发现更新!)
|
||||
update.ignore=不再提醒此版本更新
|
||||
|
||||
logwindow.terminate_game=结束游戏进程
|
||||
logwindow.tieba=贴吧
|
||||
|
@ -168,6 +168,7 @@ ui.message.launching=\u542f\u52a8\u4e2d
|
||||
ui.message.making=\u751f\u6210\u4e2d
|
||||
ui.message.sure_remove=\u771f\u7684\u8981\u5220\u9664\u914d\u7f6e%s\u5417\uff1f
|
||||
ui.message.update_java=\u8bf7\u66f4\u65b0\u60a8\u7684Java
|
||||
ui.message.recommend_tip=\u70b9\u51fb\u6253\u5f00\u94fe\u63a5
|
||||
|
||||
ui.label.settings=\u9009\u9879
|
||||
ui.label.crashing=<html>Hello Minecraft!\u9047\u5230\u4e86\u65e0\u6cd5\u5904\u7406\u7684\u9519\u8bef\uff0c\u8bf7\u590d\u5236\u4e0b\u5217\u5185\u5bb9\u5e76\u901a\u8fc7mcbbs\u3001\u8d34\u5427\u3001Github\u6216Minecraft Forum\u53cd\u9988bug\u3002</html>
|
||||
@ -369,6 +370,7 @@ update.should_open_link=\u662f\u5426\u66f4\u65b0\uff1f
|
||||
update.newest_version=\u6700\u65b0\u7248\u672c\u4e3a\uff1a
|
||||
update.failed=\u68c0\u67e5\u66f4\u65b0\u5931\u8d25
|
||||
update.found=(\u53d1\u73b0\u66f4\u65b0!)
|
||||
update.ignore=\u4e0d\u518d\u63d0\u9192\u6b64\u7248\u672c\u66f4\u65b0
|
||||
|
||||
logwindow.terminate_game=\u7ed3\u675f\u6e38\u620f\u8fdb\u7a0b
|
||||
logwindow.tieba=\u8d34\u5427
|
||||
|
@ -168,6 +168,7 @@ ui.message.launching=Launching...
|
||||
ui.message.making=Generating...
|
||||
ui.message.sure_remove=Sure to remove profile %s?
|
||||
ui.message.update_java=Please upgrade your Java.
|
||||
ui.message.recommend_tip=Click to open link
|
||||
|
||||
ui.label.settings=Settings
|
||||
ui.label.crashing=<html>Hello Minecraft! Launcher has crashed!</html>
|
||||
@ -369,6 +370,7 @@ update.should_open_link=Are you willing to upgrade this app?
|
||||
update.newest_version=Newest version:
|
||||
update.failed=Failed to check for updates.
|
||||
update.found=(Found Update!)
|
||||
update.ignore=Do not remind this version update.
|
||||
|
||||
logwindow.terminate_game=Terminate Game
|
||||
logwindow.tieba=Baidu Tieba
|
||||
|
@ -168,6 +168,7 @@ ui.message.launching=Launching...
|
||||
ui.message.making=Generating...
|
||||
ui.message.sure_remove=Sure to remove profile %s?
|
||||
ui.message.update_java=Please upgrade your Java.
|
||||
ui.message.recommend_tip=Click to open link
|
||||
|
||||
ui.label.settings=Settings
|
||||
ui.label.crashing=<html>Hello Minecraft! Launcher has crashed!</html>
|
||||
@ -369,6 +370,7 @@ update.should_open_link=Are you willing to upgrade this app?
|
||||
update.newest_version=Newest version:
|
||||
update.failed=Failed to check for updates.
|
||||
update.found=(Found Update!)
|
||||
update.ignore=Do not remind this version update.
|
||||
|
||||
logwindow.terminate_game=Terminate Game
|
||||
logwindow.tieba=Baidu Tieba
|
||||
|
@ -168,6 +168,7 @@ ui.message.launching=啟動中
|
||||
ui.message.making=生成中
|
||||
ui.message.sure_remove=真的要删除配置%s吗?
|
||||
ui.message.update_java=请更新您的Java
|
||||
ui.message.recommend_tip=點擊打開連接
|
||||
|
||||
ui.label.settings=選項
|
||||
ui.label.crashing=<html>Hello Minecraft! Launcher遇到了無法處理的錯誤,請複制下列內容並通過mcbbs、貼吧或Minecraft Forum反饋bug。 </html>
|
||||
@ -369,6 +370,7 @@ update.should_open_link=是否更新?
|
||||
update.newest_version=最新版本為:
|
||||
update.failed=檢查更新失敗
|
||||
update.found=(發現更新!)
|
||||
update.ignore=不再提醒此版本更新
|
||||
|
||||
logwindow.terminate_game=結束遊戲進程
|
||||
logwindow.tieba=貼吧
|
||||
|
@ -168,6 +168,7 @@ ui.message.launching=\u555f\u52d5\u4e2d
|
||||
ui.message.making=\u751f\u6210\u4e2d
|
||||
ui.message.sure_remove=\u771f\u7684\u8981\u5220\u9664\u914d\u7f6e%s\u5417\uff1f
|
||||
ui.message.update_java=\u8bf7\u66f4\u65b0\u60a8\u7684Java
|
||||
ui.message.recommend_tip=\u9ede\u64ca\u6253\u958b\u9023\u63a5
|
||||
|
||||
ui.label.settings=\u9078\u9805
|
||||
ui.label.crashing=<html>Hello Minecraft! Launcher\u9047\u5230\u4e86\u7121\u6cd5\u8655\u7406\u7684\u932f\u8aa4\uff0c\u8acb\u8907\u5236\u4e0b\u5217\u5167\u5bb9\u4e26\u901a\u904emcbbs\u3001\u8cbc\u5427\u6216Minecraft Forum\u53cd\u994bbug\u3002 </html>
|
||||
@ -369,6 +370,7 @@ update.should_open_link=\u662f\u5426\u66f4\u65b0\uff1f
|
||||
update.newest_version=\u6700\u65b0\u7248\u672c\u70ba\uff1a
|
||||
update.failed=\u6aa2\u67e5\u66f4\u65b0\u5931\u6557
|
||||
update.found=(\u767c\u73fe\u66f4\u65b0!)
|
||||
update.ignore=\u4e0d\u518d\u63d0\u9192\u6b64\u7248\u672c\u66f4\u65b0
|
||||
|
||||
logwindow.terminate_game=\u7d50\u675f\u904a\u6232\u9032\u7a0b
|
||||
logwindow.tieba=\u8cbc\u5427
|
||||
|
Loading…
x
Reference in New Issue
Block a user