Add v1.4.0 changes to legacy #9

Merged
Jack1424 merged 12 commits from main into legacy 2024-07-23 18:10:08 -04:00
6 changed files with 111 additions and 49 deletions
Showing only changes of commit 20bf2d74fc - Show all commits

View File

@@ -19,7 +19,7 @@ public class ConfigManager {
private final FileConfiguration configFile;
private TimeZone timeZone;
private boolean debug, timeEnabled, weatherEnabled, blockTimeSetCommand, blockWeatherCommand, disableBedsAtNight, disableBedsDuringThunder;
private long timeSyncInterval, weatherSyncInterval;
private long timeSyncInterval, weatherSyncInterval, updateCheckInterval;
private String sunriseSunset, sunriseSunsetLatitude, sunriseSunsetLongitude, apiKey, weatherLatitude, weatherLongitude, disableBedsAtNightMessage, disableBedsDuringThunderMessage, sunriseCustomTime, sunsetCustomTime;
public ConfigManager(RealTimeWeather rtw) {
@@ -71,6 +71,8 @@ public class ConfigManager {
setWeatherEnabled(false);
}
setUpdateCheckInterval(configFile.getLong("updateCheckInterval"));
}
public boolean debugEnabled() {
@@ -308,4 +310,13 @@ public class ConfigManager {
weatherLongitude = value;
rtw.debug("Longitude set to " + value);
}
public void setUpdateCheckInterval(long value) {
updateCheckInterval = value;
rtw.debug("updateCheckInterval set to " + value);
}
public long getUpdateCheckInterval() {
return updateCheckInterval;
}
}

View File

@@ -43,6 +43,15 @@ public final class RealTimeWeather extends JavaPlugin {
metrics.addCustomChart(new SimplePie("time_sync_enabled", () -> String.valueOf(config.isTimeEnabled())));
logger.info("Started!");
logger.info("Checking for updates...");
logger.info(getUpdateCheck());
long updateCheckInterval = config.getUpdateCheckInterval();
if (config.getUpdateCheckInterval() > 0)
getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
logger.info(getUpdateCheck());
}, updateCheckInterval, updateCheckInterval);
}
@Override
@@ -168,6 +177,23 @@ public final class RealTimeWeather extends JavaPlugin {
}
}
public String getUpdateCheck() {
String currentVersion = this.getDescription().getVersion();
String latestVersion;
try {
debug("Getting latest version...");
latestVersion = RequestFunctions.getLatestVersion();
} catch (Exception exception) {
debug(exception.getMessage());
return "There was an error getting the latest version";
}
if (currentVersion.equals(latestVersion)) {
return String.format("RealTimeWeather (v%s) is up to date!", currentVersion);
} else
return String.format("RealTimeWeather (v%s) is outdated! v%s is the latest version.", currentVersion, latestVersion);
}
public ConfigManager getConfigurator() {
return config;
}

View File

@@ -1,4 +1,4 @@
# RealTimeWeather Configuration File (v1.3.0)
# RealTimeWeather Configuration File (v1.4.0)
# You can find detailed instructions at: https://github.com/Jack1424/RealTimeWeather/wiki#editing-the-configuration-file
################################# TIME SYNC SETTINGS #################################################################
@@ -72,6 +72,12 @@ WeatherLongitude: '0'
# #
######################################################################################################################
# By default, RealTimeWeather will check if an update is available every 24 hours (1734000 ticks)
# You can change the interval here (or set to 0 to disable update checks)
# If this is disabled, RealTimeWeather will still check for updates on startup
# You can find a handy tick calculator here: https://mapmaking.fr/tick/
updateCheckInterval: 1734000
# Set to true for various console messages when time and weather sync are executed
# This is useful if the plugin is not working, and you want to find out what's wrong
# This will also provide error messages even when an error is caught and managed by RTM