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

View File

@ -48,6 +48,15 @@ public final class CommandECloudDownload extends PlaceholderCommand {
.anyMatch(s -> s.equalsIgnoreCase(name)); .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 @Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
@NotNull final CommandSender sender, @NotNull final String alias, @NotNull final CommandSender sender, @NotNull final String alias,
@ -72,7 +81,7 @@ public final class CommandECloudDownload extends PlaceholderCommand {
return; 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"); 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; return;
} }