Remove all references to GitHubWebAPI4Java and use lambda instead.

This commit is contained in:
BONNe 2019-09-02 19:24:30 +03:00 committed by BuildTools
parent b719b88bf1
commit 747c12f1a6
2 changed files with 11 additions and 32 deletions

12
pom.xml
View File

@ -165,12 +165,6 @@
<version>${vault.version}</version> <version>${vault.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Shaded APIs -->
<dependency>
<groupId>com.github.TheBusyBiscuit</groupId>
<artifactId>GitHubWebAPI4Java</artifactId>
<version>d5f5e0bbd8</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -265,12 +259,6 @@
<version>3.2.1</version> <version>3.2.1</version>
<configuration> <configuration>
<minimizeJar>true</minimizeJar> <minimizeJar>true</minimizeJar>
<relocations>
<relocation>
<pattern>io.github.TheBusyBiscuit.GitHubWebAPI4Java</pattern>
<shadedPattern>world.bentobox.bentobox.api.github</shadedPattern>
</relocation>
</relocations>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>

View File

@ -7,8 +7,6 @@ import org.bukkit.World;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import io.github.TheBusyBiscuit.GitHubWebAPI4Java.GitHubWebAPI;
import io.github.TheBusyBiscuit.GitHubWebAPI4Java.objects.repositories.GitHubRepository;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.api.user.User;
import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.ChallengesAddon;
@ -40,7 +38,7 @@ public class WebManager
// If below 0, it means we shouldn't run this as a repeating task. // If below 0, it means we shouldn't run this as a repeating task.
this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin,
() -> this.requestCatalogGitHubData(true), () -> this.requestCatalogGitHubData(true),
20L); 600L);
} }
else else
{ {
@ -48,7 +46,7 @@ public class WebManager
connectionInterval = Math.max(connectionInterval, 60 * 20 * 60L); connectionInterval = Math.max(connectionInterval, 60 * 20 * 60L);
this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin,
() -> this.requestCatalogGitHubData(true), () -> this.requestCatalogGitHubData(true),
20L, 600L,
connectionInterval); connectionInterval);
} }
} }
@ -61,21 +59,21 @@ public class WebManager
*/ */
public void requestCatalogGitHubData(boolean clearCache) public void requestCatalogGitHubData(boolean clearCache)
{ {
this.plugin.getWebManager().getGitHub().ifPresent(gh -> this.plugin.getWebManager().getGitHub().ifPresent(gitHubWebAPI ->
{ {
if (this.plugin.getSettings().isLogGithubDownloadData()) if (this.plugin.getSettings().isLogGithubDownloadData())
{ {
this.plugin.log("Downloading data from GitHub..."); this.plugin.log("Downloading data from GitHub...");
} }
GitHubRepository repo = new GitHubRepository(gh, "BentoBoxWorld/weblink");
String catalogContent = ""; String catalogContent = "";
// Downloading the data // Downloading the data
try try
{ {
catalogContent = repo.getContent("challenges/catalog.json").getContent().replaceAll("\\n", ""); catalogContent = gitHubWebAPI.getRepository("BentoBoxWorld", "weblink").
getContent("challenges/catalog.json").
getContent().replaceAll("\\n", "");
} }
catch (IllegalAccessException e) catch (IllegalAccessException e)
{ {
@ -125,26 +123,22 @@ public class WebManager
* @param entry Entry that contains information about requested object. * @param entry Entry that contains information about requested object.
* @return {@code true} if request was successful, {@code false} otherwise. * @return {@code true} if request was successful, {@code false} otherwise.
*/ */
public boolean requestEntryGitHubData(User user, World world, LibraryEntry entry) public void requestEntryGitHubData(User user, World world, LibraryEntry entry)
{ {
Optional<GitHubWebAPI> gitAPI = this.plugin.getWebManager().getGitHub(); this.plugin.getWebManager().getGitHub().ifPresent(gitHubWebAPI ->
if (gitAPI.isPresent())
{ {
if (this.plugin.getSettings().isLogGithubDownloadData()) if (this.plugin.getSettings().isLogGithubDownloadData())
{ {
this.plugin.log("Downloading data from GitHub..."); this.plugin.log("Downloading data from GitHub...");
} }
GitHubRepository repo = new GitHubRepository(gitAPI.get(), "BentoBoxWorld/weblink");
String challengeLibrary = ""; String challengeLibrary = "";
// Downloading the data // Downloading the data
try try
{ {
challengeLibrary = gitHubWebAPI.getRepository("BentoBoxWorld", "weblink").
challengeLibrary = repo.getContent("challenges/library/" + entry.getRepository() + ".json"). getContent("challenges/library/" + entry.getRepository() + ".json").
getContent(). getContent().
replaceAll("\\n", ""); replaceAll("\\n", "");
} }
@ -177,11 +171,8 @@ public class WebManager
if (!challengeLibrary.isEmpty()) if (!challengeLibrary.isEmpty())
{ {
this.addon.getImportManager().loadDownloadedChallenges(user, world, challengeLibrary); this.addon.getImportManager().loadDownloadedChallenges(user, world, challengeLibrary);
return true;
} }
} });
return false;
} }