mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixed Metrics
This commit is contained in:
parent
eb8e689d2c
commit
5a1b868c91
@ -187,11 +187,16 @@ public class MetricsService {
|
||||
* The version to download.
|
||||
*/
|
||||
private boolean download(int version) {
|
||||
File f = new File(parentFolder, "Metrics-" + version + ".jar");
|
||||
File file = new File(parentFolder, "Metrics-" + version + ".jar");
|
||||
|
||||
try {
|
||||
plugin.getLogger().log(Level.INFO, "# Starting download of MetricsModule build: #{0}", version);
|
||||
|
||||
|
||||
if (file.exists()) {
|
||||
// Delete the file in case we accidentally downloaded it before
|
||||
Files.delete(file.toPath());
|
||||
}
|
||||
|
||||
AtomicInteger lastPercentPosted = new AtomicInteger();
|
||||
GetRequest request = Unirest.get(GH_RELEASES + "/" + version + "/" + REPO_NAME + ".jar");
|
||||
|
||||
@ -202,14 +207,14 @@ public class MetricsService {
|
||||
plugin.getLogger().info("# Downloading... " + percent + "% " + "(" + bytesWritten + "/" + totalBytes + " bytes)");
|
||||
lastPercentPosted.set(percent);
|
||||
}
|
||||
}).asFile(f.getPath());
|
||||
}).asFile(file.getPath());
|
||||
|
||||
if (response.isSuccess()) {
|
||||
plugin.getLogger().log(Level.INFO, "Successfully downloaded {0} build: #{1}", new Object[] { REPO_NAME, version });
|
||||
|
||||
// Replace the metric file with the new one
|
||||
cleanUp();
|
||||
Files.move(f.toPath(), metricsModuleFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
Files.move(file.toPath(), metricsModuleFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
metricVersion = String.valueOf(version);
|
||||
hasDownloadedUpdate = true;
|
||||
|
Loading…
Reference in New Issue
Block a user