From ecd4c002c822fb91264385f37016b0f39ed042f3 Mon Sep 17 00:00:00 2001 From: Julian Date: Thu, 30 Mar 2023 13:41:01 +0200 Subject: [PATCH] Add environment variable to block individual ecloud expansions. This commit adds the environment variable "PAPI_BLOCKED_EXPANSIONS" which can contain a case insensitive, comma separated list of blocked expansions. Expansions on this list can no longer be downloaded using commands. --- .../impl/cloud/CommandECloudDownload.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 5717447..abe04f9 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 @@ -20,6 +20,7 @@ package me.clip.placeholderapi.commands.impl.cloud; +import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.stream.Stream; @@ -37,6 +38,16 @@ 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, @@ -47,6 +58,12 @@ 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) {