Adds a menu item for easily delete built .jar files
All checks were successful
KnarCraft/Minecraft-Server-Launcher/pipeline/head This commit looks good
All checks were successful
KnarCraft/Minecraft-Server-Launcher/pipeline/head This commit looks good
This commit is contained in:
parent
429b1fcec0
commit
6ca49d2ccd
@ -236,6 +236,15 @@ public class ServerLauncherController {
|
||||
this.currentProfile = getProfileByName(profileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the directory containing .jar files
|
||||
*
|
||||
* @return <p>The directory containing .jar files</p>
|
||||
*/
|
||||
public String getJarDirectory() {
|
||||
return this.jarDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the state of the entire application to disk
|
||||
*/
|
||||
|
@ -7,6 +7,7 @@ import net.knarcraft.minecraftserverlauncher.utility.CommonFunctions;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -21,6 +22,7 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
private JCheckBoxMenuItem downloadJarsCheckBoxMenuItem;
|
||||
private JMenuItem javaCommandMenuItem;
|
||||
private JMenuItem oldJavaCommandMenuItem;
|
||||
private JMenuItem deleteBuiltJarsMenuItem;
|
||||
//Help
|
||||
private JMenuItem errorsMenuItem;
|
||||
private JMenuItem setupMenuItem;
|
||||
@ -31,6 +33,7 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
private JMenuItem downloadJarsMenuItem;
|
||||
private JMenuItem javaCommandInfoMenuItem;
|
||||
private JMenuItem oldJavaCommandInfoMenuItem;
|
||||
private JMenuItem deleteBuiltJarsInfoMenuItem;
|
||||
//Info/about
|
||||
private JMenuItem aboutMenuItem;
|
||||
private JMenuItem storyMenuItem;
|
||||
@ -93,6 +96,8 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
configureJava(false);
|
||||
} else if (actionSource == oldJavaCommandMenuItem) {
|
||||
configureJava(true);
|
||||
} else if (actionSource == deleteBuiltJarsMenuItem) {
|
||||
deleteBuiltJars();
|
||||
} else if (actionSource == errorsMenuItem) {
|
||||
CommonFunctions.goToURL(serverLauncherGUI.getMessage("infoURL"));
|
||||
} else if (actionSource == setupMenuItem) {
|
||||
@ -109,6 +114,8 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
serverLauncherGUI.showMessage("Java command", serverLauncherGUI.getMessage("javaCommandText"));
|
||||
} else if (actionSource == oldJavaCommandInfoMenuItem) {
|
||||
serverLauncherGUI.showMessage("Old Java command", serverLauncherGUI.getMessage("oldJavaCommandText"));
|
||||
} else if (actionSource == deleteBuiltJarsInfoMenuItem) {
|
||||
serverLauncherGUI.showMessage("Delete build jar files", serverLauncherGUI.getMessage("deleteBuiltJarFilesText"));
|
||||
} else if (actionSource == aboutMenuItem) {
|
||||
serverLauncherGUI.showMessage("About", serverLauncherGUI.getMessage("aboutText"));
|
||||
} else if (actionSource == storyMenuItem) {
|
||||
@ -127,6 +134,7 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
downloadJarsCheckBoxMenuItem = createCheckBoxMenuItem("Download jars", mnOptions);
|
||||
javaCommandMenuItem = createMenuItem("Java command", mnOptions);
|
||||
oldJavaCommandMenuItem = createMenuItem("Old Java command", mnOptions);
|
||||
deleteBuiltJarsMenuItem = createMenuItem("Delete build jar files", mnOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,6 +151,7 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
downloadJarsMenuItem = createMenuItem("Download jars", mnOptionsInfo);
|
||||
javaCommandInfoMenuItem = createMenuItem("Java command", mnOptionsInfo);
|
||||
oldJavaCommandInfoMenuItem = createMenuItem("Old Java command", mnOptionsInfo);
|
||||
deleteBuiltJarsInfoMenuItem = createMenuItem("Delete build jar files", mnOptionsInfo);
|
||||
|
||||
JMenu mnAbout = new JMenu("About");
|
||||
mnInfo.add(mnAbout);
|
||||
@ -197,6 +206,33 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes build Spigot and Bukkit .jar files if the user accepts
|
||||
*/
|
||||
private void deleteBuiltJars() {
|
||||
int answer = JOptionPane.showConfirmDialog(null, "This will delete build .jar files, causing them " +
|
||||
"to be rebuilt on the next run. Do you want to continue?", "Delete build .jar files",
|
||||
JOptionPane.YES_NO_OPTION
|
||||
);
|
||||
if (answer == JOptionPane.YES_NO_OPTION) {
|
||||
String jarDirectory = controller.getJarDirectory();
|
||||
File spigotFile = new File(jarDirectory + "SpigotLatest");
|
||||
File bukkitFile = new File(jarDirectory + "BukkitLatest");
|
||||
boolean success = true;
|
||||
if (spigotFile.exists() && !spigotFile.delete()) {
|
||||
serverLauncherGUI.showError("Unable to delete latest spigot .jar");
|
||||
success = false;
|
||||
}
|
||||
if (bukkitFile.exists() && !bukkitFile.delete()) {
|
||||
serverLauncherGUI.showError("Unable to delete latest bukkit .jar");
|
||||
success = false;
|
||||
}
|
||||
if (success) {
|
||||
serverLauncherGUI.showMessage("Deletion successful", "Deleted build .jar files");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the user for a delay if checked, and sets the value to the current profile
|
||||
*/
|
||||
|
@ -7,4 +7,5 @@ infoURL=https://archive.knarcraft.net/Scripts/BungeeMinecraftServerLauncherInfo/
|
||||
manualUpdateURL=https://git.knarcraft.net/KnarCraft/Minecraft-Server-Launcher/releases
|
||||
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._BREAK_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._BREAK_If "java" is currently pointing to Java 16, you can use this to set a custom one for running old Minecraft servers.
|
||||
oldJavaCommandText=This option allows you to set a custom command/path to the Java executable used for Minecraft 1.16 and below._BREAK_If "java" is currently pointing to Java 16, you can use this to set a custom one for running old Minecraft servers.
|
||||
deleteBuiltJarFilesText=This option allows you to easily delete built Spigot and Bukkit .jar files._BREAK_You should occasionally run this option to update the built .jar files to ensure you're running the latest update.
|
Can't render this file because it contains an unexpected character in line 9 and column 136.
|
Loading…
Reference in New Issue
Block a user