1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Requested changes

This commit is contained in:
Daniel Walsh 2020-07-23 09:51:35 +01:00
parent d547d61151
commit 6f92bd6c28

View File

@ -55,7 +55,12 @@ public class MetricsService {
public MetricsService(SlimefunPlugin plugin) { public MetricsService(SlimefunPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
this.metricFile = new File(plugin.getDataFolder(), REPO_NAME + ".jar");
File parentFile = new File(plugin.getDataFolder(), "cache" + File.separatorChar + "modules");
if (!parentFile.exists())
parentFile.mkdirs();
this.metricFile = new File(parentFile , REPO_NAME + ".jar");
} }
/** /**
@ -68,7 +73,6 @@ public class MetricsService {
plugin.getLogger().warning("Failed to start metrics as the file could not be downloaded."); plugin.getLogger().warning("Failed to start metrics as the file could not be downloaded.");
return; return;
} }
newlyDownloaded = true;
} }
try { try {
@ -94,13 +98,13 @@ public class MetricsService {
// Finally, we're good to start this. // Finally, we're good to start this.
Method start = cl.getDeclaredMethod("start"); Method start = cl.getDeclaredMethod("start");
String s = cl.getPackage().getImplementationVersion(); String version = cl.getPackage().getImplementationVersion();
// This is required to be sync due to bStats. // This is required to be sync due to bStats.
Slimefun.runSync(() -> { Slimefun.runSync(() -> {
try { try {
start.invoke(null); start.invoke(null);
plugin.getLogger().info("Metrics build " + s + " started."); plugin.getLogger().info("Metrics build #" + version + " started.");
} catch (Exception e) { } catch (Exception e) {
plugin.getLogger().log(Level.WARNING, "Failed to start metrics.", e); plugin.getLogger().log(Level.WARNING, "Failed to start metrics.", e);
} }
@ -133,10 +137,7 @@ public class MetricsService {
* @return True if there is an update available. * @return True if there is an update available.
*/ */
public boolean checkForUpdate(String currentVersion) { public boolean checkForUpdate(String currentVersion) {
if (currentVersion == null if (currentVersion == null || !PatternUtils.NUMERIC.matcher(currentVersion).matches()) {
|| currentVersion.equals("UNOFFICIAL")
|| !PatternUtils.NUMERIC.matcher(currentVersion).matches()
) {
return false; return false;
} }