Adds missing comments, simplifies proxy distinction, moves updating to own class and fixes formatting

This commit is contained in:
2020-08-11 19:29:28 +02:00
parent 094a1facb2
commit ab6453cdc3
30 changed files with 845 additions and 593 deletions

View File

@ -13,17 +13,18 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* Contains all necessary information to create, run and manage a Minecraft server.
* Contains all necessary information to create, runServer and manage a Minecraft server.
*
* @author Kristian Knarvik <kristian.knarvik@knett.no>
* @version 1.0.0
* @since 1.0.0
*/
public class Server {
public class Server implements java.io.Serializable {
/**
* Available ram sizes. For ServerLauncherGUI dropdown
*/
@ -33,19 +34,15 @@ public class Server {
private static final String jarDirectory = Main.getApplicationWorkDirectory() + File.separator + "files" + File.separator + "Jars" + File.separator;
private final String name;
private final ArrayList<String> playerList;
private String path;
private boolean enabled;
private final ArrayList<String> playerList;
private ServerType type;
private String serverVersion;
private String maxRam;
private Process process;
private BufferedWriter writer;
private BufferedReader reader;
private final String vanillaVersion;
private final String snapshotVersion;
private final String spongeVanillaVersion;
private final String bungeeVersion;
private boolean started;
/**
@ -64,41 +61,83 @@ public class Server {
this.process = null;
this.writer = null;
this.reader = null;
this.vanillaVersion = "";
this.snapshotVersion = "";
this.spongeVanillaVersion = "";
this.bungeeVersion = "";
}
/**
* Initializes a server with the given values
*
* @param name <p>The name of the server</p>
* @param path <p>The file path of the folder containing the server files</p>
* @param enabled <p>Whether the server is enabled to start the next time servers are started</p>
* @param typeName <p>The name of the server type currently in use on the server</p>
* @param serverVersion <p>The currently selected server version for the given server type</p>
* @param maxRam <p>The maximum amount of ram the server is allowed to use</p>
* @param vanillaVersion <p>The version of the "latest" downloaded vanilla version</p>
* @param snapshotVersion <p>The version of the "latest" downloaded snapshot version</p>
* @param spongeVanillaVersion <p>The version of the "latest" SpongeVanilla jar downloaded</p>
* @param bungeeVersion <p>The version of the "latest" bungee jar downloaded</p>
* @param name <p>The name of the server</p>
* @param path <p>The file path of the folder containing the server files</p>
* @param enabled <p>Whether the server is enabled to start the next time servers are started</p>
* @param typeName <p>The name of the server type currently in use on the server</p>
* @param serverVersion <p>The currently selected server version for the given server type</p>
* @param maxRam <p>The maximum amount of ram the server is allowed to use</p>
*/
public Server(String name, String path, boolean enabled, String typeName, String serverVersion, String maxRam,
String vanillaVersion, String snapshotVersion, String spongeVanillaVersion, String bungeeVersion) {
public Server(String name, String path, boolean enabled, String typeName, String serverVersion, String maxRam) {
this.name = name;
this.path = path;
this.enabled = enabled;
this.type = ServerTypeHandler.getByName(typeName);
this.serverVersion = serverVersion;
this.maxRam = maxRam;
this.vanillaVersion = vanillaVersion;
this.snapshotVersion = snapshotVersion;
this.spongeVanillaVersion = spongeVanillaVersion;
this.bungeeVersion = bungeeVersion;
this.playerList = new ArrayList<>();
}
public static String[] getRamList() {
return ramList;
}
/**
* Tries to stop all enabled servers.
*
* @throws IOException If a writer's process is already closed but not null.
*/
public static void stop() throws IOException {
for (Collection collection : Profile.getCurrent().getCollections()) {
Server server = collection.getServer();
if (server.writer != null) {
if (server.type.isProxy()) {
server.writer.write("end\n");
} else {
server.writer.write("stop\n");
}
server.writer.flush();
server.writer = null;
server.started = false;
}
}
}
/**
* Runs all enabled servers with their settings
*/
public static void startServers() {
Profile.getGUI().setStatus("Starting servers");
for (Collection collection : Profile.getCurrent().getCollections()) {
if (!collection.getServer().runServer()) {
Profile.getGUI().setStatus("An error occurred. Start aborted");
try {
Server.stop();
} catch (IOException e) {
e.printStackTrace();
}
Profile.getGUI().updateRunning(false);
return;
}
}
}
/**
* Gets a server object from a server save string
*
* @param saveString <p>The string containing necessary data regarding the server</p>
* @return <p>A server in the same state it was saved in</p>
*/
public static Server fromString(String saveString) {
String[] data = saveString.split(";");
return new Server(data[0], data[1], Boolean.parseBoolean(data[2]), data[3], data[4], data[5]);
}
/**
* Gets the name of the server
*
@ -126,6 +165,15 @@ public class Server {
return this.type.getName();
}
/**
* Gets the server type used by this server
*
* @return <p>The server type used by this server</p>
*/
public ServerType getType() {
return this.type;
}
/**
* Gets the version used given server type used
*
@ -135,108 +183,10 @@ public class Server {
return this.serverVersion;
}
public String getPath() {
return this.path;
}
public Process getProcess() {
return this.process;
}
public String getMaxRam() {
return this.maxRam;
}
public static String[] getRamList() {
return ramList;
}
public String getVanillaVersion() {
return this.vanillaVersion;
}
public String getSnapshotVersion() {
return this.snapshotVersion;
}
public String getSpongeVanillaVersion() {
return this.spongeVanillaVersion;
}
public String getBungeeVersion() {
return this.bungeeVersion;
}
public ArrayList<String> getPlayers() {
return this.playerList;
}
public void stopped() {
process = null;
writer = null;
reader = null;
started = false;
}
/**
* @return A representation of the name of a jarfile.
*/
private String getType() {
if (this.type.getName().equals("Custom")) {
return this.serverVersion;
} else {
return "";
}
}
public boolean isEnabled() {
return this.enabled;
}
public void toggle(boolean value) {
this.enabled = value;
}
public boolean hasPlayer(String name) {
for (String player : this.playerList) {
if (player.equals(name)) {
return true;
}
}
return false;
}
public void addPlayer(String name) {
this.playerList.add(name);
Profile.getGUI().addPlayer(name);
}
/**
* Removes a player with the selected name from the playerlist.
* Sets the server's server version to a valid version, or ignores the request
*
* @param name The name of the player to remove
*/
public void removePlayer(String name) {
playerList.removeIf(player -> player.equals(name));
Profile.getGUI().removePlayer(name);
}
public void setPath(String path) {
this.path = path;
}
public void setType(ServerType type) {
this.type = type;
}
public void setMaxRam(String ram) {
this.maxRam = ram;
}
/**
* Sets the server's server version to a valid version, or ignores the request.
*
* @param serverVersion Version number.
* @param serverVersion <p>The new server version</p>
*/
public void setServerVersion(String serverVersion) throws IllegalArgumentException {
if (this.type.getName().equals("Custom")) {
@ -254,43 +204,129 @@ public class Server {
}
/**
* Tries to stop all enabled servers.
* Gets the path for this server's files
*
* @throws IOException If a writer's process is already closed but not null.
* @return <p>The path of this server's files</p>
*/
public static void stop() throws IOException {
for (Collection collection : Profile.getCurrent().getCollections()) {
Server server = collection.getServer();
if (server.writer != null) {
if (server.type.getName().equals("Bungee")) {
server.writer.write("end\n");
} else {
server.writer.write("stop\n");
}
server.writer.flush();
server.writer = null;
server.started = false;
}
}
public String getPath() {
return this.path;
}
/**
* Runs all enabled servers with their settings.
* Sets the path of this server's files
*
* @param path <p>The new path of the server's files</p>
*/
public static void startServers() {
Profile.getGUI().setStatus("Starting servers");
for (Collection collection : Profile.getCurrent().getCollections()) {
if (!collection.getServer().run()) {
Profile.getGUI().setStatus("An error occurred. Start aborted");
try {
Server.stop();
} catch (IOException e) {
e.printStackTrace();
}
Profile.getGUI().updateRunning(false);
return;
public void setPath(String path) {
this.path = path;
}
/**
* Gets the process of the server
*
* @return <p>The server process</p>
*/
public Process getProcess() {
return this.process;
}
/**
* Gets the maximum amount of ram usable by this server
*
* @return <p>The maximum amount of ram this server can use</p>
*/
public String getMaxRam() {
return this.maxRam;
}
/**
* Sets the max ram to be used by the server
*
* @param ram <p>The new maximum ram amount</p>
*/
public void setMaxRam(String ram) {
this.maxRam = ram;
}
/**
* Gets a list of all players connected to this server
*
* @return <p>A list of all players connected to the server</p>
*/
public List<String> getPlayers() {
return this.playerList;
}
/**
* Checks whether this server is fully stopped
*/
public void stopped() {
process = null;
writer = null;
reader = null;
started = false;
}
/**
* Checks whether this server is currently enabled
*
* @return <p>True if the server is currently enabled</p>
*/
public boolean isEnabled() {
return this.enabled;
}
/**
* Sets whether this server is currently enabled
*
* @param value <p>Whether the server is currently enabled</p>
*/
public void setEnabled(boolean value) {
this.enabled = value;
}
/**
* Checks whether this server has a given player
*
* @param name <p>The name of the player to check</p>
* @return <p>True if the player is connected</p>
*/
public boolean hasPlayer(String name) {
for (String player : this.playerList) {
if (player.equals(name)) {
return true;
}
}
return false;
}
/**
* Adds a player to the GUI and this server's player list
*
* @param name <p>The name of the player to add</p>
*/
public void addPlayer(String name) {
this.playerList.add(name);
Profile.getGUI().addPlayer(name);
}
/**
* Removes a player with the selected name from the player list
*
* @param name The name of the player to remove
*/
public void removePlayer(String name) {
playerList.removeIf(player -> player.equals(name));
Profile.getGUI().removePlayer(name);
}
/**
* Sets the server type to be used by the server
*
* @param type <p>The new server type to be used by the server</p>
*/
public void setType(ServerType type) {
this.type = type;
}
/**
@ -298,7 +334,7 @@ public class Server {
*
* @return <p>True if nothing went wrong</p>
*/
private boolean run() {
private boolean runServer() {
if (!this.enabled) {
this.started = false;
return true;
@ -393,7 +429,6 @@ public class Server {
this.downloadJar();
Profile.getGUI().setStatus("File downloaded");
} catch (IOException e) {
System.out.println(e.getMessage());
Profile.getGUI().setStatus("Error: Jar file not found");
e.printStackTrace();
this.started = false;
@ -410,7 +445,10 @@ public class Server {
*/
private void downloadJar() throws IOException {
String path = this.path + File.separator;
File file = new File(path + this.getType());
if (this.type.getName().equals("Custom")) {
path += this.serverVersion;
}
File file = new File(path);
if (!(file.isFile() || type.downloadJar(path, this.serverVersion))) {
throw new FileNotFoundException("Jar file could not be downloaded.");
}
@ -428,4 +466,17 @@ public class Server {
this.writer.flush();
}
}
@Override
public String toString() {
return String.format(
"%s;%s;%b;%s;%s;%s;!",
this.getName(),
this.getPath(),
this.isEnabled(),
this.getTypeName(),
this.getServerVersion(),
this.getMaxRam()
);
}
}

View File

@ -29,7 +29,8 @@ public class ServerTypeHandler {
/**
* Gets a list of all server types' names.
* @return <p>A list of strings</p>
*
* @return <p>A list of strings</p>
*/
public static String[] getTypeNames() throws ConfigurationException {
ArrayList<ServerType> types = getServerTypes();
@ -42,6 +43,7 @@ public class ServerTypeHandler {
/**
* Gets all instantiated server types
*
* @return <p>A list of server types</p>
*/
public static ArrayList<ServerType> getServerTypes() throws ConfigurationException {
@ -53,6 +55,7 @@ public class ServerTypeHandler {
/**
* Gets a server type by the given name
*
* @param name <p>Then name of the server type</p>
* @return <p>A AbstractServerType</p>
*/
@ -67,6 +70,7 @@ public class ServerTypeHandler {
/**
* Reads valid server types and version from a file, and creates their objects.
*
* @throws ConfigurationException <p>If anything goes wrong</p>
*/
private static void loadServerTypes() throws ConfigurationException {
@ -102,41 +106,47 @@ public class ServerTypeHandler {
ServerType newType;
switch (serverTypeInfo[0]) {
case "Craftbukkit":
newType = new CraftBukkit("Bukkit", serverVersions, serverTypeInfo[2], serverTypeInfo[3]);
newType = new CraftBukkit("Bukkit", false, serverVersions, serverTypeInfo[2],
serverTypeInfo[3]);
break;
case "Spigot":
newType = new Spigot("Spigot", serverVersions, serverTypeInfo[2], serverTypeInfo[3]);
newType = new Spigot("Spigot", false, serverVersions, serverTypeInfo[2],
serverTypeInfo[3]);
break;
case "Vanilla":
newType = new Vanilla("Vanilla", serverVersions, serverTypeInfo[2], serverTypeInfo[3]);
newType = new Vanilla("Vanilla", false, serverVersions, serverTypeInfo[2],
serverTypeInfo[3]);
break;
case "Snapshot":
newType = new Snapshot("Snapshot", serverVersions, serverTypeInfo[2], serverTypeInfo[3]);
newType = new Snapshot("Snapshot", false, serverVersions, serverTypeInfo[2],
serverTypeInfo[3]);
break;
case "MCPCplus":
newType = new MCPCPlus("MCPCplus", serverVersions, serverTypeInfo[2], serverTypeInfo[3]);
newType = new MCPCPlus("MCPCplus", false, serverVersions, serverTypeInfo[2],
serverTypeInfo[3]);
break;
case "Paper":
newType = new Paper("Paper", serverVersions, serverTypeInfo[2], serverTypeInfo[3]);
newType = new Paper("Paper", false, serverVersions, serverTypeInfo[2],
serverTypeInfo[3]);
break;
case "Bungee":
newType = new BungeeCord("Bungee", serverVersions, serverTypeInfo[2], serverTypeInfo[3],
serverTypeInfo[4], serverTypeInfo[5]);
newType = new BungeeCord("Bungee", true, serverVersions, serverTypeInfo[2],
serverTypeInfo[3], serverTypeInfo[4], serverTypeInfo[5]);
break;
case "Travertine":
newType = new Travertine("Travertine", serverVersions, serverTypeInfo[2], serverTypeInfo[3],
serverTypeInfo[4], serverTypeInfo[5]);
newType = new Travertine("Travertine", true, serverVersions, serverTypeInfo[2],
serverTypeInfo[3], serverTypeInfo[4], serverTypeInfo[5]);
break;
case "Waterfall":
newType = new Waterfall("Waterfall", serverVersions, serverTypeInfo[2], serverTypeInfo[3],
serverTypeInfo[4], serverTypeInfo[5]);
newType = new Waterfall("Waterfall", true, serverVersions, serverTypeInfo[2],
serverTypeInfo[3], serverTypeInfo[4], serverTypeInfo[5]);
break;
case "SpongeVanilla":
newType = new SpongeVanilla("SpongeVanilla", serverVersions, serverTypeInfo[2], serverTypeInfo[3],
serverTypeInfo[4], serverTypeInfo[5], serverTypeInfo[6]);
newType = new SpongeVanilla("SpongeVanilla", false, serverVersions,
serverTypeInfo[2], serverTypeInfo[3], serverTypeInfo[4], serverTypeInfo[5], serverTypeInfo[6]);
break;
case "Custom":
newType = new Custom("Custom", serverVersions, serverTypeInfo[2]);
newType = new Custom("Custom");
break;
default:
throw new IllegalArgumentException("Unknown server type defined in config file.");

View File

@ -0,0 +1,88 @@
package net.knarcraft.minecraftserverlauncher.server;
import java.util.Map;
public class ServerVersionContainer implements java.io.Serializable {
private String vanillaVersion;
private String snapshotVersion;
private String bungeeVersion;
private String waterfallVersion;
private String travertineVersion;
private Map<String, String> spongeVanillaVersions;
public ServerVersionContainer() {
}
public String getVanillaVersion() {
return this.vanillaVersion;
}
/**
* Sets the vanilla server version
*
* @param newVersion <p>The new vanilla server version</p>
* @return <p>This object</p>
*/
public ServerVersionContainer setVanillaVersion(String newVersion) {
this.vanillaVersion = newVersion;
return this;
}
public String getSnapshotVersion() {
return this.snapshotVersion;
}
public ServerVersionContainer setSnapshotVersion(String newVersion) {
this.snapshotVersion = newVersion;
return this;
}
public String getBungeeVersion() {
return this.bungeeVersion;
}
public ServerVersionContainer setBungeeVersion(String newVersion) {
this.bungeeVersion = newVersion;
return this;
}
public String getWaterfallVersion() {
return this.waterfallVersion;
}
public ServerVersionContainer setWaterfallVersion(String newVersion) {
this.waterfallVersion = newVersion;
return this;
}
public String getTravertineVersion() {
return this.travertineVersion;
}
public ServerVersionContainer setTravertineVersion(String newVersion) {
this.travertineVersion = newVersion;
return this;
}
public Map<String, String> getSpongeVanillaVersions() {
return this.spongeVanillaVersions;
}
public String getSpongeVanillaVersion(String versionKey) {
return spongeVanillaVersions.get(versionKey);
}
public ServerVersionContainer setSpongeVanillaVersion(Map<String, String> newVersions) {
this.spongeVanillaVersions = newVersions;
return this;
}
public ServerVersionContainer setSpongeVanillaVersion(String mapKey, String newValue) {
spongeVanillaVersions.put(mapKey, newValue);
return this;
}
}

View File

@ -3,49 +3,44 @@ package net.knarcraft.minecraftserverlauncher.server.servertypes;
/**
* Contains the bare minimum to be a functional server type.
*
* @author Kristian Knarvik <kristian.knarvik@knett.no>
* @version 1.0.0
* @since 1.0.0
* @author Kristian Knarvik <kristian.knarvik@knett.no>
* @version 1.0.0
* @since 1.0.0
*/
public abstract class AbstractServerType implements ServerType {
private final String typeName;
private final String[] versions;
final String downloadURL;
final String downloadURL;
private final String typeName;
private final boolean isProxy;
private final String[] versions;
/**
* Instantiates a new server type
* @param typeName <p>The typeName of the server type</p>
* @param versions <p>A list of one or more server versions for the type</p>
* @param downloadURL <p>The URL used for downloading .jar files</p>
*/
AbstractServerType(String typeName, String[] versions, String downloadURL) {
this.typeName = typeName;
this.versions = versions;
this.downloadURL = downloadURL;
}
/**
* Instantiates a new server type
*
* @param typeName <p>The typeName of the server type</p>
* @param isProxy <p>Whether this server type is a proxy server</p>
* @param versions <p>A list of one or more server versions for the type</p>
* @param downloadURL <p>The URL used for downloading .jar files</p>
*/
AbstractServerType(String typeName, boolean isProxy, String[] versions, String downloadURL) {
this.typeName = typeName;
this.isProxy = isProxy;
this.versions = versions;
this.downloadURL = downloadURL;
}
/**
* Gets the name of the server type
* @return <p>Server type typeName</p>
*/
public String getName() {
return this.typeName;
}
@Override
public String getName() {
return this.typeName;
}
/**
* Gets a list of versions available for the server type
* @return <p>A list of server versions</p>
*/
public String[] getVersions() {
return this.versions;
}
@Override
public boolean isProxy() {
return this.isProxy;
}
/**
* Gets the url used for downloading JAR files
* @return <p>A download URL</p>
*/
public String getDownloadURL() {
return this.downloadURL;
}
@Override
public String[] getVersions() {
return this.versions;
}
}

View File

@ -18,15 +18,16 @@ public class BungeeCord extends AbstractServerType {
/**
* Instantiates a new BungeeCord server type
*
* @param typeName <p>The name of the server type</p>
* @param versions <p>The available versions for the server type</p>
* @param versionURL <p>The URL used to finding the newest version</p>
* @param srcStart <p>The string after which the version id starts</p>
* @param srcEnd <p>The string marking the end of the version id</p>
* @param typeName <p>The name of the server type</p>
* @param isProxy <p>Whether this server type is a proxy server</p>
* @param versions <p>The available versions for the server type</p>
* @param versionURL <p>The URL used to finding the newest version</p>
* @param srcStart <p>The string after which the version id starts</p>
* @param srcEnd <p>The string marking the end of the version id</p>
* @param downloadURL <p>The URL used for downloading the latest version</p>
*/
public BungeeCord(String typeName, String[] versions, String versionURL, String srcStart, String srcEnd, String downloadURL) {
super(typeName, versions, downloadURL);
public BungeeCord(String typeName, boolean isProxy, String[] versions, String versionURL, String srcStart, String srcEnd, String downloadURL) {
super(typeName, isProxy, versions, downloadURL);
this.versionURL = versionURL;
this.srcStart = srcStart;
this.srcEnd = srcEnd;

View File

@ -12,13 +12,14 @@ public class CraftBukkit extends AbstractServerType {
/**
* Instantiates a new server type
*
* @param typeName <p>The name of the server type</p>
* @param versions <p>A list of one or more server versions for the type</p>
* @param downloadURL <p>The URL used for downloading .jar files</p>
* @param typeName <p>The name of the server type</p>
* @param isProxy <p>Whether this server type is a proxy server</p>
* @param versions <p>A list of one or more server versions for the type</p>
* @param downloadURL <p>The URL used for downloading .jar files</p>
* @param downloadURLPart <p>A string used after the download url as an additional part of the URL</p>
*/
public CraftBukkit(String typeName, String[] versions, String downloadURL, String downloadURLPart) {
super(typeName, versions, downloadURL);
public CraftBukkit(String typeName, boolean isProxy, String[] versions, String downloadURL, String downloadURLPart) {
super(typeName, isProxy, versions, downloadURL);
this.downloadURLPart = downloadURLPart;
}

View File

@ -8,11 +8,9 @@ public class Custom extends AbstractServerType {
* Instantiates a new server type
*
* @param typeName <p>The name of the server type</p>
* @param versions <p>A list of one or more server versions for the type</p>
* @param downloadURL <p>The URL used for downloading .jar files</p>
*/
public Custom(String typeName, String[] versions, String downloadURL) {
super(typeName, versions, downloadURL);
public Custom(String typeName) {
super(typeName, false, new String[]{}, "");
}
@Override

View File

@ -5,13 +5,14 @@ public class MCPCPlus extends CraftBukkit {
/**
* Instantiates a new server type
*
* @param typeName <p>The name of the server type</p>
* @param versions <p>A list of one or more server versions for the type</p>
* @param downloadURL <p>The URL used for downloading .jar files</p>
* @param typeName <p>The name of the server type</p>
* @param isProxy <p>Whether this server type is a proxy server</p>
* @param versions <p>A list of one or more server versions for the type</p>
* @param downloadURL <p>The URL used for downloading .jar files</p>
* @param downloadURLPart <p>A string used after the download url as an additional part of the URL</p>
*/
public MCPCPlus(String typeName, String[] versions, String downloadURL, String downloadURLPart) {
super(typeName, versions, downloadURL, downloadURLPart);
public MCPCPlus(String typeName, boolean isProxy, String[] versions, String downloadURL, String downloadURLPart) {
super(typeName, isProxy, versions, downloadURL, downloadURLPart);
}
}

View File

@ -5,13 +5,14 @@ public class Paper extends Spigot {
/**
* Instantiates a new server type
*
* @param typeName <p>The typeName of the server type</p>
* @param versions <p>A list of one or more server versions for the type</p>
* @param downloadURL <p>The URL used for downloading .jar files</p>
* @param typeName <p>The typeName of the server type</p>
* @param isProxy <p>Whether this server type is a proxy server</p>
* @param versions <p>A list of one or more server versions for the type</p>
* @param downloadURL <p>The URL used for downloading .jar files</p>
* @param downloadURLPart <p>A string used after the download url as an additional part of the URL</p>
*/
public Paper(String typeName, String[] versions, String downloadURL, String downloadURLPart) {
super(typeName, versions, downloadURL, downloadURLPart);
public Paper(String typeName, boolean isProxy, String[] versions, String downloadURL, String downloadURLPart) {
super(typeName, isProxy, versions, downloadURL, downloadURLPart);
}
}

View File

@ -7,14 +7,23 @@ import java.io.IOException;
*/
public interface ServerType {
/**
* Gets whether this server type is a proxy server
*
* @return <p>True if this server type is a proxy server</p>
*/
boolean isProxy();
/**
* Gets the name of the server type
*
* @return <p>Server type name</p>
*/
String getName();
/**
* Gets a list of versions available for the server type
*
* @return <p>A list of server versions</p>
*/
String[] getVersions();
@ -22,7 +31,7 @@ public interface ServerType {
/**
* Downloads a .jar file for this server type
*
* @param folder <p>The folder to save the downloaded file to</p>
* @param folder <p>The folder to save the downloaded file to</p>
* @param version <p>The server type version to use</p>
* @return <p>True if the file exists or was downloaded</p>
*/

View File

@ -5,13 +5,14 @@ public class Snapshot extends Vanilla {
/**
* Instantiates a snapshot server type
*
* @param typeName <p>The name of this server type</p>
* @param versions <p>Available versions for this server type</p>
* @param versionURL <p>The URL used for downloading the version document</p>
* @param downloadURL <p>The URL used for downloading the new file</p>
* @param typeName <p>The name of this server type</p>
* @param isProxy <p>Whether this server type is a proxy server</p>
* @param versions <p>Available versions for this server type</p>
* @param versionURL <p>The URL used for downloading the version document</p>
* @param downloadURL <p>The URL used for downloading the new file</p>
*/
public Snapshot(String typeName, String[] versions, String versionURL, String downloadURL) {
super(typeName, versions, versionURL, downloadURL);
public Snapshot(String typeName, boolean isProxy, String[] versions, String versionURL, String downloadURL) {
super(typeName, isProxy, versions, versionURL, downloadURL);
this.releaseType = "snapshot";
}

View File

@ -5,13 +5,14 @@ public class Spigot extends CraftBukkit {
/**
* Instantiates a new server type
*
* @param typeName <p>The typeName of the server type</p>
* @param versions <p>A list of one or more server versions for the type</p>
* @param downloadURL <p>The URL used for downloading .jar files</p>
* @param typeName <p>The typeName of the server type</p>
* @param isProxy <p>Whether this server type is a proxy server</p>
* @param versions <p>A list of one or more server versions for the type</p>
* @param downloadURL <p>The URL used for downloading .jar files</p>
* @param downloadURLPart <p>A string used after the download url as an additional part of the URL</p>
*/
public Spigot(String typeName, String[] versions, String downloadURL, String downloadURLPart) {
super(typeName, versions, downloadURL, downloadURLPart);
public Spigot(String typeName, boolean isProxy, String[] versions, String downloadURL, String downloadURLPart) {
super(typeName, isProxy, versions, downloadURL, downloadURLPart);
}
}

View File

@ -20,6 +20,7 @@ public class SpongeVanilla extends AbstractServerType {
* Instantiates a new SpongeVanilla server type
*
* @param typeName <p>The name of this server type</p>
* @param isProxy <p>Whether this server type is a proxy server</p>
* @param versions <p>Available versions for this server type</p>
* @param versionURL <p>The URL used for downloading the version document</p>
* @param srcStart <p>The string to search for to determine newest version</p>
@ -27,9 +28,9 @@ public class SpongeVanilla extends AbstractServerType {
* @param downloadURL <p>The URL used for downloading the new file</p>
* @param downloadURLPart <p>A string used after the download url as an additional part of the URL</p>
*/
public SpongeVanilla(String typeName, String[] versions, String versionURL, String srcStart, String srcEnd,
public SpongeVanilla(String typeName, boolean isProxy, String[] versions, String versionURL, String srcStart, String srcEnd,
String downloadURL, String downloadURLPart) {
super(typeName, versions, downloadURL);
super(typeName, isProxy, versions, downloadURL);
this.versionURL = versionURL;
this.srcStart = srcStart;
this.srcEnd = srcEnd;

View File

@ -5,15 +5,16 @@ public class Travertine extends Waterfall {
/**
* Instantiates a new Travertine server type
*
* @param typeName <p>The name of the server type</p>
* @param versions <p>The available versions for the server type</p>
* @param versionURL <p>The URL used to finding the newest version</p>
* @param srcStart <p>The string after which the version id starts</p>
* @param srcEnd <p>The string marking the end of the version id</p>
* @param typeName <p>The name of the server type</p>
* @param isProxy <p>Whether this server type is a proxy server</p>
* @param versions <p>The available versions for the server type</p>
* @param versionURL <p>The URL used to finding the newest version</p>
* @param srcStart <p>The string after which the version id starts</p>
* @param srcEnd <p>The string marking the end of the version id</p>
* @param downloadURL <p>The URL used for downloading the latest version</p>
*/
public Travertine(String typeName, String[] versions, String versionURL, String srcStart, String srcEnd, String downloadURL) {
super(typeName, versions, versionURL, srcStart, srcEnd, downloadURL);
public Travertine(String typeName, boolean isProxy, String[] versions, String versionURL, String srcStart, String srcEnd, String downloadURL) {
super(typeName, isProxy, versions, versionURL, srcStart, srcEnd, downloadURL);
}
}

View File

@ -16,19 +16,20 @@ import static net.knarcraft.minecraftserverlauncher.utility.CommonFunctions.read
public class Vanilla extends AbstractServerType {
private final String versionURL;
private String lastVersion;
String releaseType;
private String lastVersion;
/**
* Instantiates a vanilla server type
*
* @param typeName <p>The name of this server type to display</p>
* @param versions <p>Available versions for this server type</p>
* @param versionURL <p>The URL used for downloading the version document</p>
* @param downloadURL <p>The URL used for downloading the new file</p>
* @param typeName <p>The name of this server type to display</p>
* @param isProxy <p>Whether this server type is a proxy server</p>
* @param versions <p>Available versions for this server type</p>
* @param versionURL <p>The URL used for downloading the version document</p>
* @param downloadURL <p>The URL used for downloading the new file</p>
*/
public Vanilla(String typeName, String[] versions, String versionURL, String downloadURL) {
super(typeName, versions, downloadURL);
public Vanilla(String typeName, boolean isProxy, String[] versions, String versionURL, String downloadURL) {
super(typeName, isProxy, versions, downloadURL);
this.versionURL = versionURL;
this.releaseType = "release";
}

View File

@ -18,15 +18,17 @@ public class Waterfall extends AbstractServerType {
/**
* Instantiates a new Waterfall server type
*
* @param typeName <p>The name of the server type</p>
* @param versions <p>The available versions for the server type</p>
* @param versionURL <p>The URL used to finding the newest version</p>
* @param srcStart <p>The string after which the version id starts</p>
* @param srcEnd <p>The string marking the end of the version id</p>
* @param typeName <p>The name of the server type</p>
* @param isProxy <p>Whether this server type is a proxy server</p>
* @param versions <p>The available versions for the server type</p>
* @param versionURL <p>The URL used to finding the newest version</p>
* @param srcStart <p>The string after which the version id starts</p>
* @param srcEnd <p>The string marking the end of the version id</p>
* @param downloadURL <p>The URL used for downloading the latest version</p>
*/
public Waterfall(String typeName, String[] versions, String versionURL, String srcStart, String srcEnd, String downloadURL) {
super(typeName, versions, downloadURL);
public Waterfall(String typeName, boolean isProxy, String[] versions, String versionURL, String srcStart,
String srcEnd, String downloadURL) {
super(typeName, isProxy, versions, downloadURL);
this.srcStart = srcStart;
this.srcEnd = srcEnd;
this.versionURL = versionURL;