feat: fetch all expansions

and display a different message if the expansion that the player is trying to download is not verified and `cloud_allow_unverified_expansions` is false
This commit is contained in:
Gabriel Dumitru 2023-03-24 17:03:12 +02:00
parent e862abe0b4
commit 87cb3eab01
No known key found for this signature in database
GPG Key ID: 4F14082F3710B7CE
3 changed files with 11 additions and 12 deletions

View File

@ -55,6 +55,12 @@ 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://api.extendedclip.com");
Msg.msg(sender, "&aTo allow the download of unverified expansions set &fcloud_allow_unverified_expansions: true &ain config.yml");
return;
}
final CloudExpansion.Version version;
if (params.size() < 2) {
version = expansion.getVersion(expansion.getLatestVersion());
@ -86,9 +92,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();
});
}

View File

@ -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<String> params) {
plugin.getCloudExpansionManager().clean();
plugin.getCloudExpansionManager()
.fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
plugin.getCloudExpansionManager().load();
Msg.msg(sender,
"&aThe eCloud manager has been refreshed!");

View File

@ -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()