mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-28 05:25:20 +01:00
Bugfixes. Allowed/blocked commands should now respect global flags. Region invincibility/godmode compatibility should now work instead of throwing NPEs.
This commit is contained in:
parent
dec469caef
commit
602b1d8a27
@ -768,8 +768,8 @@ public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||
|
||||
/**
|
||||
* Check if a player is invincible, via either god mode or region flag. If
|
||||
* the region denies invincibility, the player must have the another
|
||||
* permission to override it.
|
||||
* the region denies invincibility, the player must have an extra permission
|
||||
* to override it. (worldguard.god.override-regions)
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
@ -779,13 +779,19 @@ private boolean isInvincible(Player player) {
|
||||
WorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||
|
||||
boolean god = cfg.hasGodMode(player);
|
||||
Boolean allowed = wcfg.useRegions && RegionQueryUtil.isAllowedInvinciblity(plugin, player);
|
||||
if (allowed == false && wcfg.useRegions) {
|
||||
return god && plugin.hasPermission(player, "worldguard.god.override-regions");
|
||||
} else if (allowed == true || !wcfg.useRegions) {
|
||||
return god;
|
||||
if (wcfg.useRegions) {
|
||||
Boolean flag = RegionQueryUtil.isAllowedInvinciblity(plugin, player);
|
||||
boolean allowed = flag == null || flag == true;
|
||||
boolean invincible = RegionQueryUtil.isInvincible(plugin, player);
|
||||
|
||||
if (allowed) {
|
||||
return god || invincible;
|
||||
} else {
|
||||
return (god && plugin.hasPermission(player, "worldguard.god.override-regions"))
|
||||
|| invincible;
|
||||
}
|
||||
} else {
|
||||
return RegionQueryUtil.isInvincible(plugin, player);
|
||||
return god;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1007,17 +1007,25 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Vector pt = toVector(player.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ProtectedRegion globalRegion = mgr.getRegion("__global__");
|
||||
|
||||
String[] parts = event.getMessage().split(" ");
|
||||
|
||||
Set<String> allowedCommands = set.getFlag(DefaultFlag.ALLOWED_CMDS);
|
||||
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);
|
||||
if (blockedCommands == null && globalRegion != null) {
|
||||
blockedCommands = globalRegion.getFlag(DefaultFlag.BLOCKED_CMDS);
|
||||
}
|
||||
if (blockedCommands != null && blockedCommands.contains(parts[0].toLowerCase())) {
|
||||
player.sendMessage(ChatColor.RED + parts[0].toLowerCase() + " is blocked in this area.");
|
||||
event.setCancelled(true);
|
||||
|
@ -309,9 +309,11 @@ private void clearParents(Set<ProtectedRegion> needsClear,
|
||||
* @throws IllegalArgumentException if a StateFlag is given
|
||||
*/
|
||||
public <T extends Flag<V>, V> V getFlag(T flag) {
|
||||
/*
|
||||
if (flag instanceof StateFlag) {
|
||||
throw new IllegalArgumentException("Cannot use StateFlag with getFlag()");
|
||||
}
|
||||
*/
|
||||
|
||||
int lastPriority = 0;
|
||||
boolean found = false;
|
||||
|
Loading…
Reference in New Issue
Block a user