Fixed many bugs
This commit is contained in:
@@ -73,8 +73,10 @@ public class GameLauncher {
|
||||
public IMinecraftLoader makeLaunchCommand() {
|
||||
IMinecraftLoader loader;
|
||||
try {
|
||||
if (info != null) result = login.login(info);
|
||||
else result = login.loginBySettings();
|
||||
if (info != null)
|
||||
result = login.login(info);
|
||||
else
|
||||
result = login.loginBySettings();
|
||||
} catch (Exception e) {
|
||||
HMCLog.err("An exception has thrown when logging in.", e);
|
||||
result = new UserProfileProvider();
|
||||
@@ -102,7 +104,8 @@ public class GameLauncher {
|
||||
}
|
||||
|
||||
File file = provider.getDecompressNativesToLocation();
|
||||
if (file != null) FileUtils.cleanDirectoryQuietly(file);
|
||||
if (file != null)
|
||||
FileUtils.cleanDirectoryQuietly(file);
|
||||
|
||||
if (!downloadLibrariesEvent.execute(provider.getDownloadLibraries(downloadType))) {
|
||||
failEvent.execute(C.i18n("launch.failed"));
|
||||
@@ -135,8 +138,10 @@ public class GameLauncher {
|
||||
}
|
||||
HMCLog.log("Starting process");
|
||||
ProcessBuilder builder = new ProcessBuilder(str);
|
||||
if (get == null || get.getSelectedMinecraftVersion() == null || StrUtils.isBlank(get.getCanonicalGameDir()))
|
||||
throw new NullPointerException("Fucking bug!");
|
||||
builder.directory(provider.getRunDirectory(get.getSelectedMinecraftVersion().id))
|
||||
.environment().put("APPDATA", get.getCanonicalGameDirFile().getPath());
|
||||
.environment().put("APPDATA", get.getCanonicalGameDir());
|
||||
JavaProcess jp = new JavaProcess(str, builder.start(), PROCESS_MANAGER);
|
||||
launchEvent.execute(jp);
|
||||
} catch (IOException e) {
|
||||
@@ -157,7 +162,8 @@ public class GameLauncher {
|
||||
provider.onLaunch();
|
||||
boolean isWin = OS.os() == OS.WINDOWS;
|
||||
File f = new File(launcherName + (isWin ? ".bat" : ".sh"));
|
||||
if (!f.exists()) f.createNewFile();
|
||||
if (!f.exists())
|
||||
f.createNewFile();
|
||||
BufferedWriter writer;
|
||||
try {
|
||||
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f), System.getProperty("sun.jnu.encoding", "UTF-8")));
|
||||
|
||||
@@ -155,7 +155,10 @@ public final class Config {
|
||||
}
|
||||
|
||||
public DownloadType getDownloadSource() {
|
||||
if (downloadtype >= DownloadType.values().length || downloadtype < 0) return null;
|
||||
if (downloadtype >= DownloadType.values().length || downloadtype < 0) {
|
||||
downloadtype = 0;
|
||||
Settings.save();
|
||||
}
|
||||
return DownloadType.values()[downloadtype];
|
||||
}
|
||||
|
||||
|
||||
@@ -57,9 +57,10 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
try {
|
||||
MessageBox.Show(C.i18n("crash.headless"));
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
} else if(s.contains("java.lang.NoClassDefFoundError")) {
|
||||
} else if(s.contains("java.lang.NoClassDefFoundError") || s.contains("java.lang.IncompatibleClassChangeError") || s.contains("java.lang.ClassFormatError")) {
|
||||
System.out.println(C.i18n("crash.NoClassDefFound"));
|
||||
try {
|
||||
MessageBox.Show(C.i18n("crash.NoClassDefFound"));
|
||||
@@ -67,6 +68,9 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
t.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
} else if(s.contains("java.lang.OutOfMemoryError")) {
|
||||
System.out.println("FUCKING MEMORY LIMIT!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.assets.AssetsIndex;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.assets.AssetsObject;
|
||||
@@ -242,7 +243,13 @@ public final class MCUtils {
|
||||
.addTask(new FileDownloadTask(vurl + id + ".json", IOUtils.tryGetCanonicalFile(mvt)).setTag(id + ".json"))
|
||||
.addTask(new FileDownloadTask(vurl + id + ".jar", IOUtils.tryGetCanonicalFile(mvj)).setTag(id + ".jar"))
|
||||
.start()) {
|
||||
MinecraftVersion mv = new Gson().fromJson(FileUtils.readFileToStringQuietly(mvt), MinecraftVersion.class);
|
||||
MinecraftVersion mv;
|
||||
try {
|
||||
mv = C.gson.fromJson(FileUtils.readFileToStringQuietly(mvt), MinecraftVersion.class);
|
||||
} catch(JsonSyntaxException ex) {
|
||||
HMCLog.err("Failed to parse minecraft version json.", ex);
|
||||
mv = null;
|
||||
}
|
||||
return mv;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.utils.ArrayUtils;
|
||||
import org.jackhuang.hellominecraft.views.Selector;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.GameProfile;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.properties.PropertyMap;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.PropertyMap;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.YggdrasilAuthentication;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.UUIDTypeAdapter;
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.request;
|
||||
package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class AuthenticationRequest {
|
||||
|
||||
public HashMap<String, Object> agent;
|
||||
public String username;
|
||||
public String password;
|
||||
public String clientToken;
|
||||
public String username, password, clientToken;
|
||||
public boolean requestUser = true;
|
||||
|
||||
public AuthenticationRequest(String username, String password, String clientToken) {
|
||||
@@ -8,7 +8,6 @@ import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import java.lang.reflect.Type;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.properties.PropertyMap;
|
||||
import java.util.UUID;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil;
|
||||
|
||||
public class Property {
|
||||
|
||||
public final String name, value;
|
||||
|
||||
public Property(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.properties;
|
||||
package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
@@ -24,7 +24,6 @@ public class PropertyMap extends HashMap<String, Property> {
|
||||
Map<String, String> property = new HashMap<>();
|
||||
property.put("name", profileProperty.name);
|
||||
property.put("value", profileProperty.value);
|
||||
property.put("signature", profileProperty.signature);
|
||||
properties.add(property);
|
||||
}
|
||||
return properties;
|
||||
@@ -35,9 +34,6 @@ public class PropertyMap extends HashMap<String, Property> {
|
||||
for (Map<String, String> propertyMap : list) {
|
||||
String name = propertyMap.get("name");
|
||||
String value = propertyMap.get("value");
|
||||
String signature = propertyMap.get("signature");
|
||||
|
||||
put(name, new Property(name, value, signature));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
HMCLog.warn("Failed to deserialize properties", t);
|
||||
@@ -53,7 +49,7 @@ public class PropertyMap extends HashMap<String, Property> {
|
||||
JsonObject object = (JsonObject) json;
|
||||
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet())
|
||||
if ((entry.getValue() instanceof JsonArray))
|
||||
if (entry.getValue() instanceof JsonArray)
|
||||
for (JsonElement element : (JsonArray) entry.getValue())
|
||||
result.put(entry.getKey(),
|
||||
new Property((String) entry.getKey(), element.getAsString()));
|
||||
@@ -63,11 +59,6 @@ public class PropertyMap extends HashMap<String, Property> {
|
||||
JsonObject object = (JsonObject) element;
|
||||
String name = object.getAsJsonPrimitive("name").getAsString();
|
||||
String value = object.getAsJsonPrimitive("value").getAsString();
|
||||
|
||||
if (object.has("signature"))
|
||||
result.put(name, new Property(name, value, object.getAsJsonPrimitive("signature").getAsString()));
|
||||
else
|
||||
result.put(name, new Property(name, value));
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -76,16 +67,10 @@ public class PropertyMap extends HashMap<String, Property> {
|
||||
@Override
|
||||
public JsonElement serialize(PropertyMap src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonArray result = new JsonArray();
|
||||
|
||||
for (Property property : src.values()) {
|
||||
JsonObject object = new JsonObject();
|
||||
|
||||
object.addProperty("name", property.name);
|
||||
object.addProperty("value", property.value);
|
||||
|
||||
if (property.signature != null)
|
||||
object.addProperty("signature", property.signature);
|
||||
|
||||
result.add(object);
|
||||
}
|
||||
|
||||
@@ -99,15 +84,11 @@ public class PropertyMap extends HashMap<String, Property> {
|
||||
@Override
|
||||
public JsonElement serialize(PropertyMap src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject result = new JsonObject();
|
||||
|
||||
for (String key : src.keySet()) {
|
||||
JsonArray values = new JsonArray();
|
||||
|
||||
values.add(new JsonPrimitive(src.get(key).value));
|
||||
|
||||
result.add(key, values);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil;
|
||||
|
||||
public class RefreshRequest {
|
||||
|
||||
public String clientToken;
|
||||
public String accessToken;
|
||||
public boolean requestUser = true;
|
||||
|
||||
public RefreshRequest(String accessToken, String clientToken) {
|
||||
this.clientToken = clientToken;
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.response;
|
||||
package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil;
|
||||
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.GameProfile;
|
||||
|
||||
public class Response {
|
||||
|
||||
public String accessToken;
|
||||
public String clientToken;
|
||||
public String accessToken, clientToken;
|
||||
public GameProfile selectedProfile;
|
||||
public GameProfile[] availableProfiles;
|
||||
public User user;
|
||||
@@ -9,8 +9,7 @@ import java.util.UUID;
|
||||
public class UUIDTypeAdapter extends TypeAdapter<UUID> {
|
||||
|
||||
@Override
|
||||
public void write(JsonWriter out, UUID value)
|
||||
throws IOException {
|
||||
public void write(JsonWriter out, UUID value) throws IOException {
|
||||
out.value(fromUUID(value));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.response;
|
||||
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.properties.PropertyMap;
|
||||
package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil;
|
||||
|
||||
public class User {
|
||||
|
||||
@@ -11,14 +11,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.utils.NetUtils;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.properties.PropertyMap;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.request.AuthenticationRequest;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.request.RefreshRequest;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.response.Response;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.response.User;
|
||||
|
||||
public class YggdrasilAuthentication {
|
||||
|
||||
@@ -30,8 +24,8 @@ public class YggdrasilAuthentication {
|
||||
protected static final String BASE_URL = "https://authserver.mojang.com/";
|
||||
protected static final URL ROUTE_AUTHENTICATE = NetUtils.constantURL(BASE_URL + "authenticate");
|
||||
protected static final URL ROUTE_REFRESH = NetUtils.constantURL(BASE_URL + "refresh");
|
||||
|
||||
protected static final String STORAGE_KEY_ACCESS_TOKEN = "accessToken";
|
||||
|
||||
protected static final String STORAGE_KEY_PROFILE_NAME = "displayName";
|
||||
protected static final String STORAGE_KEY_PROFILE_ID = "uuid";
|
||||
protected static final String STORAGE_KEY_PROFILE_PROPERTIES = "profileProperties";
|
||||
@@ -41,15 +35,11 @@ public class YggdrasilAuthentication {
|
||||
|
||||
private final Proxy proxy;
|
||||
private final String clientToken;
|
||||
|
||||
private final PropertyMap userProperties = new PropertyMap();
|
||||
private String userid;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
private String userid, username, password, accessToken;
|
||||
private GameProfile selectedProfile;
|
||||
|
||||
private GameProfile[] profiles;
|
||||
private String accessToken;
|
||||
private boolean isOnline;
|
||||
|
||||
public YggdrasilAuthentication(Proxy proxy, String clientToken) {
|
||||
@@ -57,16 +47,18 @@ public class YggdrasilAuthentication {
|
||||
this.clientToken = clientToken;
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="Get/Set">
|
||||
|
||||
public void setUsername(String username) {
|
||||
if ((isLoggedIn()) && (canPlayOnline()))
|
||||
throw new IllegalStateException("Cannot change username whilst logged in & online");
|
||||
throw new IllegalStateException("Cannot change username while logged in & online");
|
||||
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
if ((isLoggedIn()) && (canPlayOnline()) && (StrUtils.isNotBlank(password)))
|
||||
throw new IllegalStateException("Cannot set password whilst logged in & online");
|
||||
throw new IllegalStateException("Cannot set password while logged in & online");
|
||||
|
||||
this.password = password;
|
||||
}
|
||||
@@ -104,37 +96,52 @@ public class YggdrasilAuthentication {
|
||||
return this.userProperties;
|
||||
}
|
||||
|
||||
protected void setUserid(String userid) {
|
||||
protected void updateUserProperties(User user) {
|
||||
if (user != null && user.properties != null)
|
||||
getModifiableUserProperties().putAll(user.properties);
|
||||
}
|
||||
|
||||
protected void setUserId(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public Proxy getProxy() {
|
||||
return this.proxy;
|
||||
}
|
||||
|
||||
protected Response makeRequest(URL url, Object input) throws AuthenticationException {
|
||||
try {
|
||||
String jsonResult = input == null ? NetUtils.doGet(url) : NetUtils.post(url, GSON.toJson(input), "application/json", proxy);
|
||||
Response result = (Response) GSON.fromJson(jsonResult, Response.class);
|
||||
|
||||
if (result == null)
|
||||
return null;
|
||||
|
||||
if (StrUtils.isNotBlank(result.error))
|
||||
throw new AuthenticationException("InvalidCredentials " + result.errorMessage);
|
||||
|
||||
return result;
|
||||
} catch (IOException | IllegalStateException | JsonParseException e) {
|
||||
throw new AuthenticationException(C.i18n("login.failed.connect_authentication_server"), e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getClientToken() {
|
||||
return this.clientToken;
|
||||
}
|
||||
|
||||
public GameProfile[] getAvailableProfiles() {
|
||||
return this.profiles;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getSessionToken() {
|
||||
if (isLoggedIn() && getSelectedProfile() != null && canPlayOnline())
|
||||
return String.format("token:%s:%s", new Object[]{getAuthenticatedToken(), getSelectedProfile().id});
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getAuthenticatedToken() {
|
||||
return this.accessToken;
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="Log In/Out">
|
||||
|
||||
public boolean canPlayOnline() {
|
||||
return isLoggedIn() && getSelectedProfile() != null && this.isOnline;
|
||||
}
|
||||
|
||||
public boolean canLogIn() {
|
||||
return (!canPlayOnline()) && (StrUtils.isNotBlank(getUsername())) && ((StrUtils.isNotBlank(getPassword())) || (StrUtils.isNotBlank(getAuthenticatedToken())));
|
||||
return !canPlayOnline() && StrUtils.isNotBlank(getUsername()) && (StrUtils.isNotBlank(getPassword()) || StrUtils.isNotBlank(getAuthenticatedToken()));
|
||||
}
|
||||
|
||||
public boolean isLoggedIn() {
|
||||
return StrUtils.isNotBlank(this.accessToken);
|
||||
}
|
||||
|
||||
public void logIn() throws AuthenticationException {
|
||||
@@ -149,23 +156,13 @@ public class YggdrasilAuthentication {
|
||||
throw new AuthenticationException(C.i18n("login.invalid_password"));
|
||||
}
|
||||
|
||||
protected void logInWithPassword() throws AuthenticationException {
|
||||
if (StrUtils.isBlank(getUsername()))
|
||||
throw new AuthenticationException(C.i18n("login.invalid_username"));
|
||||
if (StrUtils.isBlank(getPassword()))
|
||||
throw new AuthenticationException(C.i18n("login.invalid_password"));
|
||||
|
||||
HMCLog.log("Logging in with username & password");
|
||||
|
||||
AuthenticationRequest request = new AuthenticationRequest(clientToken, getUsername(), getPassword());
|
||||
Response response = makeRequest(ROUTE_AUTHENTICATE, request);
|
||||
|
||||
private void logInWithPassword() throws AuthenticationException {
|
||||
Response response = request(ROUTE_AUTHENTICATE, new AuthenticationRequest(getUsername(), getPassword(), clientToken));
|
||||
if (!response.clientToken.equals(clientToken))
|
||||
throw new AuthenticationException(C.i18n("login.changed_client_token"));
|
||||
|
||||
User user = response.user;
|
||||
|
||||
setUserid(user != null && user.id != null ? user.id : getUsername());
|
||||
setUserId(user != null && user.id != null ? user.id : getUsername());
|
||||
|
||||
this.isOnline = true;
|
||||
this.accessToken = response.accessToken;
|
||||
@@ -177,32 +174,18 @@ public class YggdrasilAuthentication {
|
||||
updateUserProperties(user);
|
||||
}
|
||||
|
||||
protected void updateUserProperties(User user) {
|
||||
if (user == null)
|
||||
return;
|
||||
|
||||
if (user.properties != null)
|
||||
getModifiableUserProperties().putAll(user.properties);
|
||||
}
|
||||
|
||||
protected void logInWithToken() throws AuthenticationException {
|
||||
if (StrUtils.isBlank(getUserID()))
|
||||
if (StrUtils.isBlank(getUsername()))
|
||||
setUserid(getUsername());
|
||||
setUserId(getUsername());
|
||||
else
|
||||
throw new AuthenticationException(C.i18n("login.invalid_uuid_and_username"));
|
||||
if (StrUtils.isBlank(getAuthenticatedToken()))
|
||||
throw new AuthenticationException(C.i18n("login.invalid_access_token"));
|
||||
|
||||
HMCLog.log("Logging in with access token");
|
||||
|
||||
RefreshRequest request = new RefreshRequest(this);
|
||||
Response response = makeRequest(ROUTE_REFRESH, request);
|
||||
|
||||
if (!response.clientToken.equals(clientToken))
|
||||
Response response = request(ROUTE_REFRESH, new RefreshRequest(getAuthenticatedToken(), getClientToken()));
|
||||
if (!clientToken.equals(response.clientToken))
|
||||
throw new AuthenticationException(C.i18n("login.changed_client_token"));
|
||||
|
||||
setUserid(response.user != null && response.user.id != null ? response.user.id : getUsername());
|
||||
setUserId(response.user != null && response.user.id != null ? response.user.id : getUsername());
|
||||
|
||||
this.isOnline = true;
|
||||
this.accessToken = response.accessToken;
|
||||
@@ -223,19 +206,10 @@ public class YggdrasilAuthentication {
|
||||
this.profiles = null;
|
||||
this.isOnline = false;
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
public GameProfile[] getAvailableProfiles() {
|
||||
return this.profiles;
|
||||
}
|
||||
|
||||
public boolean isLoggedIn() {
|
||||
return StrUtils.isNotBlank(this.accessToken);
|
||||
}
|
||||
|
||||
public boolean canPlayOnline() {
|
||||
return isLoggedIn() && getSelectedProfile() != null && this.isOnline;
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="Settings Storage">
|
||||
|
||||
public void loadFromStorage(Map<String, Object> credentials) {
|
||||
logOut();
|
||||
|
||||
@@ -283,15 +257,23 @@ public class YggdrasilAuthentication {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
protected Response request(URL url, Object input) throws AuthenticationException {
|
||||
try {
|
||||
String jsonResult = input == null ? NetUtils.doGet(url) : NetUtils.post(url, GSON.toJson(input), "application/json", proxy);
|
||||
Response result = (Response) GSON.fromJson(jsonResult, Response.class);
|
||||
|
||||
@Deprecated
|
||||
public String getSessionToken() {
|
||||
if (isLoggedIn() && getSelectedProfile() != null && canPlayOnline())
|
||||
return String.format("token:%s:%s", new Object[]{getAuthenticatedToken(), getSelectedProfile().id});
|
||||
return null;
|
||||
}
|
||||
if (result == null)
|
||||
return null;
|
||||
|
||||
public String getAuthenticatedToken() {
|
||||
return this.accessToken;
|
||||
if (StrUtils.isNotBlank(result.error))
|
||||
throw new AuthenticationException("InvalidCredentials " + result.errorMessage);
|
||||
|
||||
return result;
|
||||
} catch (IOException | IllegalStateException | JsonParseException e) {
|
||||
throw new AuthenticationException(C.i18n("login.failed.connect_authentication_server"), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.properties;
|
||||
|
||||
public class Property {
|
||||
|
||||
public final String name;
|
||||
public final String value;
|
||||
public final String signature;
|
||||
|
||||
public Property(String value, String name) {
|
||||
this(value, name, null);
|
||||
}
|
||||
|
||||
public Property(String name, String value, String signature) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.signature = signature;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.request;
|
||||
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.GameProfile;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.yggdrasil.YggdrasilAuthentication;
|
||||
|
||||
public class RefreshRequest {
|
||||
|
||||
public String clientToken;
|
||||
public String accessToken;
|
||||
public GameProfile selectedProfile;
|
||||
public boolean requestUser = true;
|
||||
|
||||
public RefreshRequest(YggdrasilAuthentication userAuth) {
|
||||
this(userAuth, null);
|
||||
}
|
||||
|
||||
public RefreshRequest(YggdrasilAuthentication userAuth, GameProfile profile) {
|
||||
this.clientToken = userAuth.getClientToken();
|
||||
this.accessToken = userAuth.getAuthenticatedToken();
|
||||
this.selectedProfile = profile;
|
||||
}
|
||||
}
|
||||
@@ -245,6 +245,7 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
@Override
|
||||
public List<GameLauncher.DownloadLibraryJob> getDownloadLibraries(DownloadType downloadType) {
|
||||
ArrayList<DownloadLibraryJob> downloadLibraries = new ArrayList<>();
|
||||
if(profile.getSelectedMinecraftVersion() == null) return downloadLibraries;
|
||||
MinecraftVersion v = profile.getSelectedMinecraftVersion().resolve(this, Settings.getInstance().getDownloadSource());
|
||||
if (v.libraries != null)
|
||||
for (IMinecraftLibrary l : v.libraries) {
|
||||
@@ -296,7 +297,7 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
@Override
|
||||
public File getDecompressNativesToLocation() {
|
||||
MinecraftVersion v = profile.getSelectedMinecraftVersion();
|
||||
return v.getNatives(profile.getCanonicalGameDirFile());
|
||||
return v == null ? null : v.getNatives(profile.getCanonicalGameDirFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -488,7 +488,9 @@
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="chkCancelWrapper">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="取消包裹启动器(出现奇怪问题时可尝试使用,与调试模式冲突)"/>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="advancedsettings.cancel_wrapper_launcher" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="chkCancelWrapperFocusLost"/>
|
||||
@@ -577,7 +579,7 @@
|
||||
<Component id="btnRemoveMod" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jScrollPane1" pref="279" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="264" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblModInfo" min="-2" max="-2" attributes="0"/>
|
||||
@@ -635,7 +637,7 @@
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="mods.default_information" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="默认光标"/>
|
||||
<Color id="Default Cursor"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
@@ -1248,7 +1250,9 @@
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnCleanGame">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="清理游戏文件"/>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="setupwindow.clean" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCleanGameActionPerformed"/>
|
||||
|
||||
@@ -569,7 +569,7 @@ public class GameSettingsPanel extends javax.swing.JPanel implements DropTargetL
|
||||
}
|
||||
});
|
||||
|
||||
chkCancelWrapper.setText("取消包裹启动器(出现奇怪问题时可尝试使用,与调试模式冲突)");
|
||||
chkCancelWrapper.setText(bundle.getString("advancedsettings.cancel_wrapper_launcher")); // NOI18N
|
||||
chkCancelWrapper.addFocusListener(new java.awt.event.FocusAdapter() {
|
||||
public void focusLost(java.awt.event.FocusEvent evt) {
|
||||
chkCancelWrapperFocusLost(evt);
|
||||
@@ -716,7 +716,7 @@ public class GameSettingsPanel extends javax.swing.JPanel implements DropTargetL
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnRemoveMod)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE))
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblModInfo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
@@ -1079,7 +1079,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
}
|
||||
});
|
||||
|
||||
btnCleanGame.setText("清理游戏文件");
|
||||
btnCleanGame.setText(bundle.getString("setupwindow.clean")); // NOI18N
|
||||
btnCleanGame.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnCleanGameActionPerformed(evt);
|
||||
|
||||
@@ -349,7 +349,7 @@ public class MainPagePanel extends javax.swing.JPanel {
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="Game Launch">
|
||||
void genLaunchCode(final Consumer<GameLauncher> listener) {
|
||||
if (isLaunching) return;
|
||||
if (isLaunching || getCurrentProfile() == null) return;
|
||||
isLaunching = true;
|
||||
HMCLog.log("Start generating launching command...");
|
||||
File file = getCurrentProfile().getCanonicalGameDirFile();
|
||||
|
||||
Reference in New Issue
Block a user