why is a non-null variable null?

This commit is contained in:
huanghongxun 2015-11-29 18:19:50 +08:00
parent 151b865dc5
commit 626cc2f6ed
4 changed files with 8 additions and 21 deletions

View File

@ -78,6 +78,7 @@ public class LibraryDownloadTask extends FileDownloadTask {
return super.executeTask(); return super.executeTask();
} }
@SuppressWarnings("UnusedAssignment")
public static void unpackLibrary(File output, File input) public static void unpackLibrary(File output, File input)
throws IOException { throws IOException {
HMCLog.log("Unpacking " + input); HMCLog.log("Unpacking " + input);

View File

@ -246,14 +246,11 @@ public final class MCUtils {
.addTask(new FileDownloadTask(vurl + id + ".json", IOUtils.tryGetCanonicalFile(mvt)).setTag(id + ".json")) .addTask(new FileDownloadTask(vurl + id + ".json", IOUtils.tryGetCanonicalFile(mvt)).setTag(id + ".json"))
.addTask(new FileDownloadTask(vurl + id + ".jar", IOUtils.tryGetCanonicalFile(mvj)).setTag(id + ".jar")) .addTask(new FileDownloadTask(vurl + id + ".jar", IOUtils.tryGetCanonicalFile(mvj)).setTag(id + ".jar"))
.start()) { .start()) {
MinecraftVersion mv;
try { try {
mv = C.gson.fromJson(FileUtils.readFileToStringQuietly(mvt), MinecraftVersion.class); return C.gson.fromJson(FileUtils.readFileToStringQuietly(mvt), MinecraftVersion.class);
} catch (JsonSyntaxException ex) { } catch (JsonSyntaxException ex) {
HMCLog.err("Failed to parse minecraft version json.", ex); HMCLog.err("Failed to parse minecraft version json.", ex);
mv = null;
} }
return mv;
} }
return null; return null;
} }
@ -328,11 +325,6 @@ public final class MCUtils {
return false; return false;
} }
public static MinecraftRemoteVersions getRemoteMinecraftVersions(DownloadType sourceType) throws IOException {
String result = NetUtils.get(sourceType.getProvider().getVersionsListDownloadURL());
return MinecraftRemoteVersions.fromJson(result);
}
public static String profile = "{\"selectedProfile\": \"(Default)\",\"profiles\": {\"(Default)\": {\"name\": \"(Default)\"}},\"clientToken\": \"88888888-8888-8888-8888-888888888888\"}"; public static String profile = "{\"selectedProfile\": \"(Default)\",\"profiles\": {\"(Default)\": {\"name\": \"(Default)\"}},\"clientToken\": \"88888888-8888-8888-8888-888888888888\"}";
public static void tryWriteProfile(File gameDir) throws IOException { public static void tryWriteProfile(File gameDir) throws IOException {

View File

@ -637,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;)"/> <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>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Default Cursor"/> <Color id="&#x9ed8;&#x8ba4;&#x5149;&#x6807;"/>
</Property> </Property>
</Properties> </Properties>
<Events> <Events>

View File

@ -1134,6 +1134,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
if (isLoading) if (isLoading)
return; return;
profile = getProfile(); profile = getProfile();
if (profile == null) return;
if (profile.getMinecraftProvider().getVersionCount() <= 0) if (profile.getMinecraftProvider().getVersionCount() <= 0)
versionChanged(profile, null); versionChanged(profile, null);
prepare(profile); prepare(profile);
@ -1618,23 +1619,16 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
@Override @Override
public boolean executeTask() { public boolean executeTask() {
final MinecraftRemoteVersions v = MinecraftRemoteVersions.fromJson(tsk.getResult()); final MinecraftRemoteVersions v = C.gson.fromJson(tsk.getResult(), MinecraftRemoteVersions.class);
if (v == null || v.versions == null) if (v == null || v.versions == null)
return true; return true;
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
DefaultTableModel model = (DefaultTableModel) lstDownloads.getModel(); DefaultTableModel model = (DefaultTableModel) lstDownloads.getModel();
while (model.getRowCount() > 0) while (model.getRowCount() > 0)
model.removeRow(0); model.removeRow(0);
for (MinecraftRemoteVersion ver : v.versions) { for (MinecraftRemoteVersion ver : v.versions)
Object[] line = new Object[3]; model.addRow(new Object[] {ver.id, ver.time,
line[0] = ver.id; StrUtils.equalsOne(ver.type, "old_beta", "old_alpha", "release", "snapshot") ? C.i18n("versions." + ver.type) : ver.type});
line[1] = ver.time;
if (StrUtils.equalsOne(ver.type, "old_beta", "old_alpha", "release", "snapshot"))
line[2] = C.i18n("versions." + ver.type);
else
line[2] = ver.type;
model.addRow(line);
}
lstDownloads.updateUI(); lstDownloads.updateUI();
}); });
return true; return true;