mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-17 22:57:52 +01:00
Added 'web.github.download-data' in config
This commit is contained in:
parent
e041107df9
commit
1bdb919734
@ -169,6 +169,13 @@ public class Settings implements DataObject {
|
||||
@ConfigEntry(path = "web.metrics")
|
||||
private boolean metrics = true;
|
||||
|
||||
@ConfigComment("Toggle whether BentoBox can connect to GitHub to get data about updates and addons.")
|
||||
@ConfigComment("Disabling this will result in the deactivation of the update checker and of some other")
|
||||
@ConfigComment("features that rely on the data downloaded from the GitHub API.")
|
||||
@ConfigComment("It does not send any data.")
|
||||
@ConfigEntry(path = "web.github.download-data", since = "1.3.0")
|
||||
private boolean githubDownloadData = true;
|
||||
|
||||
//---------------------------------------------------------------------------------------/
|
||||
@ConfigComment("These settings should not be edited")
|
||||
private String uniqueId = "config";
|
||||
@ -445,4 +452,12 @@ public class Settings implements DataObject {
|
||||
public void setResetCooldownOnCreate(boolean resetCooldownOnCreate) {
|
||||
this.resetCooldownOnCreate = resetCooldownOnCreate;
|
||||
}
|
||||
|
||||
public boolean isGithubDownloadData() {
|
||||
return githubDownloadData;
|
||||
}
|
||||
|
||||
public void setGithubDownloadData(boolean githubDownloadData) {
|
||||
this.githubDownloadData = githubDownloadData;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
import world.bentobox.bentobox.api.github.GitHubConnector;
|
||||
@ -19,14 +20,16 @@ import world.bentobox.bentobox.api.github.GitHubConnector;
|
||||
public class WebManager {
|
||||
|
||||
private @NonNull BentoBox plugin;
|
||||
private @NonNull GitHubConnector bentoBoxGitHubConnector;
|
||||
private @Nullable GitHubConnector bentoBoxGitHubConnector;
|
||||
private @NonNull Map<@NonNull Addon, @NonNull GitHubConnector> gitHubConnectors = new LinkedHashMap<>();
|
||||
|
||||
public WebManager(@NonNull BentoBox plugin) {
|
||||
this.plugin = plugin;
|
||||
if (plugin.getSettings().isGithubDownloadData()) {
|
||||
this.bentoBoxGitHubConnector = new GitHubConnector("BentoBoxWorld/BentoBox");
|
||||
setupAddonsGitHubConnectors();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setups the {@code GitHubConnector} instances for each addons.
|
||||
@ -41,7 +44,9 @@ public class WebManager {
|
||||
* Connects all the {@link GitHubConnector} to GitHub to retrieve data.
|
||||
*/
|
||||
public void requestGitHubData() {
|
||||
if (plugin.getSettings().isGithubDownloadData()) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> bentoBoxGitHubConnector.connect());
|
||||
gitHubConnectors.values().forEach(gitHubConnector -> Bukkit.getScheduler().runTask(plugin, gitHubConnector::connect));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user