From f91b4e3752de1c476494df816170a1f9aef0fd76 Mon Sep 17 00:00:00 2001 From: Gabriel Dumitru Date: Wed, 21 Jun 2023 21:26:52 +0300 Subject: [PATCH] feat: fetch all expansions (#952) --- .../commands/impl/cloud/CommandECloudDownload.java | 9 ++++++--- .../commands/impl/cloud/CommandECloudRefresh.java | 4 +--- .../expansion/manager/CloudExpansionManager.java | 9 +++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudDownload.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudDownload.java index abe04f9..060d56c 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudDownload.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudDownload.java @@ -72,6 +72,11 @@ public final class CommandECloudDownload extends PlaceholderCommand { return; } + if (!expansion.isVerified() && !plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions()) { + Msg.msg(sender, "&cThe expansion '&f" + params.get(0) + "&c' is not verified and can only be downloaded manually from &fhttps://placeholderapi.com/ecloud"); + return; + } + final CloudExpansion.Version version; if (params.size() < 2) { version = expansion.getVersion(expansion.getLatestVersion()); @@ -103,9 +108,7 @@ public final class CommandECloudDownload extends PlaceholderCommand { .getVersion() + "] &ato file: &f" + file.getName(), "&aMake sure to type &f/papi reload &ato enable your new expansion!"); - plugin.getCloudExpansionManager().clean(); - plugin.getCloudExpansionManager() - .fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions()); + plugin.getCloudExpansionManager().load(); }); } diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudRefresh.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudRefresh.java index fb11086..e82b407 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudRefresh.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudRefresh.java @@ -38,9 +38,7 @@ public final class CommandECloudRefresh extends PlaceholderCommand { public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List params) { - plugin.getCloudExpansionManager().clean(); - plugin.getCloudExpansionManager() - .fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions()); + plugin.getCloudExpansionManager().load(); Msg.msg(sender, "&aThe eCloud manager has been refreshed!"); diff --git a/src/main/java/me/clip/placeholderapi/expansion/manager/CloudExpansionManager.java b/src/main/java/me/clip/placeholderapi/expansion/manager/CloudExpansionManager.java index 11d7cb3..19dc77c 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/CloudExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/CloudExpansionManager.java @@ -100,7 +100,7 @@ public final class CloudExpansionManager { public void load() { clean(); - fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions()); + fetch(); } public void kill() { @@ -170,7 +170,7 @@ public final class CloudExpansionManager { await.clear(); } - public void fetch(final boolean allowUnverified) { + public void fetch() { plugin.getLogger().info("Fetching available expansion information..."); ASYNC_EXECUTOR.submit( @@ -190,9 +190,6 @@ public final class CloudExpansionManager { || expansion.getVersion(expansion.getLatestVersion()) == null) { toRemove.add(entry.getKey()); } - if (!allowUnverified && !expansion.isVerified()) { - toRemove.add(entry.getKey()); - } } for (String name : toRemove) { @@ -203,7 +200,7 @@ public final class CloudExpansionManager { plugin.getLogger().log(Level.WARNING, "Failed to download expansion information", e); } - // loop thru what's left on the main thread + // loop through what's left on the main thread plugin .getServer() .getScheduler()