Merge pull request #978 from JulianVennen/block-unverified-expansions

Add environment variable to override cloud_allowunverified_expansions
This commit is contained in:
PiggyPiglet 2023-09-21 17:38:54 +08:00 committed by GitHub
commit 5623a00f9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -48,6 +48,15 @@ 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) {
return env.equalsIgnoreCase("true");
}
return plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions();
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
@NotNull final CommandSender sender, @NotNull final String alias,
@ -72,7 +81,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;
}