Changes download URLs of Paper to papermc.io
All checks were successful
KnarCraft/Minecraft-Server-Launcher/pipeline/head This commit looks good

Updates software version
Stores version of downloaded Paper .jar files
Completes #8
This commit is contained in:
2021-08-23 14:53:39 +02:00
parent 9d8531535d
commit 365d08f2e2
6 changed files with 46 additions and 12 deletions

View File

@ -134,7 +134,7 @@ public class ServerTypeHandler {
break;
case "Paper":
newType = new Paper("Paper", false, serverVersions, serverTypeInfo[2],
serverTypeInfo[3]);
serverTypeInfo[3], serverTypeInfo[4], serverTypeInfo[5]);
break;
case "Bungee":
newType = new BungeeCord("Bungee", true, serverVersions, serverTypeInfo[2],

View File

@ -22,6 +22,7 @@ public class ServerVersionContainer {
private String bungeeVersion;
private Map<String, String> waterfallVersions;
private Map<String, String> travertineVersions;
private Map<String, String> paperVersions;
private Map<String, String> spongeVanillaVersions;
private Map<String, String> spongeForgeVersions;
private String downloadedBuildToolsVersion;
@ -32,6 +33,7 @@ public class ServerVersionContainer {
private ServerVersionContainer() {
this.waterfallVersions = new HashMap<>();
this.travertineVersions = new HashMap<>();
this.paperVersions = new HashMap<>();
this.spongeVanillaVersions = new HashMap<>();
this.spongeForgeVersions = new HashMap<>();
loadState();
@ -58,6 +60,7 @@ public class ServerVersionContainer {
this.bungeeVersion = null;
this.waterfallVersions = new HashMap<>();
this.travertineVersions = new HashMap<>();
this.paperVersions = new HashMap<>();
this.spongeVanillaVersions = new HashMap<>();
this.spongeForgeVersions = new HashMap<>();
this.downloadedBuildToolsVersion = null;
@ -70,6 +73,7 @@ public class ServerVersionContainer {
"bungeeVersion;" + bungeeVersion + "\n" +
"waterfallVersions;" + mapToString(waterfallVersions) + "\n" +
"travertineVersions;" + mapToString(travertineVersions) + "\n" +
"paperVersions;" + mapToString(paperVersions) + "\n" +
"spongeVanillaVersions;" + mapToString(spongeVanillaVersions) + "\n" +
"spongeForgeVersions;" + mapToString(spongeForgeVersions) + "\n" +
"downloadedBuildToolsVersion;" + downloadedBuildToolsVersion;
@ -163,6 +167,9 @@ public class ServerVersionContainer {
case "travertineVersions":
parseVersionsToMap(travertineVersions, variableValue);
break;
case "paperVersions":
parseVersionsToMap(paperVersions, variableValue);
break;
case "spongeVanillaVersions":
parseVersionsToMap(spongeVanillaVersions, variableValue);
break;
@ -291,6 +298,27 @@ public class ServerVersionContainer {
saveState();
}
/**
* Gets a specific paper version
*
* @param versionKey <p>The version to check the current version of</p>
* @return <p>The current paper version</p>
*/
public String getPaperVersion(String versionKey) {
return this.paperVersions.get(versionKey);
}
/**
* Sets the current version for a given paper version
*
* @param mapKey <p>The version key to set version for</p>
* @param newValue <p>The new current version</p>
*/
public void setPaperVersion(String mapKey, String newValue) {
this.paperVersions.put(mapKey, newValue);
saveState();
}
/**
* Gets a specific sponge vanilla version
*

View File

@ -3,19 +3,25 @@ package net.knarcraft.minecraftserverlauncher.server.servertypes;
/**
* This class represents the Paper Minecraft server type
*/
public class Paper extends Spigot {
public class Paper extends Waterfall {
/**
* Instantiates a new Paper server type
*
* @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>
* @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 Paper(String typeName, boolean isProxy, String[] versions, String downloadURL, String downloadURLPart) {
super(typeName, isProxy, versions, downloadURL, downloadURLPart);
public Paper(String typeName, boolean isProxy, String[] versions, String versionURL, String srcStart,
String srcEnd, String downloadURL) {
super(typeName, isProxy, versions, versionURL, srcStart, srcEnd, downloadURL);
this.oldVersionFunction = serverVersionContainer::getPaperVersion;
this.versionUpdateFunction = serverVersionContainer::setPaperVersion;
}
}