Makes some improvements
All checks were successful
KnarCraft/Minecraft-Server-Launcher/pipeline/head This commit looks good

Saves the downloaded BuildTools version to the server version container
Adds a check to see whether the BuildTools file exists
Adds a helper function for reading local files
This commit is contained in:
2021-08-02 16:09:22 +02:00
parent 51ceac69da
commit 043f2045e6
12 changed files with 77 additions and 31 deletions

View File

@ -21,6 +21,7 @@ public class ServerVersionContainer {
private Map<String, String> travertineVersions;
private Map<String, String> spongeVanillaVersions;
private Map<String, String> spongeForgeVersions;
private String downloadedBuildToolsVersion;
/**
* Initializes a new server version container
@ -56,6 +57,7 @@ public class ServerVersionContainer {
this.travertineVersions = new HashMap<>();
this.spongeVanillaVersions = new HashMap<>();
this.spongeForgeVersions = new HashMap<>();
this.downloadedBuildToolsVersion = null;
}
@Override
@ -66,7 +68,8 @@ public class ServerVersionContainer {
"waterfallVersions;" + mapToString(waterfallVersions) + "\n" +
"travertineVersions;" + mapToString(travertineVersions) + "\n" +
"spongeVanillaVersions;" + mapToString(spongeVanillaVersions) + "\n" +
"spongeForgeVersions;" + mapToString(spongeForgeVersions);
"spongeForgeVersions;" + mapToString(spongeForgeVersions) + "\n" +
"downloadedBuildToolsVersion;" + downloadedBuildToolsVersion;
}
/**
@ -105,7 +108,7 @@ public class ServerVersionContainer {
}
}
file = new PrintWriter(versionFile);
file.println(this.toString());
file.println(this);
file.close();
} catch (IOException e) {
e.printStackTrace();
@ -163,6 +166,9 @@ public class ServerVersionContainer {
case "spongeForgeVersions":
parseVersionsToMap(spongeForgeVersions, variableValue);
break;
case "downloadedBuildToolsVersion":
downloadedBuildToolsVersion = variableValue;
break;
default:
throw new IllegalArgumentException("Invalid key encountered in the server version file.");
}
@ -323,5 +329,25 @@ public class ServerVersionContainer {
spongeForgeVersions.put(mapKey, newValue);
saveState();
}
/**
* Gets the version of the downloaded BuildTools file
*
* @return <p>The version of the downloaded BuildTools file</p>
*/
public String getDownloadedBuildToolsVersion() {
return this.downloadedBuildToolsVersion;
}
/**
* Sets the version of the downloaded BuildTools file
*
* @param newValue <p>The new version</p></p>
*/
public void setDownloadedBuildToolsVersion(String newValue) {
this.downloadedBuildToolsVersion = newValue;
saveState();
}
}