mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 12:07:35 +01:00
Added VersionCheckSystem & Modularized Theme
This commit is contained in:
parent
bd238f4efe
commit
f14c481a29
@ -22,12 +22,9 @@ package main.java.com.djrapitops.plan;
|
||||
import com.djrapitops.plugin.BukkitPlugin;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.Benchmark;
|
||||
import com.djrapitops.plugin.api.Priority;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.api.config.Config;
|
||||
import com.djrapitops.plugin.api.systems.NotificationCenter;
|
||||
import com.djrapitops.plugin.api.systems.TaskCenter;
|
||||
import com.djrapitops.plugin.api.utility.Version;
|
||||
import com.djrapitops.plugin.api.utility.log.DebugLog;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.settings.ColorScheme;
|
||||
@ -47,6 +44,9 @@ import main.java.com.djrapitops.plan.settings.theme.Theme;
|
||||
import main.java.com.djrapitops.plan.systems.Systems;
|
||||
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
||||
import main.java.com.djrapitops.plan.systems.cache.GeolocationCache;
|
||||
import main.java.com.djrapitops.plan.systems.file.FileSystem;
|
||||
import main.java.com.djrapitops.plan.systems.file.config.ConfigSystem;
|
||||
import main.java.com.djrapitops.plan.systems.file.database.DBSystem;
|
||||
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.info.ImporterManager;
|
||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||
@ -55,10 +55,8 @@ import main.java.com.djrapitops.plan.systems.listeners.*;
|
||||
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
||||
import main.java.com.djrapitops.plan.systems.processing.importing.importers.OfflinePlayerImporter;
|
||||
import main.java.com.djrapitops.plan.systems.queue.ProcessingQueue;
|
||||
import main.java.com.djrapitops.plan.systems.file.FileSystem;
|
||||
import main.java.com.djrapitops.plan.systems.file.config.ConfigSystem;
|
||||
import main.java.com.djrapitops.plan.systems.file.database.DBSystem;
|
||||
import main.java.com.djrapitops.plan.systems.tasks.TPSCountTimer;
|
||||
import main.java.com.djrapitops.plan.systems.update.VersionCheckSystem;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.WebServer;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.WebServerSystem;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.pagecache.PageCache;
|
||||
@ -85,8 +83,6 @@ public class Plan extends BukkitPlugin implements IPlan {
|
||||
|
||||
private API api;
|
||||
|
||||
private Theme theme;
|
||||
|
||||
private Systems systems;
|
||||
|
||||
private ProcessingQueue processingQueue;
|
||||
@ -147,21 +143,7 @@ public class Plan extends BukkitPlugin implements IPlan {
|
||||
|
||||
Log.setDebugMode(Settings.DEBUG.toString());
|
||||
|
||||
String currentVersion = getVersion();
|
||||
String githubVersionUrl = "https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml";
|
||||
String spigotUrl = "https://www.spigotmc.org/resources/plan-player-analytics.32536/";
|
||||
try {
|
||||
if (Version.checkVersion(currentVersion, githubVersionUrl) || Version.checkVersion(currentVersion, spigotUrl)) {
|
||||
Log.infoColor("§a----------------------------------------");
|
||||
Log.infoColor("§aNew version is available at https://www.spigotmc.org/resources/plan-player-analytics.32536/");
|
||||
Log.infoColor("§a----------------------------------------");
|
||||
NotificationCenter.addNotification(Priority.HIGH, "New Version is available at https://www.spigotmc.org/resources/plan-player-analytics.32536/");
|
||||
} else {
|
||||
Log.info("You're using the latest version.");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.error("Failed to check newest version number");
|
||||
}
|
||||
VersionCheckSystem.getInstance().init();
|
||||
|
||||
Benchmark.start("Enable");
|
||||
|
||||
@ -175,7 +157,7 @@ public class Plan extends BukkitPlugin implements IPlan {
|
||||
|
||||
new Locale().loadLocale();
|
||||
|
||||
theme = new Theme();
|
||||
Theme.getInstance().init();
|
||||
|
||||
Benchmark.start("Reading server variables");
|
||||
serverVariableHolder = new ServerVariableHolder(getServer());
|
||||
@ -518,11 +500,6 @@ public class Plan extends BukkitPlugin implements IPlan {
|
||||
return api;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Theme getTheme() {
|
||||
return theme;
|
||||
}
|
||||
|
||||
public Systems getSystems() {
|
||||
return systems;
|
||||
}
|
||||
|
@ -7,11 +7,8 @@ package main.java.com.djrapitops.plan;
|
||||
import com.djrapitops.plugin.BungeePlugin;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.Benchmark;
|
||||
import com.djrapitops.plugin.api.Priority;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.api.config.Config;
|
||||
import com.djrapitops.plugin.api.systems.NotificationCenter;
|
||||
import com.djrapitops.plugin.api.utility.Version;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.settings.ColorScheme;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
@ -24,22 +21,22 @@ import main.java.com.djrapitops.plan.settings.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.settings.locale.Msg;
|
||||
import main.java.com.djrapitops.plan.settings.theme.Theme;
|
||||
import main.java.com.djrapitops.plan.systems.Systems;
|
||||
import main.java.com.djrapitops.plan.systems.file.FileSystem;
|
||||
import main.java.com.djrapitops.plan.systems.file.config.ConfigSystem;
|
||||
import main.java.com.djrapitops.plan.systems.file.database.DBSystem;
|
||||
import main.java.com.djrapitops.plan.systems.info.BungeeInformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.info.server.BungeeServerInfoManager;
|
||||
import main.java.com.djrapitops.plan.systems.listeners.BungeePlayerListener;
|
||||
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
||||
import main.java.com.djrapitops.plan.systems.queue.ProcessingQueue;
|
||||
import main.java.com.djrapitops.plan.systems.file.FileSystem;
|
||||
import main.java.com.djrapitops.plan.systems.file.config.ConfigSystem;
|
||||
import main.java.com.djrapitops.plan.systems.file.database.DBSystem;
|
||||
import main.java.com.djrapitops.plan.systems.tasks.TPSCountTimer;
|
||||
import main.java.com.djrapitops.plan.systems.update.VersionCheckSystem;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.WebServer;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.WebServerSystem;
|
||||
import main.java.com.djrapitops.plan.utilities.file.export.HtmlExport;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -50,8 +47,6 @@ import java.util.UUID;
|
||||
*/
|
||||
public class PlanBungee extends BungeePlugin implements IPlan {
|
||||
|
||||
private Theme theme;
|
||||
|
||||
private Systems systems;
|
||||
|
||||
private BungeeServerInfoManager serverInfoManager;
|
||||
@ -70,26 +65,13 @@ public class PlanBungee extends BungeePlugin implements IPlan {
|
||||
|
||||
Log.setDebugMode(Settings.DEBUG.toString());
|
||||
|
||||
String currentVersion = getVersion();
|
||||
String githubVersionUrl = "https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml";
|
||||
String spigotUrl = "https://www.spigotmc.org/resources/plan-player-analytics.32536/";
|
||||
try {
|
||||
if (Version.checkVersion(currentVersion, githubVersionUrl) || Version.checkVersion(currentVersion, spigotUrl)) {
|
||||
Log.infoColor("§a----------------------------------------");
|
||||
Log.infoColor("§aNew version is available at https://www.spigotmc.org/resources/plan-player-analytics.32536/");
|
||||
Log.infoColor("§a----------------------------------------");
|
||||
NotificationCenter.addNotification(Priority.HIGH, "New Version is available at https://www.spigotmc.org/resources/plan-player-analytics.32536/");
|
||||
} else {
|
||||
Log.info("You're using the latest version.");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.error("Failed to check newest version number");
|
||||
}
|
||||
VersionCheckSystem.getInstance().init();
|
||||
|
||||
variableHolder = new ServerVariableHolder(getProxy());
|
||||
|
||||
new Locale().loadLocale();
|
||||
|
||||
theme = new Theme();
|
||||
Theme.getInstance().init();
|
||||
|
||||
DBSystem.getInstance().init();
|
||||
|
||||
@ -239,11 +221,6 @@ public class PlanBungee extends BungeePlugin implements IPlan {
|
||||
return serverInfoManager.getServerUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Theme getTheme() {
|
||||
return theme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Systems getSystems() {
|
||||
return systems;
|
||||
|
@ -9,7 +9,6 @@ import com.djrapitops.plugin.api.config.Config;
|
||||
import com.djrapitops.plugin.settings.ColorScheme;
|
||||
import main.java.com.djrapitops.plan.ServerVariableHolder;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.settings.theme.Theme;
|
||||
import main.java.com.djrapitops.plan.systems.Systems;
|
||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
||||
@ -48,7 +47,5 @@ public interface IPlan extends IPlugin {
|
||||
|
||||
ColorScheme getColorScheme();
|
||||
|
||||
Theme getTheme();
|
||||
|
||||
Systems getSystems();
|
||||
}
|
@ -9,7 +9,8 @@ import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException;
|
||||
import main.java.com.djrapitops.plan.settings.Settings;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.systems.SubSystem;
|
||||
import main.java.com.djrapitops.plan.systems.Systems;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@ -21,11 +22,16 @@ import java.util.List;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class Theme {
|
||||
public class Theme implements SubSystem {
|
||||
|
||||
private final ThemeConfig config;
|
||||
private ThemeConfig config;
|
||||
|
||||
public Theme() throws PlanEnableException {
|
||||
public static Theme getInstance() {
|
||||
return Systems.getInstance().getThemeSystem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws PlanEnableException {
|
||||
String themeName = Settings.THEME_BASE.toString();
|
||||
try {
|
||||
config = new ThemeConfig(themeName);
|
||||
@ -34,6 +40,11 @@ public class Theme {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
|
||||
}
|
||||
|
||||
public String getColor(ThemeVal variable) {
|
||||
String path = variable.getThemePath();
|
||||
try {
|
||||
@ -83,10 +94,10 @@ public class Theme {
|
||||
}
|
||||
|
||||
public static String getValue(ThemeVal variable) {
|
||||
return MiscUtils.getIPlan().getTheme().getThemeValue(variable);
|
||||
return getInstance().getThemeValue(variable);
|
||||
}
|
||||
|
||||
public static String replaceColors(String resourceString) {
|
||||
return MiscUtils.getIPlan().getTheme().replaceThemeColors(resourceString);
|
||||
return getInstance().replaceThemeColors(resourceString);
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ package main.java.com.djrapitops.plan.systems;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.PlanBungee;
|
||||
import main.java.com.djrapitops.plan.settings.theme.Theme;
|
||||
import main.java.com.djrapitops.plan.systems.file.FileSystem;
|
||||
import main.java.com.djrapitops.plan.systems.file.config.ConfigSystem;
|
||||
import main.java.com.djrapitops.plan.systems.file.config.PlanBungeeConfigSystem;
|
||||
@ -14,6 +15,7 @@ import main.java.com.djrapitops.plan.systems.file.config.PlanConfigSystem;
|
||||
import main.java.com.djrapitops.plan.systems.file.database.DBSystem;
|
||||
import main.java.com.djrapitops.plan.systems.file.database.PlanBungeeDBSystem;
|
||||
import main.java.com.djrapitops.plan.systems.file.database.PlanDBSystem;
|
||||
import main.java.com.djrapitops.plan.systems.update.VersionCheckSystem;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.WebServerSystem;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
@ -28,9 +30,12 @@ public class Systems {
|
||||
private FileSystem fileSystem;
|
||||
private ConfigSystem configSystem;
|
||||
private DBSystem databaseSystem;
|
||||
private Theme themeSystem;
|
||||
|
||||
private WebServerSystem webServerSystem;
|
||||
|
||||
private VersionCheckSystem versionCheckSystem;
|
||||
|
||||
/**
|
||||
* Constructor for Bukkit version.
|
||||
*
|
||||
@ -40,8 +45,10 @@ public class Systems {
|
||||
fileSystem = new FileSystem(plugin);
|
||||
configSystem = new PlanConfigSystem();
|
||||
databaseSystem = new PlanDBSystem();
|
||||
versionCheckSystem = new VersionCheckSystem(plugin.getVersion());
|
||||
|
||||
webServerSystem = new WebServerSystem(plugin);
|
||||
themeSystem = new Theme();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,8 +60,10 @@ public class Systems {
|
||||
fileSystem = new FileSystem(plugin);
|
||||
configSystem = new PlanBungeeConfigSystem();
|
||||
databaseSystem = new PlanBungeeDBSystem();
|
||||
versionCheckSystem = new VersionCheckSystem(plugin.getVersion());
|
||||
|
||||
webServerSystem = new WebServerSystem(plugin);
|
||||
themeSystem = new Theme();
|
||||
}
|
||||
|
||||
private SubSystem[] getSubSystems() {
|
||||
@ -97,4 +106,12 @@ public class Systems {
|
||||
public WebServerSystem getWebServerSystem() {
|
||||
return webServerSystem;
|
||||
}
|
||||
|
||||
public VersionCheckSystem getVersionCheckSystem() {
|
||||
return versionCheckSystem;
|
||||
}
|
||||
|
||||
public Theme getThemeSystem() {
|
||||
return themeSystem;
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.systems.update;
|
||||
|
||||
import com.djrapitops.plugin.api.Priority;
|
||||
import com.djrapitops.plugin.api.systems.NotificationCenter;
|
||||
import com.djrapitops.plugin.api.utility.Version;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException;
|
||||
import main.java.com.djrapitops.plan.systems.SubSystem;
|
||||
import main.java.com.djrapitops.plan.systems.Systems;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class VersionCheckSystem implements SubSystem {
|
||||
|
||||
private final String currentVersion;
|
||||
private boolean newVersionAvailable = false;
|
||||
|
||||
public VersionCheckSystem(String currentVersion) {
|
||||
this.currentVersion = currentVersion;
|
||||
}
|
||||
|
||||
public static VersionCheckSystem getInstance() {
|
||||
return Systems.getInstance().getVersionCheckSystem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws PlanEnableException {
|
||||
checkForNewVersion();
|
||||
}
|
||||
|
||||
private void checkForNewVersion() {
|
||||
String githubVersionUrl = "https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml";
|
||||
String spigotUrl = "https://www.spigotmc.org/resources/plan-player-analytics.32536/";
|
||||
try {
|
||||
newVersionAvailable = Version.checkVersion(currentVersion, githubVersionUrl)
|
||||
|| Version.checkVersion(currentVersion, spigotUrl);
|
||||
if (newVersionAvailable) {
|
||||
String newVersionNotification = "New Version is available at " + spigotUrl;
|
||||
Log.infoColor("§a----------------------------------------");
|
||||
Log.infoColor("§a"+newVersionNotification);
|
||||
Log.infoColor("§a----------------------------------------");
|
||||
NotificationCenter.addNotification(Priority.HIGH, newVersionNotification);
|
||||
} else {
|
||||
Log.info("You're using the latest version.");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.error("Failed to check newest version number");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
/* Does not need to be closed */
|
||||
}
|
||||
|
||||
public static boolean isNewVersionAvailable() {
|
||||
return getInstance().newVersionAvailable;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user