From a3a50c1961a848bfb3069804c15dcdaa59a44e06 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 4 May 2019 23:05:11 +0200 Subject: [PATCH] Made the GitHub connection interval be at least 15 minutes --- src/main/java/world/bentobox/bentobox/Settings.java | 4 ++-- .../java/world/bentobox/bentobox/managers/WebManager.java | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/Settings.java b/src/main/java/world/bentobox/bentobox/Settings.java index addc320be..3794ecddd 100644 --- a/src/main/java/world/bentobox/bentobox/Settings.java +++ b/src/main/java/world/bentobox/bentobox/Settings.java @@ -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; diff --git a/src/main/java/world/bentobox/bentobox/managers/WebManager.java b/src/main/java/world/bentobox/bentobox/managers/WebManager.java index e99b8a34b..25a17cec5 100644 --- a/src/main/java/world/bentobox/bentobox/managers/WebManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/WebManager.java @@ -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); } }