mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-03-07 17:36:52 +08:00
crash report uploading system & fix crashing when no version here.
This commit is contained in:
parent
70f0383b1d
commit
f63f888daf
@ -28,7 +28,7 @@ if (!hasProperty('mainClass')) {
|
||||
def buildnumber = System.getenv("BUILD_NUMBER") == null ? "" : "."+System.getenv("BUILD_NUMBER")
|
||||
|
||||
String mavenGroupId = 'HMCL'
|
||||
String mavenVersion = '2.3.3' + buildnumber
|
||||
String mavenVersion = '2.3.4' + buildnumber
|
||||
String bundleName = "Hello Minecraft! Launcher"
|
||||
|
||||
group = mavenGroupId
|
||||
|
5565
HMCL/obfuscate_2.3.4.map
Normal file
5565
HMCL/obfuscate_2.3.4.map
Normal file
File diff suppressed because it is too large
Load Diff
@ -27,6 +27,7 @@ import java.net.PasswordAuthentication;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Map;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
@ -44,6 +45,7 @@ import org.jackhuang.hellominecraft.launcher.views.MainFrame;
|
||||
import org.jackhuang.hellominecraft.lookandfeel.HelloMinecraftLookAndFeel;
|
||||
import org.jackhuang.hellominecraft.utils.system.MessageBox;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
import org.jackhuang.hellominecraft.utils.system.OS;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -52,7 +54,7 @@ import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
public final class Main implements NonConsumer {
|
||||
|
||||
public static String launcherName = "Hello Minecraft! Launcher";
|
||||
public static byte firstVer = 2, secondVer = 3, thirdVer = 3;
|
||||
public static byte firstVer = 2, secondVer = 3, thirdVer = 4;
|
||||
public static int minimumLauncherVersion = 16;
|
||||
|
||||
/**
|
||||
@ -126,17 +128,25 @@ public final class Main implements NonConsumer {
|
||||
public static void update() {
|
||||
if (MessageBox.Show(C.i18n("update.newest_version") + Settings.UPDATE_CHECKER.getNewVersion().firstVer + "." + Settings.UPDATE_CHECKER.getNewVersion().secondVer + "." + Settings.UPDATE_CHECKER.getNewVersion().thirdVer + "\n"
|
||||
+ C.i18n("update.should_open_link"),
|
||||
MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
||||
Map<String, String> map = Settings.UPDATE_CHECKER.download_link;
|
||||
String url = C.URL_PUBLISH;
|
||||
if (map != null)
|
||||
if (map.containsKey(OS.os().checked_name))
|
||||
url = map.get(OS.os().checked_name);
|
||||
else if (map.containsKey(OS.UNKOWN.checked_name))
|
||||
url = map.get(OS.UNKOWN.checked_name);
|
||||
if (url == null) url = C.URL_PUBLISH;
|
||||
try {
|
||||
java.awt.Desktop.getDesktop().browse(new URI(C.URL_PUBLISH));
|
||||
java.awt.Desktop.getDesktop().browse(new URI(url));
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
HMCLog.warn("Failed to browse uri: " + C.URL_PUBLISH, e);
|
||||
HMCLog.warn("Failed to browse uri: " + url, e);
|
||||
|
||||
Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
cb.setContents(new StringSelection(C.URL_PUBLISH), null);
|
||||
cb.setContents(new StringSelection(url), null);
|
||||
MessageBox.Show(C.i18n("update.no_browser"));
|
||||
}
|
||||
else
|
||||
} else
|
||||
Settings.getInstance().setCheckUpdate(false);
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,12 @@ package org.jackhuang.hellominecraft.launcher.utils;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.Main;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.MinecraftCrashAdvicer;
|
||||
import org.jackhuang.hellominecraft.utils.NetUtils;
|
||||
import org.jackhuang.hellominecraft.utils.UpdateChecker;
|
||||
import org.jackhuang.hellominecraft.utils.system.MessageBox;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
@ -57,6 +59,8 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
if (enableLogger) HMCLog.err(text);
|
||||
else System.out.println(text);
|
||||
SwingUtilities.invokeLater(() -> LogWindow.instance.showAsCrashWindow(UpdateChecker.OUT_DATED));
|
||||
if (!UpdateChecker.OUT_DATED)
|
||||
reportToServer(text);
|
||||
} catch (Throwable ex) {
|
||||
try {
|
||||
MessageBox.Show(e.getMessage() + "\n" + ex.getMessage(), "ERROR", MessageBox.ERROR_MESSAGE);
|
||||
@ -67,4 +71,12 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
void reportToServer(String text) {
|
||||
new Thread(() -> {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("CrashReport", text);
|
||||
System.out.println(NetUtils.post("http://huangyuhui.duapp.com/crash.php", map));
|
||||
}).start();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import com.google.gson.JsonSyntaxException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
@ -222,6 +223,7 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
|
||||
@Override
|
||||
public List<ModInfo> listMods() {
|
||||
if (profile.getSelectedMinecraftVersion() == null) return Arrays.asList();
|
||||
File modsFolder = new File(getRunDirectory(profile.getSelectedMinecraftVersion().id), "mods");
|
||||
ArrayList<ModInfo> mods = new ArrayList<>();
|
||||
Queue<File> queue = new LinkedList<>();
|
||||
@ -235,9 +237,8 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
ModInfo m = ModInfo.readModInfo(f);
|
||||
if (m != null)
|
||||
mods.add(m);
|
||||
} else if(f.isDirectory()) {
|
||||
} else if (f.isDirectory())
|
||||
queue.add(f);
|
||||
}
|
||||
}
|
||||
Collections.sort(mods);
|
||||
return mods;
|
||||
|
@ -123,8 +123,6 @@ public final class NetUtils {
|
||||
}
|
||||
sb = new StringBuilder(sb.substring(0, sb.length() - 1));
|
||||
}
|
||||
System.out.println("send_url:" + url);
|
||||
System.out.println("send_data:" + sb.toString());
|
||||
try {
|
||||
u = new URL(url);
|
||||
con = (HttpURLConnection) u.openConnection();
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
|
||||
import java.util.Map;
|
||||
import org.jackhuang.hellominecraft.utils.system.MessageBox;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.utils.functions.NonConsumer;
|
||||
@ -32,6 +33,7 @@ public final class UpdateChecker extends Thread {
|
||||
public String type;
|
||||
public boolean continueUpdate;
|
||||
public NonConsumer dl;
|
||||
public Map<String, String> download_link;
|
||||
|
||||
public UpdateChecker(VersionNumber base, String type, boolean continueUpdate, NonConsumer dl) {
|
||||
super("UpdateChecker");
|
||||
@ -46,9 +48,9 @@ public final class UpdateChecker extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
String url = "http://huangyuhui.duapp.com/info.php?type=" + type, version;
|
||||
String version;
|
||||
try {
|
||||
version = NetUtils.doGet(url);
|
||||
version = NetUtils.doGet("http://huangyuhui.duapp.com/info.php?type=" + type);
|
||||
} catch (Exception e) {
|
||||
HMCLog.warn("Failed to get update url.", e);
|
||||
return;
|
||||
@ -57,6 +59,14 @@ public final class UpdateChecker extends Thread {
|
||||
if (!continueUpdate)
|
||||
return;
|
||||
process(false);
|
||||
if (OUT_DATED) {
|
||||
try {
|
||||
download_link = C.gson.fromJson(NetUtils.doGet("http://huangyuhui.duapp.com/update_link.php?type=" + type), Map.class);
|
||||
} catch (Exception e) {
|
||||
HMCLog.warn("Failed to get update link.", e);
|
||||
}
|
||||
dl.onDone();
|
||||
}
|
||||
}
|
||||
|
||||
public void process(boolean showMessage) {
|
||||
@ -67,7 +77,6 @@ public final class UpdateChecker extends Thread {
|
||||
} else
|
||||
if (VersionNumber.isOlder(base, value)) {
|
||||
OUT_DATED = true;
|
||||
dl.onDone();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,15 +25,17 @@ import org.jackhuang.hellominecraft.HMCLog;
|
||||
*/
|
||||
public enum OS {
|
||||
|
||||
LINUX('/'),
|
||||
WINDOWS('\\'),
|
||||
OSX('/'),
|
||||
UNKOWN('/');
|
||||
LINUX('/', "linux"),
|
||||
WINDOWS('\\', "windows"),
|
||||
OSX('/', "osx"),
|
||||
UNKOWN('/', "universal");
|
||||
|
||||
public final char fileSeparator;
|
||||
public final String checked_name;
|
||||
|
||||
private OS(char fileSeparator) {
|
||||
private OS(char fileSeparator, String n) {
|
||||
this.fileSeparator = fileSeparator;
|
||||
checked_name = n;
|
||||
}
|
||||
|
||||
public static OS os() {
|
||||
|
Loading…
Reference in New Issue
Block a user