mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
[Ci skip] Added SlimefunBranch enum
This commit is contained in:
parent
2ab549f7a4
commit
cc8bb1bebb
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
|
@ -5,38 +5,48 @@ 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) {
|
||||
updater.start();
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user