mirror of
https://hub.spigotmc.org/stash/scm/spigot/buildtools.git
synced 2025-04-13 09:31:28 +00:00
Fixed several launch bugs.
- Program exiting before GUI launch. - Moved java modal warnings to compile phase rather than version selection phase. - Removed some unused commented code and methods.
This commit is contained in:
parent
135c113102
commit
3591c955f2
6 changed files with 53 additions and 53 deletions
|
@ -33,6 +33,8 @@ public class Bootstrap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !guiEnabled )
|
||||||
|
{
|
||||||
JavaVersion javaVersion = JavaVersion.getCurrentVersion();
|
JavaVersion javaVersion = JavaVersion.getCurrentVersion();
|
||||||
|
|
||||||
if ( javaVersion.isUnknown() )
|
if ( javaVersion.isUnknown() )
|
||||||
|
@ -50,8 +52,6 @@ public class Bootstrap
|
||||||
System.exit( 1 );
|
System.exit( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !guiEnabled )
|
|
||||||
{
|
|
||||||
Builder.logOutput( System.out, System.err );
|
Builder.logOutput( System.out, System.err );
|
||||||
Builder.main( args );
|
Builder.main( args );
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ public final class BuildData {
|
||||||
*
|
*
|
||||||
* @param buildSettings the buildSettings used to get the current selected spigot version
|
* @param buildSettings the buildSettings used to get the current selected spigot version
|
||||||
*/
|
*/
|
||||||
public void updateJavaExecutable(final BuildSettings buildSettings) {
|
public CompletableFuture<Boolean> updateJavaExecutable(final BuildSettings buildSettings, boolean showModal) {
|
||||||
String checkVersion = buildSettings.getVersion();
|
String checkVersion = buildSettings.getVersion();
|
||||||
if (checkVersion.equals("experimental")) {
|
if (checkVersion.equals("experimental")) {
|
||||||
String mostRecent = versions.get(2);
|
String mostRecent = versions.get(2);
|
||||||
|
@ -106,12 +106,7 @@ public final class BuildData {
|
||||||
checkVersion = mostRecent;
|
checkVersion = mostRecent;
|
||||||
}
|
}
|
||||||
|
|
||||||
builds.get(checkVersion).whenComplete((BuildInfo info, Throwable throwable) -> {
|
return builds.get(checkVersion).thenApply((BuildInfo info) -> {
|
||||||
if (throwable != null) {
|
|
||||||
MessageModal.displayError(Utils.getReadableStacktrace(throwable));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info.getJavaVersions() == null) {
|
if (info.getJavaVersions() == null) {
|
||||||
info.setJavaVersions(new int[]{
|
info.setJavaVersions(new int[]{
|
||||||
JavaVersion.JAVA_7.getVersion(),
|
JavaVersion.JAVA_7.getVersion(),
|
||||||
|
@ -125,7 +120,7 @@ public final class BuildData {
|
||||||
final JavaInstallation primary = javaInstallationManager.getPrimaryInstallation();
|
final JavaInstallation primary = javaInstallationManager.getPrimaryInstallation();
|
||||||
if (primary.getVersion().getClassFileMajorVersion() >= min.getVersion() && primary.getVersion().getClassFileMajorVersion() <= max.getVersion()) {
|
if (primary.getVersion().getClassFileMajorVersion() >= min.getVersion() && primary.getVersion().getClassFileMajorVersion() <= max.getVersion()) {
|
||||||
javaInstallationManager.setSelectedInstallation(primary);
|
javaInstallationManager.setSelectedInstallation(primary);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JavaInstallation newInstallation = null;
|
JavaInstallation newInstallation = null;
|
||||||
|
@ -143,6 +138,7 @@ public final class BuildData {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newInstallation == null) {
|
if (newInstallation == null) {
|
||||||
|
if (showModal) {
|
||||||
String style = Utils.getFileContentsFromResource("web/reset.css");
|
String style = Utils.getFileContentsFromResource("web/reset.css");
|
||||||
String message = Utils.getFileContentsFromResource("web/insufficient_java.html");
|
String message = Utils.getFileContentsFromResource("web/insufficient_java.html");
|
||||||
message = message.replace("%STYLESHEET%", "<style>" + style + "</style>");
|
message = message.replace("%STYLESHEET%", "<style>" + style + "</style>");
|
||||||
|
@ -154,16 +150,22 @@ public final class BuildData {
|
||||||
message = message.replace("%ORACLE_LINK%", Constants.DOWNLOAD_ORACLE);
|
message = message.replace("%ORACLE_LINK%", Constants.DOWNLOAD_ORACLE);
|
||||||
|
|
||||||
MessageModal.displayError(message);
|
MessageModal.displayError(message);
|
||||||
return;
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
javaInstallationManager.setSelectedInstallation(newInstallation);
|
javaInstallationManager.setSelectedInstallation(newInstallation);
|
||||||
|
return true;
|
||||||
|
}).whenComplete((Boolean completed, Throwable throwable) -> {
|
||||||
|
if (throwable != null) {
|
||||||
|
MessageModal.displayError(Utils.getReadableStacktrace(throwable));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a copy of the versions list.
|
* @return a copy of the versions list.
|
||||||
* */
|
*/
|
||||||
public List<String> getVersions() {
|
public List<String> getVersions() {
|
||||||
return new ArrayList<>(versions);
|
return new ArrayList<>(versions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.spigotmc.gui.panels.general;
|
package org.spigotmc.gui.panels.general;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import org.spigotmc.gui.BuildToolsProcess;
|
import org.spigotmc.gui.BuildToolsProcess;
|
||||||
import org.spigotmc.gui.attributes.Lockable;
|
import org.spigotmc.gui.attributes.Lockable;
|
||||||
import org.spigotmc.gui.data.BuildSettings;
|
import org.spigotmc.gui.data.BuildSettings;
|
||||||
|
@ -149,6 +150,15 @@ public class GeneralPanel extends JPanel implements Lockable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildButtonActionPerformed(ActionEvent event) {
|
private void buildButtonActionPerformed(ActionEvent event) {
|
||||||
|
try {
|
||||||
|
if (!buildData.updateJavaExecutable(buildSettings, true).get()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
MessageModal.displayError(Utils.getReadableStacktrace(e));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cancelButton.setEnabled(true);
|
cancelButton.setEnabled(true);
|
||||||
consolePane.updateConsoleAreaText(new ArrayList<>());
|
consolePane.updateConsoleAreaText(new ArrayList<>());
|
||||||
|
|
||||||
|
|
|
@ -193,7 +193,7 @@ public class SettingsPanel extends JPanel implements Lockable, Themeable {
|
||||||
|
|
||||||
buildSettings.setVersion(selected);
|
buildSettings.setVersion(selected);
|
||||||
if (!buildSettings.isOverrideJavaExecutable()) {
|
if (!buildSettings.isOverrideJavaExecutable()) {
|
||||||
buildData.updateJavaExecutable(buildSettings);
|
buildData.updateJavaExecutable(buildSettings, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
consolePane.updateConsoleAreaText(buildData.generatePreCompilationText(buildSettings));
|
consolePane.updateConsoleAreaText(buildData.generatePreCompilationText(buildSettings));
|
||||||
|
|
|
@ -441,7 +441,7 @@ public class OptionsPanel extends JPanel {
|
||||||
this.detectJavaButton.setEnabled(false);
|
this.detectJavaButton.setEnabled(false);
|
||||||
this.javaSelectionButton.setEnabled(false);
|
this.javaSelectionButton.setEnabled(false);
|
||||||
buildSettings.setOverrideJavaExecutable(false);
|
buildSettings.setOverrideJavaExecutable(false);
|
||||||
buildData.updateJavaExecutable(buildSettings);
|
buildData.updateJavaExecutable(buildSettings, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text Fields
|
// Text Fields
|
||||||
|
|
|
@ -91,19 +91,7 @@ public class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRanFromCommandLine() {
|
public static boolean isRanFromCommandLine() {
|
||||||
// If a console is available, we're definitely running from command line.
|
return System.console() != null;
|
||||||
if (System.console() != null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Naive check for running from command line on Windows.
|
|
||||||
// If ran from command line or inside most IDEs, the SESSIONNAME environment variable will be set to "Console".
|
|
||||||
// It will be unset when double-clicking the .jar or when using other OSes
|
|
||||||
if ("Console".equals(System.getenv("SESSIONNAME"))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValidPR(String input, Repository repository) {
|
public static boolean isValidPR(String input, Repository repository) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue