mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI.git
synced 2024-12-26 02:48:14 +01:00
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.
This commit is contained in:
parent
e862abe0b4
commit
ecd4c002c8
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user