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();
}
@SuppressWarnings("UnusedAssignment")
public static void unpackLibrary(File output, File input)
throws IOException {
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 + ".jar", IOUtils.tryGetCanonicalFile(mvj)).setTag(id + ".jar"))
.start()) {
MinecraftVersion mv;
try {
mv = C.gson.fromJson(FileUtils.readFileToStringQuietly(mvt), MinecraftVersion.class);
return C.gson.fromJson(FileUtils.readFileToStringQuietly(mvt), MinecraftVersion.class);
} catch (JsonSyntaxException ex) {
HMCLog.err("Failed to parse minecraft version json.", ex);
mv = null;
}
return mv;
}
return null;
}
@ -328,11 +325,6 @@ public final class MCUtils {
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 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;)"/>
</Property>
<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>
</Properties>
<Events>

View File

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