Adds support for the travertine and waterfall server proxies
This commit is contained in:
parent
a2d4d491ba
commit
094a1facb2
@ -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()));
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,9 @@ Spigot;1.16.1,1.15.2,1.14.4,1.13.2,1.12.2,1.11.2,1.10.2,1.9.4,1.9.4,1.8.8,1.7.10
|
||||
MCPCplus;1.6.4,1.6.2,1.5.2,1.4.7;https://static.knarcraft.net/archive/downloads/minecraftserverjars/MCPC+/;mcpcplus
|
||||
Craftbukkit;1.13.2,1.12.2,1.11.2,1.10.2,1.9.4,1.8.8,1.7.10-R0.1,1.6.4-R2.0,1.5.2-R1.0,1.4.6-R0.3,1.3.2-R3.0,1.2.5-R2.0,1.1-R6,1.0.1-R1;https://static.knarcraft.net/archive/downloads/minecraftserverjars/Bukkit/;craftbukkit-
|
||||
Paper;1.16.1,1.15.2,1.14.4,1.13.2,1.12.2,1.11.2,1.10.2,1.9.4,1.8.8;https://static.knarcraft.net/archive/downloads/minecraftserverjars/Paper/;Paper-
|
||||
Bungee;Latest;https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/;Artifacts of BungeeCord #; ;http://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/BungeeCord.jar;
|
||||
Bungee;Latest;https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/;Artifacts of BungeeCord #; ;http://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/BungeeCord.jar
|
||||
Waterfall;Latest;https://papermc.io/api/v1/waterfall/1.16;"latest":";";https://papermc.io/api/v1/waterfall/1.16/
|
||||
Travertine;Latest;https://papermc.io/api/v1/travertine/1.16;"latest":";";https://papermc.io/api/v1/travertine/1.16/
|
||||
Snapshot;Latest;https://launchermeta.mojang.com/mc/game/version_manifest.json;"snapshot":";";https://s3.amazonaws.com/Minecraft.Download/versions/
|
||||
Vanilla;Latest,1.16.1,1.15.2,1.14.4,1.13.2,1.12.2,1.11.2,1.10.2,1.9.4,1.8.9,1.7.10,1.6.4,1.5.2,1.4.7,1.3.2,1.2.5;https://launchermeta.mojang.com/mc/game/version_manifest.json;"release":";";https://s3.amazonaws.com/Minecraft.Download/versions/
|
||||
Custom;;
|
Can't render this file because it contains an unexpected character in line 1 and column 151.
|
@ -8,6 +8,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class DownloadTests {
|
||||
|
||||
@Test
|
||||
public void downloadJarsTest() throws IOException {
|
||||
String targetDirectory = Main.getApplicationWorkDirectory() + File.separator + "files" + File.separator + "testjars" + File.separator;
|
||||
|
Loading…
Reference in New Issue
Block a user