mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-10-08 03:27:27 +02:00
Prevent commands in the allow commands list from being blocked and vice versa
This commit is contained in:
parent
f0e6008563
commit
2cc990a530
@ -1003,27 +1003,22 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
|||||||
Vector pt = toVector(player.getLocation());
|
Vector pt = toVector(player.getLocation());
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||||
ProtectedRegion globalRegion = mgr.getRegion("__global__");
|
|
||||||
|
|
||||||
String[] parts = event.getMessage().split(" ");
|
String[] parts = event.getMessage().split(" ");
|
||||||
|
String lowerCommand = parts[0].toLowerCase();
|
||||||
|
|
||||||
Set<String> allowedCommands = set.getFlag(DefaultFlag.ALLOWED_CMDS, localPlayer);
|
Set<String> allowedCommands = set.getFlag(DefaultFlag.ALLOWED_CMDS, localPlayer);
|
||||||
if (allowedCommands == null && globalRegion != null) {
|
|
||||||
allowedCommands = globalRegion.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, localPlayer);
|
Set<String> blockedCommands = set.getFlag(DefaultFlag.BLOCKED_CMDS, localPlayer);
|
||||||
if (blockedCommands == null && globalRegion != null) {
|
|
||||||
blockedCommands = globalRegion.getFlag(DefaultFlag.BLOCKED_CMDS);
|
if (allowedCommands != null && !allowedCommands.contains(lowerCommand) && (blockedCommands == null || blockedCommands.contains(lowerCommand))) {
|
||||||
|
player.sendMessage(ChatColor.RED + lowerCommand + " is not allowed in this area.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (blockedCommands != null && blockedCommands.contains(parts[0].toLowerCase())) {
|
|
||||||
player.sendMessage(ChatColor.RED + parts[0].toLowerCase() + " is blocked in this area.");
|
if (blockedCommands != null && blockedCommands.contains(lowerCommand)
|
||||||
|
&& (allowedCommands == null || !allowedCommands.contains(lowerCommand))) {
|
||||||
|
player.sendMessage(ChatColor.RED + lowerCommand + " is blocked in this area.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -139,16 +139,11 @@ public Object marshal(Location o) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double toNumber(Object o) {
|
private double toNumber(Object o) {
|
||||||
if (o instanceof Integer) {
|
if (o instanceof Number) {
|
||||||
return (Integer) o;
|
return ((Number) o).doubleValue();
|
||||||
} else if (o instanceof Long) {
|
|
||||||
return (Long) o;
|
|
||||||
} else if (o instanceof Float) {
|
|
||||||
return (Float) o;
|
|
||||||
} else if (o instanceof Double) {
|
|
||||||
return (Double) o;
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user