Removed redundant codes

This commit is contained in:
huanghongxun
2015-12-12 13:01:18 +08:00
parent 8186482a11
commit 68a734adb0
17 changed files with 33 additions and 257 deletions

View File

@@ -46,6 +46,12 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
public boolean checkThrowable(Throwable e) {
String s = StrUtils.getStackTrace(e);
if (s.contains("MessageBox") || s.contains("AWTError")) {
return false;
} else if (s.contains("JFileChooser") || s.contains("JceSecurityManager")) {
System.out.println("Is not your operating system installed completely? ");
return false;
}
if (s.contains("sun.awt.shell.Win32ShellFolder2") || s.contains("UnsatisfiedLinkError")) {
System.out.println(C.i18n("crash.user_fault"));
try {
@@ -112,6 +118,10 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
}
}
}
void showMessage() {
}
private static final HashSet<String> throwableSet = new HashSet<>();

View File

@@ -1,31 +0,0 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hellominecraft.launcher.utils.assets;
import java.util.ArrayList;
/**
*
* @author huangyuhui
*/
public interface AssetsLoaderListener {
void OnDone(ArrayList<Contents> loader);
void OnFailed(Exception e);
}

View File

@@ -27,7 +27,7 @@ public class BMCLAPIDownloadProvider extends IDownloadProvider {
@Override
public InstallerVersionList getForgeInstaller() {
return org.jackhuang.hellominecraft.launcher.utils.installers.forge.vanilla.MinecraftForgeVersionList.getInstance();
return org.jackhuang.hellominecraft.launcher.utils.installers.forge.MinecraftForgeVersionList.getInstance();
}
@Override

View File

@@ -28,7 +28,7 @@ public class MojangDownloadProvider extends IDownloadProvider {
@Override
public InstallerVersionList getForgeInstaller() {
return org.jackhuang.hellominecraft.launcher.utils.installers.forge.vanilla.MinecraftForgeVersionList.getInstance();
return org.jackhuang.hellominecraft.launcher.utils.installers.forge.MinecraftForgeVersionList.getInstance();
}
@Override

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hellominecraft.launcher.utils.installers.forge.vanilla;
package org.jackhuang.hellominecraft.launcher.utils.installers.forge;
/**
*

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hellominecraft.launcher.utils.installers.forge.vanilla;
package org.jackhuang.hellominecraft.launcher.utils.installers.forge;
import java.util.ArrayList;
import java.util.Collections;

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hellominecraft.launcher.utils.installers.forge.vanilla;
package org.jackhuang.hellominecraft.launcher.utils.installers.forge;
import java.util.Map;

View File

@@ -1,28 +0,0 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hellominecraft.launcher.utils.installers.forge.bmcl;
/**
*
* @author huangyuhui
*/
public class Downloads {
public String changelog;
public String[] universal, src, javadoc, installer;
}

View File

@@ -1,104 +0,0 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hellominecraft.launcher.utils.installers.forge.bmcl;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.ArrayUtils;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.launcher.utils.installers.InstallerVersionList;
import org.jackhuang.hellominecraft.utils.NetUtils;
/**
*
* @author huangyuhui
*/
public class ForgeBMCLVersionList extends InstallerVersionList {
private static ForgeBMCLVersionList instance;
public static ForgeBMCLVersionList getInstance() {
if (instance == null)
instance = new ForgeBMCLVersionList();
return instance;
}
public ArrayList<ForgeVersion> root;
public Map<String, List<InstallerVersion>> versionMap;
public List<InstallerVersion> versions;
@Override
public void refreshList(String[] neededVersions) throws Exception {
if (versionMap == null) {
versionMap = new HashMap<>();
versions = new ArrayList<>();
}
for (String x : neededVersions) {
if (versionMap.containsKey(x))
continue;
String s = NetUtils.get("http://bmclapi2.bangbang93.com/forge/minecraft/" + x);
if (s == null)
continue;
try {
root = C.gson.fromJson(s, new TypeToken<ArrayList<ForgeVersion>>() {
}.getType());
for (ForgeVersion v : root) {
InstallerVersion iv = new InstallerVersion(v.version, StrUtils.formatVersion(v.minecraft));
List<InstallerVersion> al = ArrayUtils.tryGetMapWithList(versionMap, StrUtils.formatVersion(v.minecraft));
iv.changelog = v.downloads.changelog;
iv.installer = ArrayUtils.getEnd(v.downloads.installer);
iv.universal = ArrayUtils.getEnd(v.downloads.universal);
al.add(iv);
versions.add(iv);
}
} catch (JsonSyntaxException e) {
HMCLog.warn("Failed to parse BMCLAPI2 response.", e);
}
}
Collections.sort(versions, new InstallerVersionComparator());
}
@Override
public List<InstallerVersion> getVersions(String mcVersion) {
if (versions == null || versionMap == null)
return null;
if (StrUtils.isBlank(mcVersion))
return versions;
List c = versionMap.get(mcVersion);
if (c == null)
return versions;
Collections.sort(c, InstallerVersionComparator.INSTANCE);
return c;
}
@Override
public String getName() {
return "Forge - BMCLAPI (By: bangbang93)";
}
}

View File

@@ -1,28 +0,0 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hellominecraft.launcher.utils.installers.forge.bmcl;
/**
*
* @author huangyuhui
*/
public class ForgeVersion {
public String time, minecraft, version, _id, __v;
public Downloads downloads;
}

View File

@@ -136,7 +136,7 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtGameDir" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
<Component id="lblGameDir" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -173,7 +173,7 @@
<Component id="lblDimension" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtWidth" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="95" max="32767" attributes="0"/>
<EmptySpace pref="113" max="32767" attributes="0"/>
<Component id="btnDownloadAllAssets" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -390,7 +390,7 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtJavaArgs" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
<Component id="lblJavaArgs" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -413,7 +413,7 @@
<Component id="lblServerIP" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtServerIP" min="-2" pref="26" max="-2" attributes="0"/>
<EmptySpace pref="90" max="32767" attributes="0"/>
<EmptySpace pref="102" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="chkDebug" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkNoJVMArgs" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -554,8 +554,8 @@
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jScrollPane1" pref="773" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="779" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="btnRemoveMod" min="-2" max="-2" attributes="0"/>
<Component id="btnAddMod" alignment="0" min="-2" max="-2" attributes="0"/>

View File

@@ -459,7 +459,7 @@ public final class GameSettingsPanel extends javax.swing.JPanel implements DropT
pnlSettingsLayout.setVerticalGroup(
pnlSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlSettingsLayout.createSequentialGroup()
.addContainerGap()
.addGap(0, 0, 0)
.addGroup(pnlSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtGameDir, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblGameDir)
@@ -490,7 +490,7 @@ public final class GameSettingsPanel extends javax.swing.JPanel implements DropT
.addComponent(lblDimensionX, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblDimension)
.addComponent(txtWidth, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 95, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 113, Short.MAX_VALUE)
.addComponent(btnDownloadAllAssets)
.addContainerGap())
);
@@ -594,7 +594,7 @@ public final class GameSettingsPanel extends javax.swing.JPanel implements DropT
pnlAdvancedSettingsLayout.setVerticalGroup(
pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
.addContainerGap()
.addGap(0, 0, 0)
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtJavaArgs, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblJavaArgs))
@@ -614,7 +614,7 @@ public final class GameSettingsPanel extends javax.swing.JPanel implements DropT
.addComponent(lblServerIP)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtServerIP, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 90, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 102, Short.MAX_VALUE)
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(chkDebug)
.addComponent(chkNoJVMArgs)
@@ -664,8 +664,8 @@ public final class GameSettingsPanel extends javax.swing.JPanel implements DropT
.addGroup(pnlModManagementContentLayout.createSequentialGroup()
.addGroup(pnlModManagementContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlModManagementContentLayout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 773, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 779, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlModManagementContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnRemoveMod)
.addComponent(btnAddMod)))

View File

@@ -19,6 +19,7 @@ package org.jackhuang.hellominecraft.launcher.views;
import java.util.List;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.launcher.settings.Settings;
@@ -145,7 +146,9 @@ public class InstallerPanel extends javax.swing.JPanel {
}
public void loadVersions() {
versions = loadVersions(list, lstInstallers);
SwingUtilities.invokeLater(() -> {
versions = loadVersions(list, lstInstallers);
});
}
private List<InstallerVersionList.InstallerVersion> loadVersions(InstallerVersionList list, JTable table) {