mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-28 05:25:20 +01:00
Added region command whitelisting and the bypass for command checks.
This commit is contained in:
parent
c9178da608
commit
767c49f9fa
@ -898,13 +898,20 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().hasBypass(player, world)) {
|
||||
Vector pt = toVector(player.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
String[] parts = event.getMessage().split(" ");
|
||||
|
||||
Set<String> allowedCommands = set.getFlag(DefaultFlag.ALLOWED_CMDS);
|
||||
if (allowedCommands != null && !allowedCommands.contains(parts[0].toLowerCase())) {
|
||||
player.sendMessage(ChatColor.RED + parts[0].toLowerCase() + " is not allowed in this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> blockedCommands = set.getFlag(DefaultFlag.BLOCKED_CMDS);
|
||||
if (blockedCommands != null && blockedCommands.contains(parts[0].toLowerCase())) {
|
||||
player.sendMessage(ChatColor.RED + parts[0].toLowerCase() + " is blocked in this area.");
|
||||
|
@ -63,6 +63,7 @@ public final class DefaultFlag {
|
||||
public static final BooleanFlag BUYABLE = new BooleanFlag("buyable");
|
||||
public static final DoubleFlag PRICE = new DoubleFlag("price");
|
||||
public static final SetFlag<String> BLOCKED_CMDS = new SetFlag<String>("blocked-cmds", new CommandStringFlag(null));
|
||||
public static final SetFlag<String> ALLOWED_CMDS = new SetFlag<String>("allowed-cmds", new CommandStringFlag(null));
|
||||
|
||||
public static final Flag<?>[] flagsList = new Flag<?>[] {
|
||||
PASSTHROUGH, BUILD, PVP, MOB_DAMAGE, MOB_SPAWNING, CREEPER_EXPLOSION, SLEEP,
|
||||
@ -70,7 +71,7 @@ public final class DefaultFlag {
|
||||
USE, PLACE_VEHICLE, GREET_MESSAGE, FAREWELL_MESSAGE, NOTIFY_ENTER,
|
||||
NOTIFY_LEAVE, DENY_SPAWN, HEAL_DELAY, HEAL_AMOUNT, TELE_LOC,
|
||||
TELE_PERM, SPAWN_LOC, SPAWN_PERM, BUYABLE, PRICE, SNOW_FALL, LEAF_DECAY,
|
||||
GHAST_FIREBALL, BLOCKED_CMDS
|
||||
GHAST_FIREBALL, BLOCKED_CMDS, ALLOWED_CMDS
|
||||
};
|
||||
|
||||
private DefaultFlag() {
|
||||
|
Loading…
Reference in New Issue
Block a user