Fixed many bugs

This commit is contained in:
huanghongxun 2015-11-15 16:19:10 +08:00
parent f508645496
commit 990f830300
30 changed files with 187 additions and 196 deletions

View File

@ -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")));

View File

@ -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];
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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));
}

View File

@ -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 {

View File

@ -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);
}
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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

View File

@ -488,7 +488,9 @@
</Component>
<Component class="javax.swing.JCheckBox" name="chkCancelWrapper">
<Properties>
<Property name="text" type="java.lang.String" value="&#x53d6;&#x6d88;&#x5305;&#x88f9;&#x542f;&#x52a8;&#x5668;&#xff08;&#x51fa;&#x73b0;&#x5947;&#x602a;&#x95ee;&#x9898;&#x65f6;&#x53ef;&#x5c1d;&#x8bd5;&#x4f7f;&#x7528;,&#x4e0e;&#x8c03;&#x8bd5;&#x6a21;&#x5f0f;&#x51b2;&#x7a81;&#xff09;"/>
<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(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</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(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="&#x9ed8;&#x8ba4;&#x5149;&#x6807;"/>
<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="&#x6e05;&#x7406;&#x6e38;&#x620f;&#x6587;&#x4ef6;"/>
<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(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCleanGameActionPerformed"/>

View File

@ -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);

View File

@ -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();

View File

@ -29,7 +29,19 @@ public final class C {
public static final Gson gsonPrettyPrinting = new GsonBuilder().setPrettyPrinting().create();
public static final Gson gson = new Gson();
public static final ResourceBundle I18N = ResourceBundle.getBundle("org/jackhuang/hellominecraft/launcher/I18N");
public static final ResourceBundle I18N;
static {
ResourceBundle rb = null;
try {
rb = ResourceBundle.getBundle("org/jackhuang/hellominecraft/launcher/I18N");
} catch(Throwable t) {
rb = null;
System.out.println("Did you delete I18N.properties?");
t.printStackTrace();
}
I18N = rb;
}
//http://repo1.maven.org/maven2
public static final String URL_PUBLISH = "http://www.mcbbs.net/thread-142335-1-1.html";

View File

@ -71,16 +71,15 @@ public class TaskWindow extends javax.swing.JDialog
return this;
}
public void clean() {
public synchronized void clean() {
if (isVisible()) return;
taskList = null;
taskList = new TaskList();
taskList.addTaskListener(this);
taskList.addAllDoneListener(this);
}
public boolean start() {
if (isVisible() || taskList.isAlive()) return false;
if (isVisible() || taskList == null || taskList.isAlive()) return false;
pgsTotal.setValue(0);
suc = false;
SwingUtils.clearDefaultTable(lstDownload);
@ -179,7 +178,8 @@ public class TaskWindow extends javax.swing.JDialog
}
if (!suc) {
SwingUtilities.invokeLater(taskList::abort);
if (taskList != null)
SwingUtilities.invokeLater(taskList::abort);
HMCLog.log("Tasks have been canceled by user.");
}
taskList = null;
@ -205,7 +205,7 @@ public class TaskWindow extends javax.swing.JDialog
int idx = tasks.indexOf(task);
if (idx == -1) return;
int pgs = progress * 100 / max;
if (progresses.get(idx) != pgs) {
if (progresses.contains(idx) && progresses.get(idx) != pgs && lstDownload.getRowCount() > idx) {
SwingUtils.setValueAt(lstDownload, pgs + "%", idx, 1);
progresses.set(idx, pgs);
}
@ -281,8 +281,6 @@ public class TaskWindow extends javax.swing.JDialog
}
public static class TaskWindowFactory {
public static final Object obj = new Object();
LinkedList<Task> ll = new LinkedList<>();
public TaskWindowFactory addTask(Task t) {
@ -291,7 +289,8 @@ public class TaskWindow extends javax.swing.JDialog
}
public boolean start() {
synchronized(obj) {
synchronized(instance) {
if (instance.isVisible()) return false;
TaskWindow tw = inst();
for(Task t : ll) tw.addTask(t);
return tw.start();

View File

@ -30,7 +30,6 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder;
@ -93,7 +92,7 @@ public final class Utils {
try {
Desktop.getDesktop().browse(new URI(url));
return true;
} catch (URISyntaxException | IOException ex) {
} catch (Exception ex) {
HMCLog.warn("Failed to open link:" + url, ex);
return false;
}
@ -166,7 +165,8 @@ public final class Utils {
}
/**
* In order to fight against the permission manager.
* In order to fight against the permission manager by Minecraft Forge.
* @param status exit code
*/
public static void shutdownForcely(int status) {
try {

View File

@ -435,6 +435,7 @@ public class FileUtils {
public static File[] searchSuffix(File dir, String suffix) {
ArrayList<File> al = new ArrayList();
File[] files = dir.listFiles();
if (files == null) return new File[0];
for (File f : files)
if (f.getName().endsWith(suffix)) al.add(f);
return al.toArray(new File[0]);

View File

@ -57,12 +57,14 @@ public final class JdkVersion {
public boolean equals(Object obj) {
if (!(obj instanceof JdkVersion)) return false;
JdkVersion b = (JdkVersion) obj;
if(b.location == null || location == null)
return b.location == location;
return new File(b.location).equals(new File(location));
}
@Override
public int hashCode() {
return new File(location).hashCode();
return location == null ? 0 : new File(location).hashCode();
}
public JdkVersion(String location) {

View File

@ -24,7 +24,7 @@ import org.jackhuang.hellominecraft.C;
*/
public class MessageBox {
private static String Title = C.i18n("message.info");
private static final String TITLE = C.i18n("message.info");
/**
* Buttons: OK
*/
@ -110,7 +110,7 @@ public class MessageBox {
* @return User Operation
*/
public static int Show(String Msg, int Option) {
return Show(Msg, Title, Option);
return Show(Msg, TITLE, Option);
}
/**
@ -120,6 +120,6 @@ public class MessageBox {
* @return User Operation
*/
public static int Show(String Msg) {
return Show(Msg, Title, INFORMATION_MESSAGE);
return Show(Msg, TITLE, INFORMATION_MESSAGE);
}
}

View File

@ -209,7 +209,7 @@ settings.failed_load=\u8bbe\u7f6e\u6587\u4ef6\u52a0\u8f7d\u5931\u8d25\uff0c\u53e
mods=Mod\u7ba1\u7406
mods.choose_mod=\u9009\u62e9\u6a21\u7ec4
mods.failed=\u6dfb\u52a0\u5931\u8d25
mods.default_information=<html><font color=#c0392b>\u60a8\u53ef\u4ee5\u4ece\u8d44\u6e90\u7ba1\u7406\u5668\u62d6\u52a8mod\u6587\u4ef6\u5230\u5217\u8868\u4e2d\u6765\u6dfb\u52a0mod\uff0c\u540c\u65f6\u4f7f\u7528\u5220\u9664\u952e\u53ef\u5feb\u901f\u5220\u9664\u9009\u4e2dmod<br>\u70b9\u6389mod\u524d\u9762\u7684\u52fe\u53ef\u7981\u7528mod\uff0c\u4e0d\u4f1a\u52a0\u8f7d\uff1b\u9009\u62e9mod\u53ef\u4ee5\u83b7\u53d6mod\u4fe1\u606f</font></html>
mods.default_information=<html><font color=#c0392b>\u5b89\u88c5Mod\u524d\u4f60\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5Forge\u6216LiteLoader!<br>\u60a8\u53ef\u4ee5\u4ece\u8d44\u6e90\u7ba1\u7406\u5668\u62d6\u52a8mod\u6587\u4ef6\u5230\u5217\u8868\u4e2d\u6765\u6dfb\u52a0mod\uff0c\u540c\u65f6\u4f7f\u7528\u5220\u9664\u952e\u53ef\u5feb\u901f\u5220\u9664\u9009\u4e2dmod<br>\u70b9\u6389mod\u524d\u9762\u7684\u52fe\u53ef\u7981\u7528mod\uff0c\u4e0d\u4f1a\u52a0\u8f7d\uff1b\u9009\u62e9mod\u53ef\u4ee5\u83b7\u53d6mod\u4fe1\u606f</font></html>
advancedsettings=\u9ad8\u7ea7\u8bbe\u7f6e
advancedsettings.launcher_visible=\u542f\u52a8\u5668\u53ef\u89c1\u6027
@ -227,6 +227,7 @@ advancedsettings.no_jvm_args=\u4e0d\u6dfb\u52a0JVM\u53c2\u6570(\u4f7f\u7528Java9
advancedsettings.java_args_default=\u542f\u52a8\u5668\u9ed8\u8ba4\u6dfb\u52a0\u7684\u53c2\u6570\uff08\u8bf7\u4e0d\u8981\u91cd\u590d\u6dfb\u52a0\uff09\uff1a-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:MaxPermSize=???m -Xmx???m -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true
advancedsettings.wrapper_launcher=\u542f\u52a8\u524d\u6267\u884c\u547d\u4ee4(\u4e0d\u5fc5\u586b\u5199\uff0c\u5c06\u5728\u6e38\u620f\u542f\u52a8\u524d\u8c03\u7528)
advancedsettings.server_ip=\u76f4\u5165\u670d\u52a1\u5668ip\u5730\u5740(\u4e0d\u5fc5\u586b\u5199\uff0c\u542f\u52a8\u6e38\u620f\u540e\u76f4\u63a5\u8fdb\u5165\u5bf9\u5e94\u670d\u52a1\u5668)
advancedsettings.cancel_wrapper_launcher=\u53d6\u6d88\u5305\u88f9\u542f\u52a8\u5668\uff08\u51fa\u73b0\u5947\u602a\u95ee\u9898\u65f6\u53ef\u5c1d\u8bd5\u4f7f\u7528,\u4e0e\u8c03\u8bd5\u6a21\u5f0f\u51b2\u7a81\uff09
mainwindow.show_log=\u67e5\u770b\u65e5\u5fd7
mainwindow.make_launch_script=\u751f\u6210\u542f\u52a8\u811a\u672c
@ -293,6 +294,7 @@ setupwindow.find_in_configurations=\u5bfc\u5165\u5b8c\u6210\uff0c\u5feb\u5230\u9
setupwindow.give_a_name=\u7ed9\u65b0\u6e38\u620f\u8def\u5f84\u8d77\u4e2a\u540d\u5b57\u5427
setupwindow.new=\u65b0\u5efa
setupwindow.no_empty_name=\u540d\u5b57\u4e0d\u53ef\u4e3a\u7a7a
setupwindow.clean=\u6e05\u7406\u6e38\u620f\u6587\u4ef6
update.no_browser=\u65e0\u6cd5\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u7f51\u5740\u5df2\u7ecf\u590d\u5236\u5230\u526a\u8d34\u677f\u4e86\uff0c\u60a8\u53ef\u4ee5\u624b\u52a8\u7c98\u8d34\u7f51\u5740\u6253\u5f00\u9875\u9762
update.should_open_link=\u662f\u5426\u524d\u5f80\u53d1\u5e03\u9875\u9762\u66f4\u65b0\uff1f

View File

@ -134,7 +134,7 @@ ui.button.run=Play
ui.button.settings=Settings
ui.button.about=About
ui.button.others=Others
ui.button.logout=LogOut
ui.button.logout=Log Out
ui.button.download=Download
ui.button.retry=Retry
ui.button.delete=Delete
@ -209,6 +209,7 @@ settings.failed_load=Failed to load settings file. Remove it?
mods=Mods
mods.choose_mod=Choose your mods
mods.failed=Failed to add mods
mods.default_information=<html><font color=#c0392b>Please ensure that you have installed Forge or LiteLoader before installing mods!<br>You can drop your mod files from explorer/finder, and delete mods by the delete button.<br>Disable a mod by leaving the check box unchecked; Choose an item to get the information.</font></html>
advancedsettings=Advanced
advancedsettings.launcher_visible=Launcher Visibility
@ -226,6 +227,7 @@ advancedsettings.no_jvm_args=No JVM Args
advancedsettings.java_args_default=Default java args: -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:MaxPermSize=???m -Xmx???m -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true
advancedsettings.wrapper_launcher=Wrapper Launcher(like optirun...)
advancedsettings.server_ip=Server Host
advancedsettings.cancel_wrapper_launcher=Cancel Wrapper Launcher
mainwindow.show_log=Show Logs
mainwindow.make_launch_script=Make Launching Script.
@ -240,11 +242,13 @@ launcher.background_location=Background Location
launcher.exit_failed=Failed to shutdown.
launcher.versions_json_not_matched=The version %s is malformed! There are a json:%s in this version. Do you want to fix this problem?
launcher.versions_json_not_matched_cannot_auto_completion=The version %s lost version information file, delete it?
launcher.versions_json_not_formatted=The version information of %s is malformed! Redownload it?
launcher.choose_bgpath=Choose background path.
launcher.background_tooltip=<html>\n<body>\nThis app uses the default background at first.<br />\nIf there is background.png in the directory, it will be used.<br />\nIf there is "bg" subdirectory, this app will chooses one picture in "bgskin" randomly.<br />\nIf you set the background setting, this app will use it.\n</body>\n</html>
launcher.update_launcher=Check for update
launcher.enable_shadow=Enable Window Shadow
launcher.theme=Theme
launcher.proxy=Proxy
launcher.title.game=Games
launcher.title.main=Home
@ -269,6 +273,7 @@ assets.not_refreshed=The assets list is not refreshed, please refresh it once.
assets.failed=Failed to get the list, try again.
assets.list.1_7_3_after=1.7.3 And Higher
assets.list.1_6=1.6(BMCLAPI)
assets.unkown_type_select_one=Unknown game version: %s, please choose an asset type.
assets.type=Asset Type
assets.download=Download Assets
assets.no_assets=Assets are not complete, complete them?
@ -289,6 +294,7 @@ setupwindow.find_in_configurations=Finished importing. You can find it in the co
setupwindow.give_a_name=Give a name to the new game.
setupwindow.new=New
setupwindow.no_empty_name=Version name cannot be empty.
setupwindow.clean=Clean game files
update.no_browser=Cannot open any browser. The link has been copied to the clipboard. You can paste it to the address bar.
update.should_open_link=Are you willing to open the update link?

View File

@ -209,7 +209,7 @@ settings.failed_load=\u8bbe\u7f6e\u6587\u4ef6\u52a0\u8f7d\u5931\u8d25\uff0c\u53e
mods=Mod\u7ba1\u7406
mods.choose_mod=\u9009\u62e9\u6a21\u7ec4
mods.failed=\u6dfb\u52a0\u5931\u8d25
mods.default_information=<html><font color=#c0392b>\u60a8\u53ef\u4ee5\u4ece\u8d44\u6e90\u7ba1\u7406\u5668\u62d6\u52a8mod\u6587\u4ef6\u5230\u5217\u8868\u4e2d\u6765\u6dfb\u52a0mod\uff0c\u540c\u65f6\u4f7f\u7528\u5220\u9664\u952e\u53ef\u5feb\u901f\u5220\u9664\u9009\u4e2dmod<br>\u70b9\u6389mod\u524d\u9762\u7684\u52fe\u53ef\u7981\u7528mod\uff0c\u4e0d\u4f1a\u52a0\u8f7d\uff1b\u9009\u62e9mod\u53ef\u4ee5\u83b7\u53d6mod\u4fe1\u606f</font></html>
mods.default_information=<html><font color=#c0392b>\u5b89\u88c5Mod\u524d\u4f60\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5Forge\u6216LiteLoader!<br>\u60a8\u53ef\u4ee5\u4ece\u8d44\u6e90\u7ba1\u7406\u5668\u62d6\u52a8mod\u6587\u4ef6\u5230\u5217\u8868\u4e2d\u6765\u6dfb\u52a0mod\uff0c\u540c\u65f6\u4f7f\u7528\u5220\u9664\u952e\u53ef\u5feb\u901f\u5220\u9664\u9009\u4e2dmod<br>\u70b9\u6389mod\u524d\u9762\u7684\u52fe\u53ef\u7981\u7528mod\uff0c\u4e0d\u4f1a\u52a0\u8f7d\uff1b\u9009\u62e9mod\u53ef\u4ee5\u83b7\u53d6mod\u4fe1\u606f</font></html>
advancedsettings=\u9ad8\u7ea7\u8bbe\u7f6e
advancedsettings.launcher_visible=\u542f\u52a8\u5668\u53ef\u89c1\u6027
@ -293,6 +293,7 @@ setupwindow.find_in_configurations=\u5bfc\u5165\u5b8c\u6210\uff0c\u5feb\u5230\u9
setupwindow.give_a_name=\u7ed9\u65b0\u6e38\u620f\u8def\u5f84\u8d77\u4e2a\u540d\u5b57\u5427
setupwindow.new=\u65b0\u5efa
setupwindow.no_empty_name=\u540d\u5b57\u4e0d\u53ef\u4e3a\u7a7a
setupwindow.clean=\u6e05\u7406\u6e38\u620f\u6587\u4ef6
update.no_browser=\u65e0\u6cd5\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u7f51\u5740\u5df2\u7ecf\u590d\u5236\u5230\u526a\u8d34\u677f\u4e86\uff0c\u60a8\u53ef\u4ee5\u624b\u52a8\u7c98\u8d34\u7f51\u5740\u6253\u5f00\u9875\u9762
update.should_open_link=\u662f\u5426\u524d\u5f80\u53d1\u5e03\u9875\u9762\u66f4\u65b0\uff1f

View File

@ -227,6 +227,7 @@ advancedsettings.no_jvm_args=\u4e0d\u6dfb\u52a0JVM\u53c3\u6578(\u4f7f\u7528Java9
advancedsettings.java_args_default=\u555f\u52d5\u5668\u9ed8\u8a8d\u6dfb\u52a0\u7684\u53c3\u6578\uff08\u8acb\u4e0d\u8981\u91cd\u8907\u6dfb\u52a0\uff09\uff1a-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:MaxPermSize=???m -Xmx???m -Dfml. ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true
advancedsettings.wrapper_launcher=\u524d\u7f6e\u555f\u52d5\u6307\u4ee4(\u4e0d\u5fc5\u586b\u5beb\uff0c\u5167\u5bb9\u5c07\u52a0\u5728\u555f\u52d5\u8173\u672c\u6700\u524d\uff0c\u5982optirun...)
advancedsettings.server_ip=\u76f4\u5165\u670d\u52d9\u5668ip\u5730\u5740(\u4e0d\u5fc5\u586b\u5beb\uff0c\u555f\u52d5\u904a\u6232\u5f8c\u76f4\u63a5\u9032\u5165\u5c0d\u61c9\u670d\u52d9\u5668)
advancedsettings.cancel_wrapper_launcher=\u53d6\u6d88\u5305\u88f9\u555f\u52d5\u5668(\u51fa\u73fe\u5947\u602a\u554f\u984c\u6642\u53ef\u5617\u8a66\u4f7f\u7528,\u8207\u8abf\u8a66\u6a21\u5f0f\u885d\u7a81)
mainwindow.show_log=\u67e5\u770b\u65e5\u8a8c
mainwindow.make_launch_script=\u751f\u6210\u555f\u52d5\u8173\u672c
@ -272,6 +273,7 @@ assets.not_refreshed=\u8cc7\u6e90\u5217\u8868\u672a\u5237\u65b0\uff0c\u8acb\u523
assets.failed=\u7372\u53d6\u5217\u8868\u5931\u6557\uff0c\u8acb\u5237\u65b0\u91cd\u8a66\u3002
assets.list.1_7_3_after=1.7.3\u53ca\u4ee5\u5f8c
assets.list.1_6=1.6(BMCLAPI)
assets.unkown_type_select_one=\u7121\u6cd5\u89e3\u6790\u904a\u6232\u7248\u672c\uff1a%s\uff0c\u8acb\u9078\u64c7\u4e00\u7a2e\u8cc7\u6e90\u985e\u578b\u4e0b\u8f09\u3002
assets.type=\u8cc7\u6e90\u985e\u578b
assets.download=\u4e0b\u8f09\u8cc7\u6e90
assets.no_assets=\u8cc7\u6e90\u6587\u4ef6\u4e0d\u5b8c\u6574\uff0c\u662f\u5426\u88dc\u5168\uff1f
@ -292,6 +294,7 @@ setupwindow.find_in_configurations=\u5c0e\u5165\u5b8c\u6210\uff0c\u5feb\u5230\u9
setupwindow.give_a_name=\u7d66\u65b0\u904a\u6232\u8def\u5f91\u8d77\u500b\u540d\u5b57\u5427
setupwindow.new=\u65b0\u5efa
setupwindow.no_empty_name=\u540d\u5b57\u4e0d\u53ef\u70ba\u7a7a
setupwindow.clean=\u6e05\u7406\u904a\u6232\u6587\u4ef6
update.no_browser=\u7121\u6cd5\u6253\u958b\u700f\u89bd\u5668\uff0c\u7db2\u5740\u5df2\u7d93\u5fa9\u88fd\u5230\u526a\u8cbc\u677f\u4e86\uff0c\u60a8\u53ef\u4ee5\u624b\u52d5\u7c98\u8cbc\u7db2\u5740\u6253\u958b\u9801\u9762
update.should_open_link=\u662f\u5426\u524d\u5f80\u767c\u5e03\u9801\u9762\u66f4\u65b0\uff1f