Compare commits

..
2 Commits
Author SHA1 Message Date
PiggyPiglet 27ec162393 Merge pull request #1253 from PlaceholderAPI/t3/enforce-cloud-update-verification
Enforce eCloud restrictions on updates
2026-10-24 16:35:25 +08:00
darbyjack 12561adfad fix: enforce eCloud download restrictions 2026-10-24 03:06:38 +00:00
2 changed files with 17 additions and 22 deletions

No files matched your search

@@ -20,7 +20,6 @@
package me.clip.placeholderapi.commands.impl.cloud;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
@@ -39,16 +38,6 @@ public final class CommandECloudDownload extends PlaceholderCommand {
super("download");
}
private boolean isBlockedExpansion(String name) {
String env = System.getenv("PAPI_BLOCKED_EXPANSIONS");
if (env == null) {
return false;
}
return Arrays.stream(env.split(","))
.anyMatch(s -> s.equalsIgnoreCase(name));
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
@NotNull final CommandSender sender, @NotNull final String alias,
@@ -59,12 +48,6 @@ public final class CommandECloudDownload extends PlaceholderCommand {
return;
}
if (isBlockedExpansion(params.get(0))) {
Msg.msg(sender,
"&cThis expansion can't be downloaded.");
return;
}
final CloudExpansion expansion = plugin.getCloudExpansionManager()
.findCloudExpansionByName(params.get(0)).orElse(null);
if (expansion == null) {
@@ -91,11 +74,6 @@ public final class CommandECloudDownload extends PlaceholderCommand {
}
}
if (!version.isVerified()) {
Msg.msg(sender, "&cThe expansion '&f" + params.get(0) + "&c' is not verified and can only be downloaded manually from &fhttps://ecloud.placeholderapi.com");
return;
}
plugin.getCloudExpansionManager().downloadExpansion(expansion, version)
.whenComplete((file, exception) -> {
if (exception != null) {
@@ -33,6 +33,7 @@ import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -274,6 +275,16 @@ public final class CloudExpansionManager {
@NotNull
public CompletableFuture<File> downloadExpansion(@NotNull final CloudExpansion expansion,
@NotNull final CloudExpansion.Version version) {
final String blockedExpansions = System.getenv("PAPI_BLOCKED_EXPANSIONS");
if (blockedExpansions != null && Arrays.stream(blockedExpansions.split(","))
.anyMatch(name -> name.equalsIgnoreCase(expansion.getName()))) {
return failedDownload("This expansion can't be downloaded.");
}
if (!version.isVerified()) {
return failedDownload("The expansion is not verified and can only be downloaded manually from https://ecloud.placeholderapi.com");
}
final CompletableFuture<File> previous = await.get(toIndexName(expansion));
if (previous != null) {
return previous;
@@ -309,4 +320,10 @@ public final class CloudExpansionManager {
return download;
}
private CompletableFuture<File> failedDownload(String message) {
final CompletableFuture<File> failed = new CompletableFuture<>();
failed.completeExceptionally(new IllegalArgumentException(message));
return failed;
}
}