fix bugs with Swing.
This commit is contained in:
@@ -62,11 +62,11 @@ dependencies {
|
||||
}
|
||||
|
||||
retrolambda {
|
||||
javaVersion = JavaVersion.VERSION_1_7
|
||||
javaVersion = JavaVersion.VERSION_1_6
|
||||
}
|
||||
|
||||
jar {
|
||||
jar.classifier = 'base'
|
||||
//jar.classifier = 'base'
|
||||
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
|
||||
|
||||
manifest {
|
||||
@@ -117,7 +117,7 @@ task makeExecutable(dependsOn: jar) << {
|
||||
launch4j {
|
||||
launch4jCmd = 'D:\\Develop\\Java\\Launch4j\\launch4j.exe'
|
||||
supportUrl = 'http://www.mcbbs.net/thread-142335-1-1.html'
|
||||
jreMinVersion = '1.7.0'
|
||||
jreMinVersion = '1.6.0'
|
||||
|
||||
mainClassName = mainClass
|
||||
icon = new File(project.buildDir, '../icon.ico').absolutePath
|
||||
@@ -136,6 +136,6 @@ processResources {
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn proguard
|
||||
//build.dependsOn proguard
|
||||
//makeExecutable.dependsOn proguard
|
||||
//build.dependsOn makeExecutable
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.launch;
|
||||
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -146,7 +147,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
// If the scale new format existent file is lower then 0.1, use the old format.
|
||||
if (cnt * 10 < tot) return assetsDir;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (IOException | JsonSyntaxException e) {
|
||||
HMCLog.warn("Failed to create virutal assets.", e);
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +172,7 @@ public final class Profile {
|
||||
}
|
||||
|
||||
public File getFolder(String folder) {
|
||||
if (getSelectedMinecraftVersion() == null) return new File(getCanonicalGameDirFile(), folder);
|
||||
return new File(getMinecraftProvider().getRunDirectory(getSelectedMinecraftVersion().id), folder);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.Main;
|
||||
@@ -77,6 +76,8 @@ public final class Settings {
|
||||
temp.add(new Java("Custom", null));
|
||||
if (OS.os() == OS.WINDOWS)
|
||||
temp.addAll(Java.queryAllJavaHomeInWindowsByReg());
|
||||
if (OS.os() == OS.OSX)
|
||||
temp.addAll(Java.queryAllJDKInMac());
|
||||
JAVA = Collections.unmodifiableList(temp);
|
||||
}
|
||||
|
||||
@@ -124,7 +125,6 @@ public final class Settings {
|
||||
}
|
||||
|
||||
public static void setVersion(Profile ver) {
|
||||
Objects.requireNonNull(ver);
|
||||
getVersions().put(ver.getName(), ver);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jackhuang.hellominecraft.launcher.utils;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.Main;
|
||||
@@ -60,7 +61,7 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
else System.out.println(text);
|
||||
SwingUtilities.invokeLater(() -> LogWindow.instance.showAsCrashWindow(UpdateChecker.OUT_DATED));
|
||||
if (!UpdateChecker.OUT_DATED)
|
||||
reportToServer(text);
|
||||
reportToServer(text, e);
|
||||
} catch (Throwable ex) {
|
||||
try {
|
||||
MessageBox.Show(e.getMessage() + "\n" + ex.getMessage(), "ERROR", MessageBox.ERROR_MESSAGE);
|
||||
@@ -71,7 +72,12 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
void reportToServer(String text) {
|
||||
private static final HashSet<String> throwableSet = new HashSet<>();
|
||||
|
||||
void reportToServer(String text, Throwable t) {
|
||||
String s = StrUtils.getStackTrace(t);
|
||||
if (throwableSet.contains(s)) return;
|
||||
throwableSet.add(s);
|
||||
new Thread(() -> {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("CrashReport", text);
|
||||
|
||||
@@ -72,6 +72,11 @@ public class BMCLAPIDownloadProvider implements IDownloadProvider {
|
||||
return "http://bmclapi2.bangbang93.com/assets/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParsedLibraryDownloadURL(String str) {
|
||||
return str.replace("http://files.minecraftforge.net/maven", "http://bmclapi2.bangbang93.com/maven");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowedToUseSelfURL() {
|
||||
return false;
|
||||
|
||||
@@ -41,6 +41,8 @@ public interface IDownloadProvider {
|
||||
String getVersionsListDownloadURL();
|
||||
|
||||
String getAssetsDownloadURL();
|
||||
|
||||
String getParsedLibraryDownloadURL(String str);
|
||||
|
||||
boolean isAllowedToUseSelfURL();
|
||||
}
|
||||
|
||||
@@ -77,4 +77,9 @@ public class MojangDownloadProvider implements IDownloadProvider {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParsedLibraryDownloadURL(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,10 +24,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.TreeMap;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
@@ -223,23 +221,26 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
|
||||
@Override
|
||||
public List<ModInfo> listMods() {
|
||||
if (profile.getSelectedMinecraftVersion() == null) return Arrays.asList();
|
||||
if (profile.getSelectedMinecraftVersion() == null) return new ArrayList<>();
|
||||
File modsFolder = new File(getRunDirectory(profile.getSelectedMinecraftVersion().id), "mods");
|
||||
ArrayList<ModInfo> mods = new ArrayList<>();
|
||||
Queue<File> queue = new LinkedList<>();
|
||||
queue.add(modsFolder);
|
||||
while (!queue.isEmpty()) {
|
||||
File dir = queue.poll();
|
||||
File[] fs = dir.listFiles();
|
||||
if (fs != null)
|
||||
for (File f : fs)
|
||||
if (ModInfo.isFileMod(f)) {
|
||||
ModInfo m = ModInfo.readModInfo(f);
|
||||
if (m != null)
|
||||
mods.add(m);
|
||||
} else if (f.isDirectory())
|
||||
queue.add(f);
|
||||
}
|
||||
File[] fs = modsFolder.listFiles();
|
||||
if (fs != null)
|
||||
for (File f : fs)
|
||||
if (ModInfo.isFileMod(f)) {
|
||||
ModInfo m = ModInfo.readModInfo(f);
|
||||
if (m != null)
|
||||
mods.add(m);
|
||||
} else if (f.isDirectory()) {
|
||||
File[] ss = f.listFiles();
|
||||
if (ss != null)
|
||||
for (File ff : ss)
|
||||
if (ModInfo.isFileMod(ff)) {
|
||||
ModInfo m = ModInfo.readModInfo(ff);
|
||||
if (m != null)
|
||||
mods.add(m);
|
||||
}
|
||||
}
|
||||
Collections.sort(mods);
|
||||
return mods;
|
||||
}
|
||||
@@ -255,7 +256,7 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
||||
File ff = l.getFilePath(baseFolder);
|
||||
if (!ff.exists()) {
|
||||
String libURL = downloadType.getProvider().getLibraryDownloadURL() + "/";
|
||||
libURL = l.getDownloadURL(libURL, downloadType);
|
||||
libURL = downloadType.getProvider().getParsedLibraryDownloadURL(l.getDownloadURL(libURL, downloadType));
|
||||
if (libURL != null)
|
||||
downloadLibraries.add(new DownloadLibraryJob(l.name, libURL, ff));
|
||||
}
|
||||
|
||||
@@ -175,7 +175,6 @@ public class GameSettingsPanel extends javax.swing.JPanel implements DropTargetL
|
||||
ppmManage.add(itm);
|
||||
//</editor-fold>
|
||||
|
||||
lstExternalMods.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
||||
if (lstExternalMods.getColumnModel().getColumnCount() > 0) {
|
||||
lstExternalMods.getColumnModel().getColumn(0).setMinWidth(17);
|
||||
lstExternalMods.getColumnModel().getColumn(0).setPreferredWidth(17);
|
||||
@@ -1143,11 +1142,12 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
String url;
|
||||
File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "forge-installer.jar");
|
||||
if (v.installer != null) {
|
||||
url = v.installer;
|
||||
url = Settings.getInstance().getDownloadSource().getProvider().getParsedLibraryDownloadURL(v.installer);
|
||||
TaskWindow.getInstance()
|
||||
.addTask(new FileDownloadTask(url, filepath).setTag("forge"))
|
||||
.addTask(new ForgeInstaller(profile.getMinecraftProvider(), filepath, v))
|
||||
.start();
|
||||
refreshVersions();
|
||||
}
|
||||
}//GEN-LAST:event_btnDownloadForgeActionPerformed
|
||||
|
||||
@@ -1169,6 +1169,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
.addTask(new FileDownloadTask(filepath).registerPreviousResult(task).setTag("optifine"))
|
||||
.addTask(new OptiFineInstaller(profile, v.selfVersion, filepath))
|
||||
.start();
|
||||
refreshVersions();
|
||||
}
|
||||
}//GEN-LAST:event_btnDownloadOptifineActionPerformed
|
||||
|
||||
@@ -1186,6 +1187,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
TaskWindow.getInstance()
|
||||
.addTask(task).addTask(new LiteLoaderInstaller(profile, (LiteLoaderInstallerVersion) v).registerPreviousResult(task))
|
||||
.start();
|
||||
refreshVersions();
|
||||
}//GEN-LAST:event_btnInstallLiteLoaderActionPerformed
|
||||
|
||||
private void btnRefreshLiteLoaderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshLiteLoaderActionPerformed
|
||||
@@ -1369,6 +1371,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
try {
|
||||
if (!ModInfo.isFileMod(f) || mods == null) return false;
|
||||
File newf = profile.getFolder("mods");
|
||||
if(newf == null) return false;
|
||||
newf.mkdirs();
|
||||
newf = new File(newf, f.getName());
|
||||
FileUtils.copyFile(f, newf);
|
||||
@@ -1537,7 +1540,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
if (mcVersion == null || profile == null) return;
|
||||
type.getList((value) -> {
|
||||
if (value != null)
|
||||
TaskWindow.getInstance().addTask(type.getDownloadTask(Settings.getInstance().getDownloadSource().getProvider())).start();
|
||||
SwingUtilities.invokeLater(() -> TaskWindow.getInstance().addTask(type.getDownloadTask(Settings.getInstance().getDownloadSource().getProvider())).start());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1694,13 +1697,22 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
// </editor-fold>
|
||||
// <editor-fold>
|
||||
List<ModInfo> mods;
|
||||
private final Object lockMod = new Object();
|
||||
|
||||
private void reloadMods() {
|
||||
mods = profile.getMinecraftProvider().listMods();
|
||||
SwingUtils.clearDefaultTable(lstExternalMods);
|
||||
DefaultTableModel model = (DefaultTableModel) lstExternalMods.getModel();
|
||||
for (ModInfo info : mods)
|
||||
model.addRow(new Object[]{info.isActive(), info.getFileName(), info.version});
|
||||
new Thread(() -> {
|
||||
synchronized (lockMod) {
|
||||
mods = profile.getMinecraftProvider().listMods();
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
synchronized (lockMod) {
|
||||
SwingUtils.clearDefaultTable(lstExternalMods);
|
||||
DefaultTableModel model = (DefaultTableModel) lstExternalMods.getModel();
|
||||
for (ModInfo info : mods)
|
||||
model.addRow(new Object[]{info.isActive(), info.getFileName(), info.version});
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.jackhuang.hellominecraft.logging.logger.Logger;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
import org.jackhuang.mojang.authlib.properties.Property;
|
||||
@@ -30,7 +29,6 @@ public abstract class BaseUserAuthentication
|
||||
private UserType userType;
|
||||
|
||||
protected BaseUserAuthentication(AuthenticationService authenticationService) {
|
||||
Objects.requireNonNull(authenticationService);
|
||||
this.authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.jackhuang.hellominecraft.logging.logger.Logger;
|
||||
import org.jackhuang.hellominecraft.utils.system.IOUtils;
|
||||
import org.jackhuang.hellominecraft.utils.NetUtils;
|
||||
import org.jackhuang.hellominecraft.utils.Utils;
|
||||
|
||||
public abstract class HttpAuthenticationService extends BaseAuthenticationService {
|
||||
|
||||
@@ -20,7 +20,6 @@ public abstract class HttpAuthenticationService extends BaseAuthenticationServic
|
||||
private final Proxy proxy;
|
||||
|
||||
protected HttpAuthenticationService(Proxy proxy) {
|
||||
Objects.requireNonNull(proxy);
|
||||
this.proxy = proxy;
|
||||
}
|
||||
|
||||
@@ -29,7 +28,6 @@ public abstract class HttpAuthenticationService extends BaseAuthenticationServic
|
||||
}
|
||||
|
||||
protected HttpURLConnection createUrlConnection(URL url) throws IOException {
|
||||
Objects.requireNonNull(url);
|
||||
LOGGER.debug("Opening connection to " + url);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(this.proxy);
|
||||
connection.setConnectTimeout(15000);
|
||||
@@ -39,9 +37,9 @@ public abstract class HttpAuthenticationService extends BaseAuthenticationServic
|
||||
}
|
||||
|
||||
public String performPostRequest(URL url, String post, String contentType) throws IOException {
|
||||
Objects.requireNonNull(url);
|
||||
Objects.requireNonNull(post);
|
||||
Objects.requireNonNull(contentType);
|
||||
Utils.requireNonNull(url);
|
||||
Utils.requireNonNull(post);
|
||||
Utils.requireNonNull(contentType);
|
||||
HttpURLConnection connection = createUrlConnection(url);
|
||||
byte[] postAsBytes = post.getBytes("UTF-8");
|
||||
|
||||
@@ -90,7 +88,7 @@ public abstract class HttpAuthenticationService extends BaseAuthenticationServic
|
||||
|
||||
public String performGetRequest(URL url)
|
||||
throws IOException {
|
||||
Objects.requireNonNull(url);
|
||||
Utils.requireNonNull(url);
|
||||
HttpURLConnection connection = createUrlConnection(url);
|
||||
|
||||
LOGGER.debug("Reading data from " + url);
|
||||
|
||||
Reference in New Issue
Block a user