From 92a7d546644ba83e71de2733fd42499f9be7046c Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 23 Jun 2023 14:00:24 +0200 Subject: [PATCH] Add environment variable to override cloud_allowunverified_expansions This adds the environment variable PAPI_ALLOW_UNVERIFIED_EXPANSIONS. It allows overriding the option set in the config.yml. --- .../impl/cloud/CommandECloudDownload.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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 060d56c..2df77fb 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 @@ -48,6 +48,24 @@ public final class CommandECloudDownload extends PlaceholderCommand { .anyMatch(s -> s.equalsIgnoreCase(name)); } + private boolean areUnverifiedExpansionsAllowed(@NotNull final PlaceholderAPIPlugin plugin) { + String env = System.getenv("PAPI_ALLOW_UNVERIFIED_EXPANSIONS"); + if (env != null) { + switch (env.toLowerCase()) { + case "true": + case "yes": + case "1": + return true; + case "false": + case "no": + case "0": + return false; + } + } + + return plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions(); + } + @Override public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @@ -72,7 +90,7 @@ public final class CommandECloudDownload extends PlaceholderCommand { return; } - if (!expansion.isVerified() && !plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions()) { + if (!expansion.isVerified() && !this.areUnverifiedExpansionsAllowed(plugin)) { 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; }