Fixed lots of bugs

This commit is contained in:
huangyuhui 2016-02-13 18:02:25 +08:00
parent d0c8a95f57
commit 69eaa04ff6
7 changed files with 44 additions and 34 deletions

View File

@ -119,7 +119,6 @@ public final class Main implements Runnable {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
{ {
//PluginManager.getServerPlugin(); //PluginManager.getServerPlugin();
if (IUpgrader.NOW_UPGRADER.parseArguments(getVersionNumber(), args)) if (IUpgrader.NOW_UPGRADER.parseArguments(getVersionNumber(), args))
return; return;
@ -169,6 +168,8 @@ public final class Main implements Runnable {
} }
}); });
} }
if (true)
throw new IOException("???");
try { try {
PluginManager.plugin().showUI(); PluginManager.plugin().showUI();

View File

@ -78,6 +78,8 @@ public final class YggdrasilAuthenticator extends IAuthenticator {
username = JOptionPane.showInputDialog(C.i18n("login.no_charactor")); username = JOptionPane.showInputDialog(C.i18n("login.no_charactor"));
else else
username = selectedProfile.name; username = selectedProfile.name;
if (username == null)
throw new AuthenticationException("No player");
result.setUserName(username); result.setUserName(username);
result.setUserId(selectedProfile == null ? OfflineAuthenticator.getUUIDFromUserName(username) : UUIDTypeAdapter.fromUUID(selectedProfile.id)); result.setUserId(selectedProfile == null ? OfflineAuthenticator.getUUIDFromUserName(username) : UUIDTypeAdapter.fromUUID(selectedProfile.id));
} }

View File

@ -22,7 +22,6 @@ import com.google.gson.JsonSyntaxException;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.List; import java.util.List;
import org.jackhuang.hellominecraft.util.C; import org.jackhuang.hellominecraft.util.C;
import org.jackhuang.hellominecraft.util.logging.HMCLog; import org.jackhuang.hellominecraft.util.logging.HMCLog;
@ -93,13 +92,15 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
MinecraftVersion mv; MinecraftVersion mv;
try { try {
mv = C.GSON.fromJson(FileUtils.readFileToStringQuietly(mvt), MinecraftVersion.class); mv = C.GSON.fromJson(FileUtils.readFileToStringQuietly(mvt), MinecraftVersion.class);
if (mv == null)
throw new JsonSyntaxException("incorrect version");
} catch (JsonSyntaxException ex) { } catch (JsonSyntaxException ex) {
HMCLog.err("Failed to parse minecraft version json.", ex); HMCLog.err("Failed to parse minecraft version json.", ex);
onFailed(k); onFailed(k);
return; return;
} }
String jarURL = vurl + id + ".jar", hash = null; String jarURL = vurl + id + ".jar", hash = null;
if (service.getDownloadType().getProvider().isAllowedToUseSelfURL() && mv.downloads != null) { if (mv != null && mv.downloads != null && service.getDownloadType().getProvider().isAllowedToUseSelfURL()) {
GameDownloadInfo gdi = mv.downloads.get("client"); GameDownloadInfo gdi = mv.downloads.get("client");
if (gdi != null) { if (gdi != null) {
if (gdi.url != null) if (gdi.url != null)

View File

@ -77,6 +77,8 @@ public class MinecraftModService extends IMinecraftModService {
try { try {
if (!ModInfo.isFileMod(f)) if (!ModInfo.isFileMod(f))
return false; return false;
if (!modCache.containsKey(id))
recacheMods(id);
File modsFolder = service.version().getRunDirectory(id, "mods"); File modsFolder = service.version().getRunDirectory(id, "mods");
if (!modsFolder.exists() && !modsFolder.mkdirs()) if (!modsFolder.exists() && !modsFolder.mkdirs())
HMCLog.warn("Failed to make directories: " + modsFolder); HMCLog.warn("Failed to make directories: " + modsFolder);

View File

@ -115,7 +115,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
mcVersion = C.GSON.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class); mcVersion = C.GSON.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
if (mcVersion == null) if (mcVersion == null)
throw new GameException("Wrong json format, got null."); throw new GameException("Wrong json format, got null.");
} catch (IOException | GameException e) { } catch (Exception e) {
HMCLog.warn("Found wrong format json, try to fix it.", e); HMCLog.warn("Found wrong format json, try to fix it.", e);
if (MessageBox.Show(C.i18n("launcher.versions_json_not_formatted", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) { if (MessageBox.Show(C.i18n("launcher.versions_json_not_formatted", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
service.download().downloadMinecraftVersionJson(id); service.download().downloadMinecraftVersionJson(id);
@ -190,6 +190,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
@Override @Override
public File getRunDirectory(String id) { public File getRunDirectory(String id) {
if (getVersionById(id) != null)
if ("version".equals(getVersionById(id).runDir)) if ("version".equals(getVersionById(id).runDir))
return versionRoot(id); return versionRoot(id);
return baseDirectory(); return baseDirectory();

View File

@ -504,8 +504,10 @@ public class MainPagePanel extends AnimatedPanel {
final Consumer<String> versionChanged = this::versionChanged; final Consumer<String> versionChanged = this::versionChanged;
void versionChanged(String selectedVersion) { void versionChanged(String selectedVersion) {
isLoading = true;
((DefaultComboBoxModel) cboVersions.getModel()).setSelectedItem(selectedVersion); ((DefaultComboBoxModel) cboVersions.getModel()).setSelectedItem(selectedVersion);
cboVersions.setToolTipText(selectedVersion); cboVersions.setToolTipText(selectedVersion);
isLoading = false;
} }
final Consumer<Profile> onSelectedProfilesChanged = t -> { final Consumer<Profile> onSelectedProfilesChanged = t -> {

View File

@ -101,6 +101,9 @@ public class AppDataUpgrader extends IUpgrader {
@Override @Override
public boolean call(Object sender, final VersionNumber number) { public boolean call(Object sender, final VersionNumber number) {
((UpdateChecker) sender).requestDownloadLink().reg(map -> { ((UpdateChecker) sender).requestDownloadLink().reg(map -> {
if (MessageBox.Show(C.i18n("update.newest_version") + number.firstVer + "." + number.secondVer + "." + number.thirdVer + "\n"
+ C.i18n("update.should_open_link"),
MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
if (map != null && map.containsKey("pack")) if (map != null && map.containsKey("pack"))
try { try {
String hash = null; String hash = null;
@ -113,9 +116,7 @@ public class AppDataUpgrader extends IUpgrader {
} catch (IOException ex) { } catch (IOException ex) {
HMCLog.err("Failed to create upgrader", ex); HMCLog.err("Failed to create upgrader", ex);
} }
if (MessageBox.Show(C.i18n("update.newest_version") + number.firstVer + "." + number.secondVer + "." + number.thirdVer + "\n" else {
+ C.i18n("update.should_open_link"),
MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
String url = C.URL_PUBLISH; String url = C.URL_PUBLISH;
if (map != null) if (map != null)
if (map.containsKey(OS.os().checked_name)) if (map.containsKey(OS.os().checked_name))