mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-03-13 17:46:58 +08:00
Fixed typesafe again and again
This commit is contained in:
parent
44735b3d4e
commit
0bda79c0d5
@ -1015,7 +1015,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
|
||||
private void btnTestGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTestGameActionPerformed
|
||||
LogWindow.INSTANCE.setVisible(true);
|
||||
MainFrame.INSTANCE.daemon.runGame(Settings.getLastProfile());
|
||||
MainFrame.INSTANCE.daemon.testGame(Settings.getLastProfile());
|
||||
}//GEN-LAST:event_btnTestGameActionPerformed
|
||||
|
||||
private void btnExploreMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnExploreMouseClicked
|
||||
|
@ -89,22 +89,26 @@ public class LaunchingUIDaemon {
|
||||
break;
|
||||
}
|
||||
}
|
||||
String msg = C.i18n("launch.exited_abnormally") + " exit code: " + exitCode;
|
||||
if (errorText != null)
|
||||
msg += ", advice: " + MinecraftCrashAdvicer.getAdvice(FileUtils.readQuietly(new File(errorText)));
|
||||
WebFrame f = new WebFrame(logs);
|
||||
f.setModal(true);
|
||||
f.setTitle(msg);
|
||||
f.setVisible(true);
|
||||
if (!LogWindow.INSTANCE.isVisible()) {
|
||||
String msg = C.i18n("launch.exited_abnormally") + " exit code: " + exitCode;
|
||||
if (errorText != null)
|
||||
msg += ", advice: " + MinecraftCrashAdvicer.getAdvice(FileUtils.readQuietly(new File(errorText)));
|
||||
WebFrame f = new WebFrame(logs);
|
||||
f.setModal(true);
|
||||
f.setTitle(msg);
|
||||
f.setVisible(true);
|
||||
}
|
||||
checkExit((LauncherVisibility) ((ProcessMonitor) event.getSource()).getTag());
|
||||
});
|
||||
HMCLApi.EVENT_BUS.channel(JVMLaunchFailedEvent.class).register(event -> {
|
||||
int exitCode = event.getValue().getExitCode();
|
||||
HMCLog.err("Cannot create jvm, exit code: " + exitCode);
|
||||
WebFrame f = new WebFrame(event.getValue().getStdOutLines().toArray(new String[0]));
|
||||
f.setModal(true);
|
||||
f.setTitle(C.i18n("launch.cannot_create_jvm") + " exit code: " + exitCode);
|
||||
f.setVisible(true);
|
||||
if (!LogWindow.INSTANCE.isVisible()) {
|
||||
WebFrame f = new WebFrame(event.getValue().getStdOutLines().toArray(new String[0]));
|
||||
f.setModal(true);
|
||||
f.setTitle(C.i18n("launch.cannot_create_jvm") + " exit code: " + exitCode);
|
||||
f.setVisible(true);
|
||||
}
|
||||
checkExit((LauncherVisibility) ((ProcessMonitor) event.getSource()).getTag());
|
||||
});
|
||||
}
|
||||
@ -117,6 +121,15 @@ public class LaunchingUIDaemon {
|
||||
}, MainFrame.INSTANCE::failed, Settings.getInstance().getAuthenticator().getPassword());
|
||||
}
|
||||
|
||||
void testGame(Profile profile) {
|
||||
MainFrame.INSTANCE.showMessage(C.i18n("ui.message.launching"));
|
||||
profile.launcher().genLaunchCode(value -> {
|
||||
DefaultPlugin.INSTANCE.saveAuthenticatorConfig();
|
||||
((HMCLGameLauncher.GameLauncherTag) value.getTag()).state = 1;
|
||||
((HMCLGameLauncher.GameLauncherTag) value.getTag()).launcherVisibility = LauncherVisibility.KEEP;
|
||||
}, MainFrame.INSTANCE::failed, Settings.getInstance().getAuthenticator().getPassword());
|
||||
}
|
||||
|
||||
void makeLaunchScript(Profile profile) {
|
||||
MainFrame.INSTANCE.showMessage(C.i18n("ui.message.launching"));
|
||||
profile.launcher().genLaunchCode(value -> {
|
||||
|
@ -44,7 +44,7 @@ public class LogWindowOutputStream extends OutputStream {
|
||||
|
||||
@Override
|
||||
public final void write(byte[] arr, int off, int len) {
|
||||
append(new String(arr, off, len, Charsets.UTF_8));
|
||||
append(new String(arr, off, len));
|
||||
}
|
||||
|
||||
private void append(final String str) {
|
||||
@ -55,6 +55,6 @@ public class LogWindowOutputStream extends OutputStream {
|
||||
|
||||
@Override
|
||||
public final void write(int i) {
|
||||
append(new String(new byte[] { (byte) i }, Charsets.UTF_8));
|
||||
append(new String(new byte[] { (byte) i }));
|
||||
}
|
||||
}
|
||||
|
@ -56,9 +56,9 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
||||
return downloadLibraries;
|
||||
MinecraftVersion v = mv.resolve(service.version());
|
||||
for (IMinecraftLibrary l : v.getLibraries())
|
||||
if (l != null && l.allow() && l.getDownloadURL(service.getDownloadType().name()) != null) {
|
||||
if (l != null && l.allow()) {
|
||||
File ff = service.version().getLibraryFile(mv, l);
|
||||
if (!ff.exists()) {
|
||||
if (!ff.exists() && l.getDownloadURL(service.getDownloadType().name()) != null) {
|
||||
String libURL = l.getDownloadURL(service.getDownloadType().name());
|
||||
if (libURL != null)
|
||||
downloadLibraries.add(new DownloadLibraryJob(l, libURL, ff));
|
||||
|
@ -19,6 +19,7 @@ package org.jackhuang.hmcl.core.version;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.jackhuang.hmcl.core.download.DownloadType;
|
||||
import org.jackhuang.hmcl.util.StrUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -58,7 +59,7 @@ public class GameDownloadInfo implements Cloneable {
|
||||
* @return the download url
|
||||
*/
|
||||
public String getUrl(DownloadType dt, boolean allowSelf) {
|
||||
if (url != null && allowSelf)
|
||||
if (StrUtils.isNotBlank(url) && allowSelf)
|
||||
return dt.getProvider().getParsedDownloadURL(url);
|
||||
else
|
||||
return getCustomizedURL(dt);
|
||||
|
@ -35,14 +35,12 @@ public class LibraryDownloadInfo extends GameDownloadInfo {
|
||||
|
||||
@Override
|
||||
public String getUrl(DownloadType dt, boolean allowSelf) {
|
||||
String myURL = (forgeURL == null ? dt.getProvider().getLibraryDownloadURL() : forgeURL);
|
||||
String myURL = dt.getProvider().getParsedDownloadURL(IOUtils.addURLSeparator(forgeURL == null ? dt.getProvider().getLibraryDownloadURL() : forgeURL) + path.replace('\\', '/'));
|
||||
if (StrUtils.isNotBlank(url) && allowSelf)
|
||||
myURL = dt.getProvider().getParsedDownloadURL(url);
|
||||
if (!myURL.endsWith(".jar"))
|
||||
if (path == null)
|
||||
return null;
|
||||
else
|
||||
myURL = IOUtils.addURLSeparator(myURL) + path.replace('\\', '/');
|
||||
return myURL;
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,9 @@ import com.google.gson.annotations.SerializedName;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import org.jackhuang.hmcl.api.HMCLApi;
|
||||
import org.jackhuang.hmcl.util.sys.OS;
|
||||
import org.jackhuang.hmcl.util.sys.Platform;
|
||||
import org.jackhuang.hmcl.util.StrUtils;
|
||||
import org.jackhuang.hmcl.api.Wrapper;
|
||||
|
||||
/**
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user