Fix Minecraft crashing when in offline & multiplayer mode.
This commit is contained in:
Binary file not shown.
@@ -25,7 +25,7 @@ if (!hasProperty('mainClass')) {
|
||||
ext.mainClass = 'org.jackhuang.hellominecraft.launcher.Main'
|
||||
}
|
||||
|
||||
def buildnumber = System.getenv("BUILD_NUMBER") == null ? ".0" : "."+System.getenv("BUILD_NUMBER")
|
||||
def buildnumber = System.getenv("BUILD_NUMBER") == null ? ".1" : "."+System.getenv("BUILD_NUMBER")
|
||||
|
||||
String mavenGroupId = 'HMCL'
|
||||
String mavenVersion = '2.3.5' + buildnumber
|
||||
|
||||
@@ -100,7 +100,7 @@ public final class Main implements Runnable {
|
||||
}
|
||||
|
||||
public static String launcherName = "Hello Minecraft! Launcher";
|
||||
public static byte firstVer = 2, secondVer = 3, thirdVer = 5, forthVer = 0;
|
||||
public static byte firstVer = 2, secondVer = 3, thirdVer = 5, forthVer = 1;
|
||||
public static int minimumLauncherVersion = 16;
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,15 +38,15 @@ public final class OfflineAuthenticator extends IAuthenticator {
|
||||
String uuid = getUUIDFromUserName(info.username);
|
||||
result.setSession(uuid);
|
||||
result.setUserId(uuid);
|
||||
result.setAccessToken("0");
|
||||
result.setAccessToken(uuid);
|
||||
result.setUserType("Legacy");
|
||||
result.setErrorReason(C.i18n("login.no_Player007"));
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getUUIDFromUserName(String str) {
|
||||
String md5 = DigestUtils.md5Hex(str);
|
||||
return md5.substring(0, 8) + '-' + md5.substring(8, 12) + '-' + md5.substring(12, 16) + '-' + md5.substring(16, 21) + md5.substring(21);
|
||||
return DigestUtils.md5Hex(str);
|
||||
//return md5.substring(0, 8) + '-' + md5.substring(8, 12) + '-' + md5.substring(12, 16) + '-' + md5.substring(16, 21) + md5.substring(21);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.version;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -53,7 +52,6 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
private File baseFolder;
|
||||
private final Profile profile;
|
||||
private final Map<String, MinecraftVersion> versions = new TreeMap();
|
||||
private final Gson gson = Utils.getDefaultGsonBuilder().create();
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -122,14 +120,14 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
}
|
||||
MinecraftVersion mcVersion;
|
||||
try {
|
||||
mcVersion = gson.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
|
||||
mcVersion = C.gson.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
|
||||
if (mcVersion == null) throw new RuntimeException("Wrong json format, got null.");
|
||||
} catch (IOException | RuntimeException e) {
|
||||
HMCLog.warn("Found wrong format json, try to fix it.", e);
|
||||
if (MessageBox.Show(C.i18n("launcher.versions_json_not_formatted", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
||||
refreshJson(id);
|
||||
try {
|
||||
mcVersion = gson.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
|
||||
mcVersion = C.gson.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
|
||||
if (mcVersion == null) throw new RuntimeException("Wrong json format, got null.");
|
||||
} catch (IOException | RuntimeException ex) {
|
||||
HMCLog.err("Retried but still failed.");
|
||||
@@ -142,7 +140,7 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
if (!id.equals(mcVersion.id)) {
|
||||
HMCLog.warn("Found: " + dir + ", it contains id: " + mcVersion.id + ", expected: " + id + ", the launcher will fix this problem.");
|
||||
mcVersion.id = id;
|
||||
FileUtils.writeQuietly(jsonFile, gson.toJson(mcVersion));
|
||||
FileUtils.writeQuietly(jsonFile, C.gsonPrettyPrinting.toJson(mcVersion));
|
||||
}
|
||||
|
||||
if (mcVersion.libraries != null)
|
||||
@@ -150,7 +148,7 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
ml.init();
|
||||
versions.put(id, mcVersion);
|
||||
} catch (Exception e) {
|
||||
HMCLog.warn("Ignoring: " + dir + ", the json of this Minecraft is malformed.");
|
||||
HMCLog.warn("Ignoring: " + dir + ", the json of this Minecraft is malformed.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,9 +166,9 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
public boolean renameVersion(String from, String to) {
|
||||
try {
|
||||
File fromJson = new File(baseFolder, "versions/" + from + "/" + from + ".json");
|
||||
MinecraftVersion mcVersion = gson.fromJson(FileUtils.readFileToString(fromJson), MinecraftVersion.class);
|
||||
MinecraftVersion mcVersion = C.gson.fromJson(FileUtils.readFileToString(fromJson), MinecraftVersion.class);
|
||||
mcVersion.id = to;
|
||||
FileUtils.writeQuietly(fromJson, gson.toJson(mcVersion));
|
||||
FileUtils.writeQuietly(fromJson, C.gsonPrettyPrinting.toJson(mcVersion));
|
||||
File toDir = new File(baseFolder, "versions/" + to);
|
||||
new File(baseFolder, "versions/" + from).renameTo(toDir);
|
||||
File toJson = new File(toDir, to + ".json");
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
|
||||
import org.jackhuang.hellominecraft.utils.system.MessageBox;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Image;
|
||||
@@ -45,12 +44,6 @@ import org.jackhuang.hellominecraft.HMCLog;
|
||||
*/
|
||||
public final class Utils {
|
||||
|
||||
private static final GsonBuilder gsonBuilder = new GsonBuilder().setPrettyPrinting();
|
||||
|
||||
public static GsonBuilder getDefaultGsonBuilder() {
|
||||
return gsonBuilder;
|
||||
}
|
||||
|
||||
public static String[] getURL() {
|
||||
URL[] urls = ((URLClassLoader) Utils.class.getClassLoader()).getURLs();
|
||||
String[] urlStrings = new String[urls.length];
|
||||
|
||||
Reference in New Issue
Block a user