feat: fetch all expansions (#952)

This commit is contained in:
Gabriel Dumitru 2023-06-21 21:26:52 +03:00 committed by GitHub
parent a497e05e55
commit f91b4e3752
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 12 deletions

View File

@ -72,6 +72,11 @@ public final class CommandECloudDownload extends PlaceholderCommand {
return; 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; final CloudExpansion.Version version;
if (params.size() < 2) { if (params.size() < 2) {
version = expansion.getVersion(expansion.getLatestVersion()); version = expansion.getVersion(expansion.getLatestVersion());
@ -103,9 +108,7 @@ public final class CommandECloudDownload extends PlaceholderCommand {
.getVersion() + "] &ato file: &f" + file.getName(), .getVersion() + "] &ato file: &f" + file.getName(),
"&aMake sure to type &f/papi reload &ato enable your new expansion!"); "&aMake sure to type &f/papi reload &ato enable your new expansion!");
plugin.getCloudExpansionManager().clean(); plugin.getCloudExpansionManager().load();
plugin.getCloudExpansionManager()
.fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
}); });
} }

View File

@ -38,9 +38,7 @@ public final class CommandECloudRefresh extends PlaceholderCommand {
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
@NotNull final CommandSender sender, @NotNull final String alias, @NotNull final CommandSender sender, @NotNull final String alias,
@NotNull @Unmodifiable final List<String> params) { @NotNull @Unmodifiable final List<String> params) {
plugin.getCloudExpansionManager().clean(); plugin.getCloudExpansionManager().load();
plugin.getCloudExpansionManager()
.fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
Msg.msg(sender, Msg.msg(sender,
"&aThe eCloud manager has been refreshed!"); "&aThe eCloud manager has been refreshed!");

View File

@ -100,7 +100,7 @@ public final class CloudExpansionManager {
public void load() { public void load() {
clean(); clean();
fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions()); fetch();
} }
public void kill() { public void kill() {
@ -170,7 +170,7 @@ public final class CloudExpansionManager {
await.clear(); await.clear();
} }
public void fetch(final boolean allowUnverified) { public void fetch() {
plugin.getLogger().info("Fetching available expansion information..."); plugin.getLogger().info("Fetching available expansion information...");
ASYNC_EXECUTOR.submit( ASYNC_EXECUTOR.submit(
@ -190,9 +190,6 @@ public final class CloudExpansionManager {
|| expansion.getVersion(expansion.getLatestVersion()) == null) { || expansion.getVersion(expansion.getLatestVersion()) == null) {
toRemove.add(entry.getKey()); toRemove.add(entry.getKey());
} }
if (!allowUnverified && !expansion.isVerified()) {
toRemove.add(entry.getKey());
}
} }
for (String name : toRemove) { for (String name : toRemove) {
@ -203,7 +200,7 @@ public final class CloudExpansionManager {
plugin.getLogger().log(Level.WARNING, "Failed to download expansion information", e); 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 plugin
.getServer() .getServer()
.getScheduler() .getScheduler()