[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"),
DATA_GEOLOCATIONS("Data.Geolocations"),
NOTIFY_ABOUT_DEV_RELEASES("Plugin.Notify-About-DEV-Releases"),
CHECK_FOR_UPDATES("Plugin.Check-for-updates"),
// Integer
WEBSERVER_PORT("WebServer.Port"),

View File

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

View File

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

View File

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