use of net.technicpack.launchercore.exception.BuildInaccessibleException in project LauncherV3 by TechnicPack.
the class Installer method internalInstallAndRun.
protected void internalInstallAndRun(final ResourceLoader resources, final ModpackModel pack, final String build, final boolean doFullInstall, final LauncherFrame frame, final DownloadListener listener, final boolean doLaunch) {
runningThread = new Thread(new Runnable() {
@Override
public void run() {
boolean everythingWorked = false;
try {
MojangVersion version = null;
InstallTasksQueue<MojangVersion> tasksQueue = new InstallTasksQueue<MojangVersion>(listener);
MojangVersionBuilder versionBuilder = createVersionBuilder(pack, tasksQueue);
if (!pack.isLocalOnly() && build != null && !build.isEmpty()) {
buildTasksQueue(tasksQueue, resources, pack, build, doFullInstall, versionBuilder);
version = installer.installPack(tasksQueue, pack, build);
} else {
version = versionBuilder.buildVersionFromKey(null);
if (version != null)
pack.initDirectories();
}
if (doLaunch) {
if (version == null) {
throw new PackNotAvailableOfflineException(pack.getDisplayName());
}
boolean usingMojangJava = version.getJavaVersion() != null && settings.shouldUseMojangJava();
JavaVersionRepository javaVersions = launcher.getJavaVersions();
Memory memoryObj = Memory.getClosestAvailableMemory(Memory.getMemoryFromId(settings.getMemory()), javaVersions.getSelectedVersion().is64Bit());
long memory = memoryObj.getMemoryMB();
String versionNumber = javaVersions.getSelectedVersion().getVersionNumber();
RunData data = pack.getRunData();
if (data != null && !data.isRunDataValid(memory, versionNumber, usingMojangJava)) {
FixRunDataDialog dialog = new FixRunDataDialog(frame, resources, data, javaVersions, memoryObj, !settings.shouldAutoAcceptModpackRequirements(), usingMojangJava);
dialog.setVisible(true);
if (dialog.getResult() == FixRunDataDialog.Result.ACCEPT) {
memoryObj = dialog.getRecommendedMemory();
memory = memoryObj.getMemoryMB();
IJavaVersion recommendedJavaVersion = dialog.getRecommendedJavaVersion();
javaVersions.selectVersion(recommendedJavaVersion.getVersionNumber(), recommendedJavaVersion.is64Bit());
if (dialog.shouldRemember()) {
settings.setAutoAcceptModpackRequirements(true);
}
} else
return;
}
if (!usingMojangJava && RunData.isJavaVersionAtLeast(versionNumber, "1.9")) {
int result = JOptionPane.showConfirmDialog(frame, resources.getString("launcher.jverwarning", versionNumber), resources.getString("launcher.jverwarning.title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (result != JOptionPane.YES_OPTION)
return;
}
LaunchAction launchAction = settings.getLaunchAction();
if (launchAction == null || launchAction == LaunchAction.HIDE) {
launcherUnhider = new LauncherUnhider(settings, frame);
} else
launcherUnhider = null;
LaunchOptions options = new LaunchOptions(pack.getDisplayName(), packIconMapper.getImageLocation(pack).getAbsolutePath(), settings);
launcher.launch(pack, memory, options, launcherUnhider, version);
if (launchAction == null || launchAction == LaunchAction.HIDE) {
frame.setVisible(false);
} else if (launchAction == LaunchAction.NOTHING) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
frame.launchCompleted();
}
});
} else if (launchAction == LaunchAction.CLOSE) {
System.exit(0);
}
}
everythingWorked = true;
} catch (InterruptedException e) {
boolean cancelledByUser = false;
synchronized (cancelLock) {
if (isCancelledByUser) {
cancelledByUser = true;
isCancelledByUser = false;
}
}
// Canceled by user
if (!cancelledByUser) {
if (e.getCause() != null)
Utils.getLogger().info("Cancelled by exception.");
else
Utils.getLogger().info("Cancelled by code.");
e.printStackTrace();
} else
Utils.getLogger().info("Cancelled by user.");
} catch (PackNotAvailableOfflineException e) {
JOptionPane.showMessageDialog(frame, e.getMessage(), resources.getString("launcher.installerror.unavailable"), JOptionPane.WARNING_MESSAGE);
} catch (DownloadException e) {
JOptionPane.showMessageDialog(frame, resources.getString("launcher.installerror.download", pack.getDisplayName(), e.getMessage()), resources.getString("launcher.installerror.title"), JOptionPane.WARNING_MESSAGE);
} catch (ZipException e) {
JOptionPane.showMessageDialog(frame, resources.getString("launcher.installerror.unzip", pack.getDisplayName(), e.getMessage()), resources.getString("launcher.installerror.title"), JOptionPane.WARNING_MESSAGE);
} catch (CacheDeleteException e) {
JOptionPane.showMessageDialog(frame, resources.getString("launcher.installerror.cache", pack.getDisplayName(), e.getMessage()), resources.getString("launcher.installerror.title"), JOptionPane.WARNING_MESSAGE);
} catch (BuildInaccessibleException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(frame, e.getMessage(), resources.getString("launcher.installerror.title"), JOptionPane.WARNING_MESSAGE);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (!everythingWorked || !doLaunch) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
frame.launchCompleted();
}
});
}
}
}
}) {
// /Interrupt is being called from a mysterious source, so unless this is a user-initiated cancel
// /Let's print the stack trace of the interruptor.
@Override
public void interrupt() {
boolean userCancelled = false;
synchronized (cancelLock) {
if (isCancelledByUser)
userCancelled = true;
}
if (!userCancelled) {
Utils.getLogger().info("Mysterious interruption source.");
try {
// I am a charlatan and a hack.
throw new Exception("Grabbing stack trace- this isn't necessarily an error.");
} catch (Exception ex) {
ex.printStackTrace();
}
}
super.interrupt();
}
};
runningThread.start();
}
use of net.technicpack.launchercore.exception.BuildInaccessibleException in project LauncherV3 by TechnicPack.
the class HttpSolderPackApi method getPackBuild.
@Override
public Modpack getPackBuild(String build) throws BuildInaccessibleException {
try {
String url = baseUrl + "modpack/" + modpackSlug + "/" + build + "?cid=" + clientId;
Modpack pack = RestObject.getRestObject(Modpack.class, url);
if (pack != null) {
return pack;
}
} catch (RestfulAPIException e) {
throw new BuildInaccessibleException(modpackSlug, build, e);
}
throw new BuildInaccessibleException(modpackSlug, build);
}
Aggregations