Adds support for the travertine and waterfall server proxies
This commit is contained in:
@ -9,7 +9,9 @@ import net.knarcraft.minecraftserverlauncher.server.servertypes.ServerType;
|
||||
import net.knarcraft.minecraftserverlauncher.server.servertypes.Snapshot;
|
||||
import net.knarcraft.minecraftserverlauncher.server.servertypes.Spigot;
|
||||
import net.knarcraft.minecraftserverlauncher.server.servertypes.SpongeVanilla;
|
||||
import net.knarcraft.minecraftserverlauncher.server.servertypes.Travertine;
|
||||
import net.knarcraft.minecraftserverlauncher.server.servertypes.Vanilla;
|
||||
import net.knarcraft.minecraftserverlauncher.server.servertypes.Waterfall;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -121,6 +123,14 @@ public class ServerTypeHandler {
|
||||
newType = new BungeeCord("Bungee", 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]);
|
||||
break;
|
||||
case "Waterfall":
|
||||
newType = new Waterfall("Waterfall", 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]);
|
||||
|
@ -16,11 +16,14 @@ public class BungeeCord extends AbstractServerType {
|
||||
private String srcEnd;
|
||||
|
||||
/**
|
||||
* Instantiates a new server type
|
||||
* Instantiates a new BungeeCord 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 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 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);
|
||||
|
@ -1,4 +1,19 @@
|
||||
package net.knarcraft.minecraftserverlauncher.server.servertypes;
|
||||
|
||||
public class Travertine {
|
||||
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 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,45 @@
|
||||
package net.knarcraft.minecraftserverlauncher.server.servertypes;
|
||||
|
||||
public class Waterfall {
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static net.knarcraft.minecraftserverlauncher.utility.CommonFunctions.downloadFile;
|
||||
import static net.knarcraft.minecraftserverlauncher.utility.CommonFunctions.readFile;
|
||||
import static net.knarcraft.minecraftserverlauncher.utility.CommonFunctions.stringBetween;
|
||||
|
||||
public class Waterfall extends AbstractServerType {
|
||||
|
||||
private String srcStart;
|
||||
private String srcEnd;
|
||||
private String versionURL;
|
||||
private String lastVersion;
|
||||
|
||||
/**
|
||||
* 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 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);
|
||||
this.srcStart = srcStart;
|
||||
this.srcEnd = srcEnd;
|
||||
this.versionURL = versionURL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean downloadJar(String folder, String version) throws IOException {
|
||||
String file = this.getName() + version + ".jar";
|
||||
File filePath = new File(folder + file);
|
||||
String newestVersion = stringBetween(readFile(versionURL), srcStart, srcEnd);
|
||||
String oldVersion = lastVersion;
|
||||
lastVersion = newestVersion;
|
||||
String fullURL = downloadURL + newestVersion + "/download";
|
||||
return (filePath.isFile() && newestVersion.equals(oldVersion)) || downloadFile(fullURL, Paths.get(filePath.toURI()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user