diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java new file mode 100644 index 000000000..5eee54dc1 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java @@ -0,0 +1,20 @@ +package io.github.thebusybiscuit.slimefun4.api; + +public enum SlimefunBranch { + + DEVELOPMENT("master"), + STABLE("stable"), + UNOFFICIAL("Unknown"), + UNKNOWN("Unknown"); + + private final String name; + + private SlimefunBranch(String name) { + this.name = name; + } + + public String getName() { + return name; + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java index ef81693dd..f2d6e71fd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java @@ -33,17 +33,7 @@ public class MetricsService extends Metrics { } })); - addCustomChart(new SimplePie("branch", () -> { - if (plugin.getDescription().getVersion().startsWith("DEV - ")) { - return "master"; - } - else if (plugin.getDescription().getVersion().startsWith("RC - ")) { - return "stable"; - } - else { - return "Unknown"; - } - })); + addCustomChart(new SimplePie("branch", SlimefunPlugin.getUpdater().getBranch()::getName)); addCustomChart(new SimplePie("language", () -> { Language language = SlimefunPlugin.getLocal().getDefaultLanguage(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java index 7b2b6e43d..1bb61b8d3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java @@ -5,37 +5,47 @@ import java.util.logging.Level; import org.bukkit.plugin.Plugin; -import io.github.thebusybiscuit.cscorelib2.updater.BukkitUpdater; import io.github.thebusybiscuit.cscorelib2.updater.GitHubBuildsUpdater; import io.github.thebusybiscuit.cscorelib2.updater.Updater; +import io.github.thebusybiscuit.slimefun4.api.SlimefunBranch; public class UpdaterService { private final Updater updater; + private final SlimefunBranch branch; public UpdaterService(Plugin plugin, File file) { String version = plugin.getDescription().getVersion(); if (version.equals("UNOFFICIAL")) { // This Server is using a modified build that is not a public release. + plugin.getLogger().log(Level.WARNING, "##################################################"); plugin.getLogger().log(Level.WARNING, "It looks like you are using an unofficially modified build of Slimefun!"); plugin.getLogger().log(Level.WARNING, "Auto-Updates have been disabled, this build is not considered safe."); plugin.getLogger().log(Level.WARNING, "Do not report bugs encountered in this Version of Slimefun."); + plugin.getLogger().log(Level.WARNING, "##################################################"); updater = null; + branch = SlimefunBranch.UNOFFICIAL; } else if (version.startsWith("DEV - ")) { // If we are using a development build, we want to switch to our custom updater = new GitHubBuildsUpdater(plugin, file, "TheBusyBiscuit/Slimefun4/master"); + branch = SlimefunBranch.DEVELOPMENT; } else if (version.startsWith("RC - ")) { // If we are using a "stable" build, we want to switch to our custom updater = new GitHubBuildsUpdater(plugin, file, "TheBusyBiscuit/Slimefun4/stable", "RC - "); + branch = SlimefunBranch.STABLE; } else { - // We are using an official build from Bukkit, use the BukkitDev Updater - updater = new BukkitUpdater(plugin, file, 53485); + updater = null; + branch = SlimefunBranch.UNKNOWN; } } + + public SlimefunBranch getBranch() { + return branch; + } public void start() { if (updater != null) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java index f928b8744..75132ae68 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java @@ -474,6 +474,10 @@ public final class SlimefunPlugin extends JavaPlugin { return instance.blockDataService; } + public static UpdaterService getUpdater() { + return instance.updaterService; + } + public static GitHubService getGitHubService() { return instance.gitHubService; }