Made the GitHub connection interval be at least 15 minutes

This commit is contained in:
Florian CUNY 2019-05-04 23:05:11 +02:00
parent 2d94e4447a
commit a3a50c1961
2 changed files with 5 additions and 2 deletions

View File

@ -178,8 +178,8 @@ public class Settings implements DataObject {
@ConfigComment("Time in minutes between each connection to the GitHub API.")
@ConfigComment("This allows for up-to-the-minute information gathering.")
@ConfigComment("However, as the GitHub API data does not get updated instantly, it is recommended to keep")
@ConfigComment("this value greater than 15 minutes.")
@ConfigComment("However, as the GitHub API data does not get updated instantly,")
@ConfigComment("this value cannot be set less than 15 minutes.")
@ConfigComment("Setting this to 0 will make BentoBox download data only at startup.")
@ConfigEntry(path = "web.github.connection-interval", since = "1.5.0")
private int githubConnectionInterval = 60;

View File

@ -37,8 +37,11 @@ public class WebManager {
long connectionInterval = plugin.getSettings().getGithubConnectionInterval() * 20L * 60L;
if (connectionInterval <= 0) {
// If below 0, it means we shouldn't run this as a repeating task.
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, () -> requestGitHubData(true), 20L);
} else {
// Set connection interval to be at least 15 minutes.
connectionInterval = Math.min(connectionInterval, 15 * 20 * 60L);
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> requestGitHubData(true), 20L, connectionInterval);
}
}