Adds the ability to download old bungee versions
This commit is contained in:
parent
2f8117ebfa
commit
2acc6f4d13
@ -122,7 +122,7 @@ public class ServerTypeHandler {
|
|||||||
break;
|
break;
|
||||||
case "Bungee":
|
case "Bungee":
|
||||||
newType = new BungeeCord("Bungee", true, serverVersions, serverTypeInfo[2],
|
newType = new BungeeCord("Bungee", true, serverVersions, serverTypeInfo[2],
|
||||||
serverTypeInfo[3], serverTypeInfo[4], serverTypeInfo[5]);
|
serverTypeInfo[3], serverTypeInfo[4], serverTypeInfo[5], serverTypeInfo[6], serverTypeInfo[7]);
|
||||||
break;
|
break;
|
||||||
case "Travertine":
|
case "Travertine":
|
||||||
newType = new Travertine("Travertine", true, serverVersions, serverTypeInfo[2],
|
newType = new Travertine("Travertine", true, serverVersions, serverTypeInfo[2],
|
||||||
|
@ -18,6 +18,8 @@ public class BungeeCord extends AbstractServerType {
|
|||||||
private final String versionURL;
|
private final String versionURL;
|
||||||
private final String srcStart;
|
private final String srcStart;
|
||||||
private final String srcEnd;
|
private final String srcEnd;
|
||||||
|
private final String oldVersionsURL;
|
||||||
|
private final String oldVersionsPrefix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new BungeeCord server type
|
* Instantiates a new BungeeCord server type
|
||||||
@ -30,18 +32,39 @@ public class BungeeCord extends AbstractServerType {
|
|||||||
* @param srcEnd <p>The string marking the end of the version id</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>
|
* @param downloadURL <p>The URL used for downloading the latest version</p>
|
||||||
*/
|
*/
|
||||||
public BungeeCord(String typeName, boolean isProxy, String[] versions, String versionURL, String srcStart, String srcEnd, String downloadURL) {
|
public BungeeCord(String typeName, boolean isProxy, String[] versions, String versionURL, String srcStart,
|
||||||
|
String srcEnd, String downloadURL, String oldVersionsURL, String oldVersionsPrefix) {
|
||||||
super(typeName, isProxy, versions, downloadURL);
|
super(typeName, isProxy, versions, downloadURL);
|
||||||
this.versionURL = versionURL;
|
this.versionURL = versionURL;
|
||||||
this.srcStart = srcStart;
|
this.srcStart = srcStart;
|
||||||
this.srcEnd = srcEnd;
|
this.srcEnd = srcEnd;
|
||||||
|
this.oldVersionsURL = oldVersionsURL;
|
||||||
|
this.oldVersionsPrefix = oldVersionsPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean downloadJar(String folder, String version) throws IOException {
|
public boolean downloadJar(String folder, String version) throws IOException {
|
||||||
|
String targetFile = this.getName() + version + ".jar";
|
||||||
|
File filePath = new File(folder + targetFile);
|
||||||
|
|
||||||
|
if (version.equals("Latest")) {
|
||||||
|
return downloadLatestJar(filePath);
|
||||||
|
} else {
|
||||||
|
String file = oldVersionsPrefix + version + ".jar";
|
||||||
|
return filePath.isFile() || downloadFile(oldVersionsURL + file, Paths.get(filePath.toURI()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downloads the latest BungeeCord .jar file
|
||||||
|
*
|
||||||
|
* @param filePath <p>The file path to download the new jar to</p>
|
||||||
|
* @return <p>True if the jar exists or was successfully downloaded</p>
|
||||||
|
* @throws IOException <p>If unable to download the new jar</p>
|
||||||
|
*/
|
||||||
|
private boolean downloadLatestJar(File filePath) throws IOException {
|
||||||
ServerVersionContainer versionContainer = ServerVersionContainer.getInstance();
|
ServerVersionContainer versionContainer = ServerVersionContainer.getInstance();
|
||||||
String file = this.getName() + version + ".jar";
|
|
||||||
File filePath = new File(folder + file);
|
|
||||||
String newestVersion = stringBetween(readFile(versionURL), srcStart, srcEnd);
|
String newestVersion = stringBetween(readFile(versionURL), srcStart, srcEnd);
|
||||||
String oldVersion = versionContainer.getBungeeVersion();
|
String oldVersion = versionContainer.getBungeeVersion();
|
||||||
//The file is already the newest version
|
//The file is already the newest version
|
||||||
@ -55,4 +78,5 @@ public class BungeeCord extends AbstractServerType {
|
|||||||
versionContainer.setBungeeVersion(newestVersion);
|
versionContainer.setBungeeVersion(newestVersion);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
|
Vanilla;Latest,Snapshot,1.16.2,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/
|
||||||
SpongeVanilla;1.12.2,1.11.2,1.10.2,1.8.9;https://dl-api.spongepowered.org/v1/org.spongepowered/spongevanilla/downloads?type=stable&minecraft=;"version":";",;https://repo.spongepowered.org/maven/org/spongepowered/spongevanilla/;/spongevanilla-
|
SpongeVanilla;1.12.2,1.11.2,1.10.2,1.8.9;https://dl-api.spongepowered.org/v1/org.spongepowered/spongevanilla/downloads?type=stable&minecraft=;"version":";",;https://repo.spongepowered.org/maven/org/spongepowered/spongevanilla/;/spongevanilla-
|
||||||
SpongeForge;1.12.2,1.11.2,1.10.2;https://dl-api.spongepowered.org/v1/org.spongepowered/spongeforge/downloads?type=stable&minecraft=;"version":";",;https://repo.spongepowered.org/maven/org/spongepowered/spongeforge/;/spongeforge-
|
SpongeForge;1.12.2,1.11.2,1.10.2;https://dl-api.spongepowered.org/v1/org.spongepowered/spongeforge/downloads?type=stable&minecraft=;"version":";",;https://repo.spongepowered.org/maven/org/spongepowered/spongeforge/;/spongeforge-
|
||||||
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,1.6.4-R2.1,1.5.2-R1.1,1.4.7-R1.1;https://static.knarcraft.net/archive/downloads/minecraftserverjars/Spigot/;spigot-
|
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,1.6.4-R2.1,1.5.2-R1.1,1.4.7-R1.1;https://static.knarcraft.net/archive/downloads/minecraftserverjars/Spigot/;spigot-
|
||||||
MCPCplus;1.6.4,1.6.2,1.5.2,1.4.7;https://static.knarcraft.net/archive/downloads/minecraftserverjars/MCPC+/;mcpcplus
|
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,b1.8.1,b1.7.3;https://static.knarcraft.net/archive/downloads/minecraftserverjars/Bukkit/;craftbukkit-
|
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,b1.8.1,b1.7.3;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-
|
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,1.7.10,1.6.4,1.5.2,1.4.7;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;https://static.knarcraft.net/archive/downloads/minecraftserverjars/BungeeCord/;BungeeCord-
|
||||||
Waterfall;Latest;https://papermc.io/api/v1/waterfall/1.16;"latest":";";https://papermc.io/api/v1/waterfall/1.16/
|
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/
|
Travertine;Latest;https://papermc.io/api/v1/travertine/1.16;"latest":";";https://papermc.io/api/v1/travertine/1.16/
|
||||||
Vanilla;Latest,Snapshot,1.16.2,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;;
|
Custom;;
|
Can't render this file because it contains an unexpected character in line 1 and column 151.
|
Loading…
Reference in New Issue
Block a user