mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-05 10:20:23 +01:00
VersionCheckSystem locale stuff
This commit is contained in:
parent
5da4b043c4
commit
2d3ca08dfe
@ -39,7 +39,7 @@ public class BukkitSystem extends PlanSystem implements ServerSystem {
|
||||
|
||||
Supplier<Locale> localeSupplier = () -> getLocaleSystem().getLocale();
|
||||
|
||||
versionCheckSystem = new VersionCheckSystem(plugin.getVersion());
|
||||
versionCheckSystem = new VersionCheckSystem(plugin.getVersion(), localeSupplier);
|
||||
fileSystem = new FileSystem(plugin);
|
||||
configSystem = new ServerConfigSystem();
|
||||
databaseSystem = new ServerDBSystem(localeSupplier);
|
||||
|
@ -15,6 +15,7 @@ import com.djrapitops.plan.system.file.FileSystem;
|
||||
import com.djrapitops.plan.system.info.BungeeInfoSystem;
|
||||
import com.djrapitops.plan.system.info.server.BungeeServerInfo;
|
||||
import com.djrapitops.plan.system.listeners.BungeeListenerSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.PlanErrorManager;
|
||||
import com.djrapitops.plan.system.settings.config.BungeeConfigSystem;
|
||||
import com.djrapitops.plan.system.settings.network.NetworkSettings;
|
||||
@ -22,6 +23,8 @@ import com.djrapitops.plan.system.tasks.BungeeTaskSystem;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Represents PlanSystem for PlanBungee.
|
||||
*
|
||||
@ -34,10 +37,12 @@ public class BungeeSystem extends PlanSystem {
|
||||
|
||||
Log.setErrorManager(new PlanErrorManager());
|
||||
|
||||
versionCheckSystem = new VersionCheckSystem(plugin.getVersion());
|
||||
Supplier<Locale> localeSupplier = () -> getLocaleSystem().getLocale();
|
||||
|
||||
versionCheckSystem = new VersionCheckSystem(plugin.getVersion(), localeSupplier);
|
||||
fileSystem = new FileSystem(plugin);
|
||||
configSystem = new BungeeConfigSystem();
|
||||
databaseSystem = new BungeeDBSystem(() -> getLocaleSystem().getLocale());
|
||||
databaseSystem = new BungeeDBSystem(localeSupplier);
|
||||
cacheSystem = new BungeeCacheSystem(this);
|
||||
listenerSystem = new BungeeListenerSystem(plugin);
|
||||
taskSystem = new BungeeTaskSystem(plugin);
|
||||
|
@ -39,7 +39,7 @@ public class SpongeSystem extends PlanSystem implements ServerSystem {
|
||||
|
||||
Log.setErrorManager(new PlanErrorManager());
|
||||
|
||||
versionCheckSystem = new VersionCheckSystem(plugin.getVersion());
|
||||
versionCheckSystem = new VersionCheckSystem(plugin.getVersion(), localeSupplier);
|
||||
fileSystem = new FileSystem(plugin);
|
||||
configSystem = new SpongeConfigSystem();
|
||||
databaseSystem = new ServerDBSystem(localeSupplier);
|
||||
|
@ -29,7 +29,14 @@ public enum PluginLang implements Lang {
|
||||
WEB_SERVER_NOTIFY_HTTP_USER_AUTH("WebServer - Notify HTTP User Auth", "WebServer: User Authorization Disabled! (Not secure over HTTP)"),
|
||||
|
||||
DISABLED("Disable", "Player Analytics Disabled."),
|
||||
DISABLED_WEB_SERVER("Disable - WebServer", "Webserver has been disabled.");
|
||||
DISABLED_WEB_SERVER("Disable - WebServer", "Webserver has been disabled."),
|
||||
|
||||
VERSION_NEWEST("Version - Latest", "You're using the latest version."),
|
||||
VERSION_AVAILABLE("Version - New", "New Release (${0}) is available ${1}"),
|
||||
VERSION_AVAILABLE_SPIGOT("Version - New (old)", "New Version is available at ${0}"),
|
||||
VERSION_AVAILABLE_DEV("Version - DEV", " This is a DEV release."),
|
||||
VERSION_FAIL_READ_VERSIONS("Version FAIL - Read versions.txt", "Version information could not be loaded from Github/versions.txt"),
|
||||
VERSION_FAIL_READ_OLD("Version FAIL - Read info (old)", "Failed to check newest version number");
|
||||
|
||||
private final String identifier;
|
||||
private final String defaultValue;
|
||||
|
@ -6,6 +6,8 @@ package com.djrapitops.plan.system.update;
|
||||
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plugin.api.Priority;
|
||||
import com.djrapitops.plugin.api.systems.NotificationCenter;
|
||||
@ -15,6 +17,7 @@ import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -25,10 +28,12 @@ import java.util.stream.Collectors;
|
||||
public class VersionCheckSystem implements SubSystem {
|
||||
|
||||
private final String currentVersion;
|
||||
private final Supplier<Locale> locale;
|
||||
private VersionInfo newVersionAvailable;
|
||||
|
||||
public VersionCheckSystem(String currentVersion) {
|
||||
public VersionCheckSystem(String currentVersion, Supplier<Locale> locale) {
|
||||
this.currentVersion = currentVersion;
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public static VersionCheckSystem getInstance() {
|
||||
@ -56,20 +61,21 @@ public class VersionCheckSystem implements SubSystem {
|
||||
VersionInfo newestVersion = versions.get(0);
|
||||
if (Version.isNewVersionAvailable(new Version(currentVersion), newestVersion.getVersion())) {
|
||||
newVersionAvailable = newestVersion;
|
||||
String notification =
|
||||
"New Release (" + newestVersion.getVersion().toString() + ") is available " +
|
||||
// "and can be updated to using update subcommand." +
|
||||
newestVersion.getChangeLogUrl() +
|
||||
(newestVersion.isRelease() ? "" : " This is a DEV release.");
|
||||
String notification = locale.get().getString(
|
||||
PluginLang.VERSION_AVAILABLE,
|
||||
newestVersion.getVersion().toString(),
|
||||
newestVersion.getChangeLogUrl()
|
||||
) + (newestVersion.isRelease() ? "" : locale.get().getString(PluginLang.VERSION_AVAILABLE_DEV));
|
||||
Log.infoColor("§a----------------------------------------");
|
||||
Log.infoColor("§a" + notification);
|
||||
Log.infoColor("§a----------------------------------------");
|
||||
NotificationCenter.getNotifications().clear();
|
||||
NotificationCenter.addNotification(newestVersion.isRelease() ? Priority.HIGH : Priority.MEDIUM, notification);
|
||||
} else {
|
||||
Log.info("You're using the latest version.");
|
||||
Log.info(locale.get().getString(PluginLang.VERSION_NEWEST));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.error("Version information could not be loaded from Github/versions.txt");
|
||||
Log.error(locale.get().getString(PluginLang.VERSION_FAIL_READ_VERSIONS));
|
||||
}
|
||||
} else {
|
||||
checkForNewVersion();
|
||||
@ -89,16 +95,16 @@ public class VersionCheckSystem implements SubSystem {
|
||||
}
|
||||
}
|
||||
if (newVersionAvailable) {
|
||||
String newVersionNotification = "New Version is available at " + spigotUrl;
|
||||
String newVersionNotification = locale.get().getString(PluginLang.VERSION_AVAILABLE_SPIGOT, 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.");
|
||||
Log.info(locale.get().getString(PluginLang.VERSION_NEWEST));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.error("Failed to check newest version number");
|
||||
Log.error(locale.get().getString(PluginLang.VERSION_FAIL_READ_OLD));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user