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
|
* 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() {
|
public String getJavaCommand() {
|
||||||
return javaCommand;
|
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.
|
* <p>The command used to run older minecraft server versions. JRE 8 should probably work.
|
||||||
* Can be just "java" or a file path.</p>
|
* 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() {
|
public String getOldJavaCommand() {
|
||||||
return oldJavaCommand;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
int guiWidth;
|
int guiWidth;
|
||||||
|
@ -19,6 +19,8 @@ public class ServerLauncherMenu implements ActionListener {
|
|||||||
private JCheckBoxMenuItem runInBackgroundCheckBoxMenuItem;
|
private JCheckBoxMenuItem runInBackgroundCheckBoxMenuItem;
|
||||||
private JCheckBoxMenuItem delayStartupCheckBoxMenuItem;
|
private JCheckBoxMenuItem delayStartupCheckBoxMenuItem;
|
||||||
private JCheckBoxMenuItem downloadJarsCheckBoxMenuItem;
|
private JCheckBoxMenuItem downloadJarsCheckBoxMenuItem;
|
||||||
|
private JMenuItem javaCommandMenuItem;
|
||||||
|
private JMenuItem oldJavaCommandMenuItem;
|
||||||
//Help
|
//Help
|
||||||
private JMenuItem errorsMenuItem;
|
private JMenuItem errorsMenuItem;
|
||||||
private JMenuItem setupMenuItem;
|
private JMenuItem setupMenuItem;
|
||||||
@ -27,6 +29,8 @@ public class ServerLauncherMenu implements ActionListener {
|
|||||||
private JMenuItem runInBackgroundMenuItem;
|
private JMenuItem runInBackgroundMenuItem;
|
||||||
private JMenuItem delayStartupMenuItem;
|
private JMenuItem delayStartupMenuItem;
|
||||||
private JMenuItem downloadJarsMenuItem;
|
private JMenuItem downloadJarsMenuItem;
|
||||||
|
private JMenuItem javaCommandInfoMenuItem;
|
||||||
|
private JMenuItem oldJavaCommandInfoMenuItem;
|
||||||
//Info/about
|
//Info/about
|
||||||
private JMenuItem aboutMenuItem;
|
private JMenuItem aboutMenuItem;
|
||||||
private JMenuItem storyMenuItem;
|
private JMenuItem storyMenuItem;
|
||||||
@ -66,6 +70,14 @@ public class ServerLauncherMenu implements ActionListener {
|
|||||||
mnOptions.add(downloadJarsCheckBoxMenuItem);
|
mnOptions.add(downloadJarsCheckBoxMenuItem);
|
||||||
downloadJarsCheckBoxMenuItem.addActionListener(this);
|
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");
|
JMenu mnHelp = new JMenu("Help");
|
||||||
menuBar.add(mnHelp);
|
menuBar.add(mnHelp);
|
||||||
|
|
||||||
@ -99,6 +111,14 @@ public class ServerLauncherMenu implements ActionListener {
|
|||||||
mnOptionsInfo.add(downloadJarsMenuItem);
|
mnOptionsInfo.add(downloadJarsMenuItem);
|
||||||
downloadJarsMenuItem.addActionListener(this);
|
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");
|
JMenu mnAbout = new JMenu("About");
|
||||||
mnInfo.add(mnAbout);
|
mnInfo.add(mnAbout);
|
||||||
|
|
||||||
@ -111,6 +131,9 @@ public class ServerLauncherMenu implements ActionListener {
|
|||||||
storyMenuItem.addActionListener(this);
|
storyMenuItem.addActionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the state of checkboxes based on whether options are enabled
|
||||||
|
*/
|
||||||
public void update() {
|
public void update() {
|
||||||
runInBackgroundCheckBoxMenuItem.setState(controller.getRunInBackground());
|
runInBackgroundCheckBoxMenuItem.setState(controller.getRunInBackground());
|
||||||
delayStartupCheckBoxMenuItem.setState(controller.getDelayStartup() > 0);
|
delayStartupCheckBoxMenuItem.setState(controller.getDelayStartup() > 0);
|
||||||
@ -126,6 +149,10 @@ public class ServerLauncherMenu implements ActionListener {
|
|||||||
delay();
|
delay();
|
||||||
} else if (actionSource == downloadJarsCheckBoxMenuItem) {
|
} else if (actionSource == downloadJarsCheckBoxMenuItem) {
|
||||||
downloadJars();
|
downloadJars();
|
||||||
|
} else if (actionSource == javaCommandMenuItem) {
|
||||||
|
configureJava(false);
|
||||||
|
} else if (actionSource == oldJavaCommandMenuItem) {
|
||||||
|
configureJava(true);
|
||||||
} else if (actionSource == errorsMenuItem) {
|
} else if (actionSource == errorsMenuItem) {
|
||||||
CommonFunctions.goToURL(serverLauncherGUI.getMessage("infoURL"));
|
CommonFunctions.goToURL(serverLauncherGUI.getMessage("infoURL"));
|
||||||
} else if (actionSource == setupMenuItem) {
|
} else if (actionSource == setupMenuItem) {
|
||||||
@ -138,6 +165,10 @@ public class ServerLauncherMenu implements ActionListener {
|
|||||||
serverLauncherGUI.showMessage("Delay startup", serverLauncherGUI.getMessage("delayStartupText"));
|
serverLauncherGUI.showMessage("Delay startup", serverLauncherGUI.getMessage("delayStartupText"));
|
||||||
} else if (actionSource == downloadJarsMenuItem) {
|
} else if (actionSource == downloadJarsMenuItem) {
|
||||||
serverLauncherGUI.showMessage("Download jars", serverLauncherGUI.getMessage("downloadJarsText"));
|
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) {
|
} else if (actionSource == aboutMenuItem) {
|
||||||
serverLauncherGUI.showMessage("About", serverLauncherGUI.getMessage("aboutText"));
|
serverLauncherGUI.showMessage("About", serverLauncherGUI.getMessage("aboutText"));
|
||||||
} else if (actionSource == storyMenuItem) {
|
} 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
|
* Asks the user for a delay if checked, and sets the value to the current profile
|
||||||
*/
|
*/
|
||||||
|
@ -6,3 +6,5 @@ aboutText=This software was created to start and manage several servers simultan
|
|||||||
infoURL=https://archive.knarcraft.net/Scripts/BungeeMinecraftServerLauncherInfo/
|
infoURL=https://archive.knarcraft.net/Scripts/BungeeMinecraftServerLauncherInfo/
|
||||||
manualUpdateURL=https://git.knarcraft.net/KnarCraft/Minecraft-Server-Launcher/releases
|
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