mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-13 05:46:59 -04:00
why is a non-null variable null?
This commit is contained in:
parent
151b865dc5
commit
626cc2f6ed
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -637,7 +637,7 @@
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="mods.default_information" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Default Cursor"/>
|
||||
<Color id="默认光标"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user