[New] Implemented update check setting

Setting: Plugin.Check-for-updates

Affected issues: #751
This commit is contained in:
Rsl1122 2018-10-14 21:41:16 +03:00
parent 0b7198df07
commit 6a8f93be89
4 changed files with 9 additions and 2 deletions

View File

@ -31,6 +31,7 @@ public enum Settings implements Setting {
DISPLAY_GAPS_IN_GRAPH_DATA("Customization.Display.GapsInGraphData"), DISPLAY_GAPS_IN_GRAPH_DATA("Customization.Display.GapsInGraphData"),
DATA_GEOLOCATIONS("Data.Geolocations"), DATA_GEOLOCATIONS("Data.Geolocations"),
NOTIFY_ABOUT_DEV_RELEASES("Plugin.Notify-About-DEV-Releases"), NOTIFY_ABOUT_DEV_RELEASES("Plugin.Notify-About-DEV-Releases"),
CHECK_FOR_UPDATES("Plugin.Check-for-updates"),
// Integer // Integer
WEBSERVER_PORT("WebServer.Port"), WEBSERVER_PORT("WebServer.Port"),

View File

@ -18,6 +18,7 @@ import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -54,6 +55,9 @@ public class VersionCheckSystem implements SubSystem {
@Override @Override
public void enable() { public void enable() {
if (config.isFalse(Settings.CHECK_FOR_UPDATES)) {
return;
}
try { try {
List<VersionInfo> versions = VersionInfoLoader.load(); List<VersionInfo> versions = VersionInfoLoader.load();
if (config.isFalse(Settings.NOTIFY_ABOUT_DEV_RELEASES)) { if (config.isFalse(Settings.NOTIFY_ABOUT_DEV_RELEASES)) {
@ -83,7 +87,7 @@ public class VersionCheckSystem implements SubSystem {
/* Does not need to be closed */ /* Does not need to be closed */
} }
public VersionInfo getNewVersionAvailable() { public Optional<VersionInfo> getNewVersionAvailable() {
return newVersionAvailable; return Optional.ofNullable(newVersionAvailable);
} }
} }

View File

@ -12,6 +12,7 @@ Network:
Plugin: Plugin:
Debug: 'false' Debug: 'false'
Locale: default Locale: default
Check-for-updates: true
Notify-About-DEV-Releases: false Notify-About-DEV-Releases: false
KeepLogsForXDays: 7 KeepLogsForXDays: 7

View File

@ -17,6 +17,7 @@ Plugin:
Bungee-Override: Bungee-Override:
StandaloneMode: false StandaloneMode: false
CopyBungeeConfig: true CopyBungeeConfig: true
Check-for-updates: true
Notify-About-DEV-Releases: false Notify-About-DEV-Releases: false
KeepLogsForXDays: 7 KeepLogsForXDays: 7