2
0
mirror of https://github.com/HMCL-dev/HMCL.git synced 2025-04-12 18:30:26 +08:00

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -13,7 +13,6 @@
</SyntheticProperties>
<Events>
<EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosed"/>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosing"/>
</Events>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>

@ -121,9 +121,6 @@ public class TaskWindow extends javax.swing.JDialog
public void windowClosed(java.awt.event.WindowEvent evt) {
formWindowClosed(evt);
}
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
btnCancel.setText(bundle.getString("taskwindow.cancel")); // NOI18N
@ -190,10 +187,6 @@ public class TaskWindow extends javax.swing.JDialog
taskList = null;
}//GEN-LAST:event_formWindowClosed
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
// TODO add your handling code here:
}//GEN-LAST:event_formWindowClosing
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnCancel;
private javax.swing.JTable lstDownload;
@ -228,10 +221,11 @@ public class TaskWindow extends javax.swing.JDialog
@Override
public void onDoing(Task task) {
if (task == null) return;
task.setProgressProviderListener(this);
SwingUtilities.invokeLater(() -> {
if (taskList == null || task == null)
if (taskList == null)
return;
tasks.add(task);
progresses.add(0);

@ -1,23 +0,0 @@
<!--
Copyright 2013 Netflix, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<body>
<p>Operators that allow composing Observables to transform and
manipulate data in an asynchronous, functional and thread-safe manner.</p>
<p>The operators are all exposed via the ObservableExtensions class</p>
</body>

@ -1,16 +0,0 @@
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Hello Minecraft! 开服器</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
</body>
</html>