Compare commits
5 Commits
v1.0.0-alp
...
v1.0.1-alp
Author | SHA1 | Date | |
---|---|---|---|
46bb3a9e29 | |||
cf0d1f7fff | |||
6ba2397e40 | |||
2476e379e5 | |||
5ed0236888 |
@ -1,5 +1,5 @@
|
|||||||
# Minecraft-Server-Launcher
|
# Minecraft-Server-Launcher
|
||||||
I originally created this software in 2013 using AutoIt. Since I am now learning Java, and I have wanted to rewrite it for a long time, I am trying to recreate it in Java. It is currently missing mostly everything, but it's nothing a lot of work can't fix.
|
I originally created this software in 2013 using AutoIt. Since I am now learning Java, I have recreated it in Java.
|
||||||
The original version can be found at: https://knarcraft.net/Downloads/Bungeeminecraftserverlauncher/
|
The original version can be found at: https://knarcraft.net/Downloads/Bungeeminecraftserverlauncher/
|
||||||
Its goal is to do everything the original does, just better. The original is 1595 lines of code repetition and dirty code. I had no prior programming experience when I first started working on the original, which is why it became such a mess.
|
Its goal is to do everything the original does, just better. The original is 1595 lines of code repetition and dirty code. I had no prior programming experience when I first started working on the original, which is why it became such a mess.
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import static net.knarcraft.serverlauncher.Shared.stringBetween;
|
|||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
@SuppressWarnings("CanBeFinal")
|
@SuppressWarnings("CanBeFinal")
|
||||||
public static String appDir;
|
private static String appDir;
|
||||||
private static boolean running = false;
|
private static boolean running = false;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -37,6 +37,11 @@ public class Main {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
try (PrintWriter file = new PrintWriter(Main.getAppDir() + File.separator + "latestrun.log")) {
|
||||||
|
file.print("");
|
||||||
|
} catch (IOException e ) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -45,7 +50,6 @@ public class Main {
|
|||||||
setup();
|
setup();
|
||||||
new ServerConsoles();
|
new ServerConsoles();
|
||||||
Profile.load();
|
Profile.load();
|
||||||
|
|
||||||
ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
|
ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
|
||||||
exec.scheduleAtFixedRate(Main::updateConsoles, 10, 500, TimeUnit.MILLISECONDS);
|
exec.scheduleAtFixedRate(Main::updateConsoles, 10, 500, TimeUnit.MILLISECONDS);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -63,6 +67,10 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getAppDir() {
|
||||||
|
return appDir;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads from server processes, and writes the output to consoles.
|
* Reads from server processes, and writes the output to consoles.
|
||||||
*/
|
*/
|
||||||
|
@ -32,9 +32,9 @@ public class Profile {
|
|||||||
private static final ArrayList<Profile> profiles = new ArrayList<>();
|
private static final ArrayList<Profile> profiles = new ArrayList<>();
|
||||||
private static Profile current;
|
private static Profile current;
|
||||||
private static GUI gui;
|
private static GUI gui;
|
||||||
private static final String profilesDir = Main.appDir + File.separator + "files";
|
private static final String profilesDir = Main.getAppDir() + File.separator + "files";
|
||||||
private static final String profilesFile = Main.appDir + File.separator + "files" + File.separator + "Profiles.txt";
|
private static final String profilesFile = Main.getAppDir() + File.separator + "files" + File.separator + "Profiles.txt";
|
||||||
private static final String jarDir = Main.appDir + File.separator + "files" + File.separator + "Jars" + File.separator;
|
private static final String jarDir = Main.getAppDir() + File.separator + "files" + File.separator + "Jars" + File.separator;
|
||||||
|
|
||||||
private final ArrayList<Collection> collections;
|
private final ArrayList<Collection> collections;
|
||||||
private final String name;
|
private final String name;
|
||||||
@ -139,6 +139,11 @@ public class Profile {
|
|||||||
this.downloadJars = value;
|
this.downloadJars = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current profile to the profile with a certain name.
|
||||||
|
*
|
||||||
|
* @param name The name of the profile
|
||||||
|
*/
|
||||||
public static void setCurrent(String name) {
|
public static void setCurrent(String name) {
|
||||||
for (Profile profile : profiles) {
|
for (Profile profile : profiles) {
|
||||||
if (profile.name.equals(name)) {
|
if (profile.name.equals(name)) {
|
||||||
|
@ -25,7 +25,7 @@ public class Server {
|
|||||||
private static final String[] ramList = {
|
private static final String[] ramList = {
|
||||||
"512M", "1G", "2G", "3G", "4G", "5G", "6G", "7G", "8G", "9G", "10G","11G", "12G", "13G", "14G", "15G", "16G"
|
"512M", "1G", "2G", "3G", "4G", "5G", "6G", "7G", "8G", "9G", "10G","11G", "12G", "13G", "14G", "15G", "16G"
|
||||||
};
|
};
|
||||||
private static final String jarDir = Main.appDir + File.separator + "files" + File.separator + "Jars" + File.separator;
|
private static final String jarDir = Main.getAppDir() + File.separator + "files" + File.separator + "Jars" + File.separator;
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private String path;
|
private String path;
|
||||||
@ -293,9 +293,9 @@ public class Server {
|
|||||||
ProcessBuilder builder;
|
ProcessBuilder builder;
|
||||||
String serverPath;
|
String serverPath;
|
||||||
if (Profile.getCurrent().getDownloadJars() && !type.getName().equals("Custom")) {
|
if (Profile.getCurrent().getDownloadJars() && !type.getName().equals("Custom")) {
|
||||||
serverPath = "\"" + jarDir + this.getType() + "\"";
|
serverPath = jarDir + this.getType();
|
||||||
} else {
|
} else {
|
||||||
serverPath = "\"" + this.path + File.separator + this.getType() + "\"";
|
serverPath = this.path + File.separator + this.getType();
|
||||||
}
|
}
|
||||||
builder = new ProcessBuilder(
|
builder = new ProcessBuilder(
|
||||||
"java",
|
"java",
|
||||||
|
@ -42,6 +42,11 @@ public class ServerType {
|
|||||||
return serverTypes;
|
return serverTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of all server types' names.
|
||||||
|
*
|
||||||
|
* @return A list of strings
|
||||||
|
*/
|
||||||
public static String[] getTypeNames() {
|
public static String[] getTypeNames() {
|
||||||
ArrayList<ServerType> types = ServerType.getServerTypes();
|
ArrayList<ServerType> types = ServerType.getServerTypes();
|
||||||
String[] serverTypes = new String[types.size()];
|
String[] serverTypes = new String[types.size()];
|
||||||
@ -51,6 +56,12 @@ public class ServerType {
|
|||||||
return serverTypes;
|
return serverTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a server type by name.
|
||||||
|
*
|
||||||
|
* @param name Then name of the server type
|
||||||
|
* @return A ServerType
|
||||||
|
*/
|
||||||
public static ServerType getByName(String name) {
|
public static ServerType getByName(String name) {
|
||||||
for (ServerType serverType : serverTypes) {
|
for (ServerType serverType : serverTypes) {
|
||||||
if (serverType.getName().equals(name)) {
|
if (serverType.getName().equals(name)) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.knarcraft.serverlauncher.userinterface;
|
package net.knarcraft.serverlauncher.userinterface;
|
||||||
|
|
||||||
|
import net.knarcraft.serverlauncher.Main;
|
||||||
import net.knarcraft.serverlauncher.profile.Collection;
|
import net.knarcraft.serverlauncher.profile.Collection;
|
||||||
import net.knarcraft.serverlauncher.server.Server;
|
import net.knarcraft.serverlauncher.server.Server;
|
||||||
import net.knarcraft.serverlauncher.profile.Profile;
|
import net.knarcraft.serverlauncher.profile.Profile;
|
||||||
@ -93,6 +94,11 @@ public class GUI implements ActionListener {
|
|||||||
*/
|
*/
|
||||||
public void setStatus(String text) {
|
public void setStatus(String text) {
|
||||||
this.lblStatuslabel.setText(text);
|
this.lblStatuslabel.setText(text);
|
||||||
|
try (PrintWriter file = new PrintWriter(new FileWriter(Main.getAppDir() + File.separator + "latestrun.log", true))) {
|
||||||
|
file.println(text);
|
||||||
|
} catch (IOException e ) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user