Finishes custom java path
Adds missing menu items Adds menu item functionality
This commit is contained in:
parent
0018816d90
commit
e4be75b770
@ -94,26 +94,44 @@ public class ServerLauncherController {
|
||||
/**
|
||||
* Gets the command for running java
|
||||
*
|
||||
* <p>To play on the newest version of Minecraft, this needs to be JDK 16. Can be just "java" or a file path.</p>
|
||||
*
|
||||
* @return <p>The command for running java</p>
|
||||
* @return <p>The command for running Java</p>
|
||||
*/
|
||||
public String getJavaCommand() {
|
||||
return javaCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the command for running older versions of java
|
||||
* Gets the command for running older versions of Java
|
||||
*
|
||||
* <p>The command used to run older minecraft server versions. JRE 8 should probably work.
|
||||
* Can be just "java" or a file path.</p>
|
||||
*
|
||||
* @return <p>The command for running older versions of java</p>
|
||||
* @return <p>The command for running older versions of Java</p>
|
||||
*/
|
||||
public String getOldJavaCommand() {
|
||||
return oldJavaCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command for running Java
|
||||
*
|
||||
* <p>To play on the newest version of Minecraft, this needs to be JDK 16. Can be just "java" or a file path.</p>
|
||||
*
|
||||
* @param javaCommand <p>The command used for running Java</p>
|
||||
*/
|
||||
public void setJavaCommand(String javaCommand) {
|
||||
this.javaCommand = javaCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command for running older versions of java
|
||||
*
|
||||
* @param oldJavaCommand <p>The command used for running older versions of Java</p>
|
||||
*/
|
||||
public void setOldJavaCommand(String oldJavaCommand) {
|
||||
this.oldJavaCommand = oldJavaCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
int guiWidth;
|
||||
|
@ -19,6 +19,8 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
private JCheckBoxMenuItem runInBackgroundCheckBoxMenuItem;
|
||||
private JCheckBoxMenuItem delayStartupCheckBoxMenuItem;
|
||||
private JCheckBoxMenuItem downloadJarsCheckBoxMenuItem;
|
||||
private JMenuItem javaCommandMenuItem;
|
||||
private JMenuItem oldJavaCommandMenuItem;
|
||||
//Help
|
||||
private JMenuItem errorsMenuItem;
|
||||
private JMenuItem setupMenuItem;
|
||||
@ -27,6 +29,8 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
private JMenuItem runInBackgroundMenuItem;
|
||||
private JMenuItem delayStartupMenuItem;
|
||||
private JMenuItem downloadJarsMenuItem;
|
||||
private JMenuItem javaCommandInfoMenuItem;
|
||||
private JMenuItem oldJavaCommandInfoMenuItem;
|
||||
//Info/about
|
||||
private JMenuItem aboutMenuItem;
|
||||
private JMenuItem storyMenuItem;
|
||||
@ -66,6 +70,14 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
mnOptions.add(downloadJarsCheckBoxMenuItem);
|
||||
downloadJarsCheckBoxMenuItem.addActionListener(this);
|
||||
|
||||
javaCommandMenuItem = new JMenuItem("Java command");
|
||||
mnOptions.add(javaCommandMenuItem);
|
||||
javaCommandMenuItem.addActionListener(this);
|
||||
|
||||
oldJavaCommandMenuItem = new JMenuItem("Old Java command");
|
||||
mnOptions.add(oldJavaCommandMenuItem);
|
||||
oldJavaCommandMenuItem.addActionListener(this);
|
||||
|
||||
JMenu mnHelp = new JMenu("Help");
|
||||
menuBar.add(mnHelp);
|
||||
|
||||
@ -99,6 +111,14 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
mnOptionsInfo.add(downloadJarsMenuItem);
|
||||
downloadJarsMenuItem.addActionListener(this);
|
||||
|
||||
javaCommandInfoMenuItem = new JMenuItem("Java command");
|
||||
mnOptionsInfo.add(javaCommandInfoMenuItem);
|
||||
javaCommandInfoMenuItem.addActionListener(this);
|
||||
|
||||
oldJavaCommandInfoMenuItem = new JMenuItem("Old Java command");
|
||||
mnOptionsInfo.add(oldJavaCommandInfoMenuItem);
|
||||
oldJavaCommandInfoMenuItem.addActionListener(this);
|
||||
|
||||
JMenu mnAbout = new JMenu("About");
|
||||
mnInfo.add(mnAbout);
|
||||
|
||||
@ -111,6 +131,9 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
storyMenuItem.addActionListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the state of checkboxes based on whether options are enabled
|
||||
*/
|
||||
public void update() {
|
||||
runInBackgroundCheckBoxMenuItem.setState(controller.getRunInBackground());
|
||||
delayStartupCheckBoxMenuItem.setState(controller.getDelayStartup() > 0);
|
||||
@ -126,6 +149,10 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
delay();
|
||||
} else if (actionSource == downloadJarsCheckBoxMenuItem) {
|
||||
downloadJars();
|
||||
} else if (actionSource == javaCommandMenuItem) {
|
||||
configureJava(false);
|
||||
} else if (actionSource == oldJavaCommandMenuItem) {
|
||||
configureJava(true);
|
||||
} else if (actionSource == errorsMenuItem) {
|
||||
CommonFunctions.goToURL(serverLauncherGUI.getMessage("infoURL"));
|
||||
} else if (actionSource == setupMenuItem) {
|
||||
@ -138,6 +165,10 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
serverLauncherGUI.showMessage("Delay startup", serverLauncherGUI.getMessage("delayStartupText"));
|
||||
} else if (actionSource == downloadJarsMenuItem) {
|
||||
serverLauncherGUI.showMessage("Download jars", serverLauncherGUI.getMessage("downloadJarsText"));
|
||||
} else if (actionSource == javaCommandInfoMenuItem) {
|
||||
serverLauncherGUI.showMessage("Java command", serverLauncherGUI.getMessage("javaCommandText"));
|
||||
} else if (actionSource == oldJavaCommandInfoMenuItem) {
|
||||
serverLauncherGUI.showMessage("Old Java command", serverLauncherGUI.getMessage("oldJavaCommandText"));
|
||||
} else if (actionSource == aboutMenuItem) {
|
||||
serverLauncherGUI.showMessage("About", serverLauncherGUI.getMessage("aboutText"));
|
||||
} else if (actionSource == storyMenuItem) {
|
||||
@ -145,6 +176,24 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the user for the new Java path
|
||||
* @param old <p>Whether asking for the path to the old java version</p>
|
||||
*/
|
||||
private void configureJava(boolean old) {
|
||||
if (old) {
|
||||
String response = JOptionPane.showInputDialog("Command or path to Java: ", controller.getOldJavaCommand());
|
||||
if (response != null) {
|
||||
controller.setOldJavaCommand(response);
|
||||
}
|
||||
} else {
|
||||
String response = JOptionPane.showInputDialog("Command or path to Java: ", controller.getJavaCommand());
|
||||
if (response != null) {
|
||||
controller.setJavaCommand(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the user for a delay if checked, and sets the value to the current profile
|
||||
*/
|
||||
|
@ -5,4 +5,6 @@ downloadJarsText=This option will download all the .jar files available in the p
|
||||
aboutText=This software was created to start and manage several servers simultaneously._BREAK_You no longer have to do the tedious work of manually downloading different .jar files every time you want to try something new.
|
||||
infoURL=https://archive.knarcraft.net/Scripts/BungeeMinecraftServerLauncherInfo/
|
||||
manualUpdateURL=https://git.knarcraft.net/KnarCraft/Minecraft-Server-Launcher/releases
|
||||
storyURL=https://archive.knarcraft.net/Scripts/BungeeMinecraftServerLauncherStory/
|
||||
storyURL=https://archive.knarcraft.net/Scripts/BungeeMinecraftServerLauncherStory/
|
||||
javaCommandText=This option allows you to set a custom command/path to the Java executable used for Minecraft 1.17 and above. If "java" is currently pointing to Java 8, you can use this to set a custom one for running new Minecraft servers and BuildTools.
|
||||
oldJavaCommandText=This option allows you to set a custom command/path to the Java executable used for Minecraft 1.16 and below. If "java" is currently pointing to Java 16, you can use this to set a custom one for running old Minecraft servers.
|
Can't render this file because it contains an unexpected character in line 9 and column 130.
|
Loading…
Reference in New Issue
Block a user