Skip to content

Commit 626cc2f

Browse files
committed
why is a non-null variable null?
1 parent 151b865 commit 626cc2f

File tree

4 files changed

+8
-21
lines changed

4 files changed

+8
-21
lines changed

HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/LibraryDownloadTask.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ boolean download(URL url, File filePath) {
7878
return super.executeTask();
7979
}
8080

81+
@SuppressWarnings("UnusedAssignment")
8182
public static void unpackLibrary(File output, File input)
8283
throws IOException {
8384
HMCLog.log("Unpacking " + input);

HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/MCUtils.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,11 @@ public static MinecraftVersion downloadMinecraft(File gameDir, String id, Downlo
246246
.addTask(new FileDownloadTask(vurl + id + ".json", IOUtils.tryGetCanonicalFile(mvt)).setTag(id + ".json"))
247247
.addTask(new FileDownloadTask(vurl + id + ".jar", IOUtils.tryGetCanonicalFile(mvj)).setTag(id + ".jar"))
248248
.start()) {
249-
MinecraftVersion mv;
250249
try {
251-
mv = C.gson.fromJson(FileUtils.readFileToStringQuietly(mvt), MinecraftVersion.class);
250+
return C.gson.fromJson(FileUtils.readFileToStringQuietly(mvt), MinecraftVersion.class);
252251
} catch (JsonSyntaxException ex) {
253252
HMCLog.err("Failed to parse minecraft version json.", ex);
254-
mv = null;
255253
}
256-
return mv;
257254
}
258255
return null;
259256
}
@@ -328,11 +325,6 @@ public static boolean downloadMinecraftAssetsIndex(File assetsLocation, String a
328325
return false;
329326
}
330327

331-
public static MinecraftRemoteVersions getRemoteMinecraftVersions(DownloadType sourceType) throws IOException {
332-
String result = NetUtils.get(sourceType.getProvider().getVersionsListDownloadURL());
333-
return MinecraftRemoteVersions.fromJson(result);
334-
}
335-
336328
public static String profile = "{\"selectedProfile\": \"(Default)\",\"profiles\": {\"(Default)\": {\"name\": \"(Default)\"}},\"clientToken\": \"88888888-8888-8888-8888-888888888888\"}";
337329

338330
public static void tryWriteProfile(File gameDir) throws IOException {

HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/GameSettingsPanel.form

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@
637637
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="mods.default_information" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
638638
</Property>
639639
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
640-
<Color id="Default Cursor"/>
640+
<Color id="&#x9ed8;&#x8ba4;&#x5149;&#x6807;"/>
641641
</Property>
642642
</Properties>
643643
<Events>

HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/GameSettingsPanel.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ private void cboProfilesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FI
11341134
if (isLoading)
11351135
return;
11361136
profile = getProfile();
1137+
if (profile == null) return;
11371138
if (profile.getMinecraftProvider().getVersionCount() <= 0)
11381139
versionChanged(profile, null);
11391140
prepare(profile);
@@ -1618,23 +1619,16 @@ public void refreshDownloads(final DownloadType provider) {
16181619

16191620
@Override
16201621
public boolean executeTask() {
1621-
final MinecraftRemoteVersions v = MinecraftRemoteVersions.fromJson(tsk.getResult());
1622+
final MinecraftRemoteVersions v = C.gson.fromJson(tsk.getResult(), MinecraftRemoteVersions.class);
16221623
if (v == null || v.versions == null)
16231624
return true;
16241625
SwingUtilities.invokeLater(() -> {
16251626
DefaultTableModel model = (DefaultTableModel) lstDownloads.getModel();
16261627
while (model.getRowCount() > 0)
16271628
model.removeRow(0);
1628-
for (MinecraftRemoteVersion ver : v.versions) {
1629-
Object[] line = new Object[3];
1630-
line[0] = ver.id;
1631-
line[1] = ver.time;
1632-
if (StrUtils.equalsOne(ver.type, "old_beta", "old_alpha", "release", "snapshot"))
1633-
line[2] = C.i18n("versions." + ver.type);
1634-
else
1635-
line[2] = ver.type;
1636-
model.addRow(line);
1637-
}
1629+
for (MinecraftRemoteVersion ver : v.versions)
1630+
model.addRow(new Object[] {ver.id, ver.time,
1631+
StrUtils.equalsOne(ver.type, "old_beta", "old_alpha", "release", "snapshot") ? C.i18n("versions." + ver.type) : ver.type});
16381632
lstDownloads.updateUI();
16391633
});
16401634
return true;

0 commit comments

Comments
 (0)