mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-25 10:37:41 +01:00
renamed isFlagAllowed() to isStateFlagAllowed()
This commit is contained in:
parent
30b0e5d0b1
commit
4d8cd430b7
@ -227,7 +227,7 @@ public void onBlockFlow(BlockFromToEvent event) {
|
|||||||
Vector pt = toVector(blockFrom.getLocation());
|
Vector pt = toVector(blockFrom.getLocation());
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(world.getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(world.getName());
|
||||||
|
|
||||||
if (!mgr.getApplicableRegions(pt).allowsFlag(FlagType.WATER_FLOW)) {
|
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.WATER_FLOW)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -273,18 +273,18 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||||
&& !set.allowsFlag(FlagType.LIGHTER)) {
|
&& !set.isStateFlagAllowed(FlagType.LIGHTER)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFireSpread && set.allowsFlag(FlagType.FIRE_SPREAD)) {
|
if (isFireSpread && set.isStateFlagAllowed(FlagType.FIRE_SPREAD)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cause == IgniteCause.LAVA && !set.allowsFlag(FlagType.LAVA_FIRE)) {
|
if (cause == IgniteCause.LAVA && !set.isStateFlagAllowed(FlagType.LAVA_FIRE)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -428,7 +428,7 @@ public void onBlockInteract(BlockInteractEvent event) {
|
|||||||
|
|
||||||
if (!cfg.hasPermission(player, "region.bypass")) {
|
if (!cfg.hasPermission(player, "region.bypass")) {
|
||||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||||
if (!set.allowsFlag(FlagType.CHEST_ACCESS) && !set.canBuild(localPlayer)) {
|
if (!set.isStateFlagAllowed(FlagType.CHEST_ACCESS) && !set.canBuild(localPlayer)) {
|
||||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -443,7 +443,7 @@ public void onBlockInteract(BlockInteractEvent event) {
|
|||||||
ApplicableRegionSet applicableRegions = mgr.getApplicableRegions(pt);
|
ApplicableRegionSet applicableRegions = mgr.getApplicableRegions(pt);
|
||||||
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, (Player)entity);
|
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, (Player)entity);
|
||||||
|
|
||||||
if (!applicableRegions.allowsFlag(FlagType.LEVER_AND_BUTTON, localPlayer)) {
|
if (!applicableRegions.isStateFlagAllowed(FlagType.LEVER_AND_BUTTON, localPlayer)) {
|
||||||
((Player)entity).sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
((Player)entity).sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
@ -102,7 +102,7 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
|||||||
Vector pt = toVector(defender.getLocation());
|
Vector pt = toVector(defender.getLocation());
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
|
|
||||||
if (!mgr.getApplicableRegions(pt).allowsFlag(FlagType.PVP)) {
|
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.PVP)) {
|
||||||
((Player) attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
|
((Player) attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -121,13 +121,13 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
|||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||||
|
|
||||||
if (!set.allowsFlag(FlagType.MOB_DAMAGE)) {
|
if (!set.isStateFlagAllowed(FlagType.MOB_DAMAGE)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attacker instanceof Creeper) {
|
if (attacker instanceof Creeper) {
|
||||||
if (!set.allowsFlag(FlagType.CREEPER_EXPLOSION)) {
|
if (!set.isStateFlagAllowed(FlagType.CREEPER_EXPLOSION)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
|||||||
Vector pt = toVector(defender.getLocation());
|
Vector pt = toVector(defender.getLocation());
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
|
|
||||||
if (!mgr.getApplicableRegions(pt).allowsFlag(FlagType.PVP)) {
|
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.PVP)) {
|
||||||
((Player) attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
|
((Player) attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -170,7 +170,7 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
|||||||
Vector pt = toVector(defender.getLocation());
|
Vector pt = toVector(defender.getLocation());
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
|
|
||||||
if (!mgr.getApplicableRegions(pt).allowsFlag(FlagType.MOB_DAMAGE)) {
|
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.MOB_DAMAGE)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -275,7 +275,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
|||||||
Vector pt = toVector(l);
|
Vector pt = toVector(l);
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||||
|
|
||||||
if (!mgr.getApplicableRegions(pt).allowsFlag(FlagType.CREEPER_EXPLOSION)) {
|
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.CREEPER_EXPLOSION)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
|||||||
Vector pt = toVector(l);
|
Vector pt = toVector(l);
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||||
|
|
||||||
if (!mgr.getApplicableRegions(pt).allowsFlag(FlagType.TNT)) {
|
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.TNT)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ public void onPlayerItem(PlayerItemEvent event) {
|
|||||||
Vector pt = toVector(block.getRelative(event.getBlockFace()));
|
Vector pt = toVector(block.getRelative(event.getBlockFace()));
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
|
|
||||||
if (!mgr.getApplicableRegions(pt).allowsFlag(FlagType.LIGHTER)) {
|
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.LIGHTER)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public ApplicableRegionSet(List<ProtectedRegion> applicable, GlobalFlags global
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean canBuild(LocalPlayer player) {
|
public boolean canBuild(LocalPlayer player) {
|
||||||
return isFlagAllowed(FlagType.BUILD, global.canBuild) || this.isMember(player);
|
return isStateFlagAllowed(FlagType.BUILD, global.canBuild) || this.isMember(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,21 +69,21 @@ public boolean canBuild(LocalPlayer player) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean allowsFlag(FlagType type) {
|
public boolean isStateFlagAllowed(FlagType type) {
|
||||||
return isFlagAllowed(type, global.getDefaultValue(type));
|
return isStateFlagAllowed(type, global.getDefaultValue(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean allowsFlag(FlagType type, LocalPlayer player) {
|
public boolean isStateFlagAllowed(FlagType type, LocalPlayer player) {
|
||||||
return isFlagAllowed(type, global.getDefaultValue(type)) || this.isMember(player);
|
return isStateFlagAllowed(type, global.getDefaultValue(type)) || this.isMember(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFlagAllowed(FlagType type, boolean def) {
|
public boolean isStateFlagAllowed(FlagType type, boolean def) {
|
||||||
|
|
||||||
State defState = def ? State.ALLOW : State.DENY;
|
State defState = def ? State.ALLOW : State.DENY;
|
||||||
return getStateFlag(type, true).getValue(defState) == State.ALLOW;
|
return getStateFlag(type, true).getValue(defState) == State.ALLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFlagAllowed(FlagType type, boolean def, LocalPlayer player) {
|
public boolean isStateFlagAllowed(FlagType type, boolean def, LocalPlayer player) {
|
||||||
|
|
||||||
State defState = def ? State.ALLOW : State.DENY;
|
State defState = def ? State.ALLOW : State.DENY;
|
||||||
return getStateFlag(type, true).getValue(defState) == State.ALLOW || this.isMember(player);
|
return getStateFlag(type, true).getValue(defState) == State.ALLOW || this.isMember(player);
|
||||||
@ -248,7 +248,7 @@ public int getAffectedRegionPriority() {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
private boolean isFlagAllowed(String flag, boolean def, LocalPlayer player) {
|
private boolean isStateFlagAllowed(String flag, boolean def, LocalPlayer player) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
boolean allowed = false; // Used for ALLOW override
|
boolean allowed = false; // Used for ALLOW override
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
@ -327,7 +327,7 @@ private boolean isFlagAllowed(String flag, boolean def, LocalPlayer player) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear a region's parents for isFlagAllowed().
|
* Clear a region's parents for isStateFlagAllowed().
|
||||||
*
|
*
|
||||||
* @param needsClear
|
* @param needsClear
|
||||||
* @param hasCleared
|
* @param hasCleared
|
||||||
|
@ -115,17 +115,17 @@ public void testNonBuildFlag() {
|
|||||||
|
|
||||||
// Outside
|
// Outside
|
||||||
appl = manager.getApplicableRegions(outside);
|
appl = manager.getApplicableRegions(outside);
|
||||||
//assertTrue(appl.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD));
|
//assertTrue(appl.isStateFlagAllowed(AreaFlags.FLAG_FIRE_SPREAD));
|
||||||
// Inside courtyard
|
// Inside courtyard
|
||||||
appl = manager.getApplicableRegions(inCourtyard);
|
appl = manager.getApplicableRegions(inCourtyard);
|
||||||
//assertTrue(appl.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD));
|
//assertTrue(appl.isStateFlagAllowed(AreaFlags.FLAG_FIRE_SPREAD));
|
||||||
// Inside fountain
|
// Inside fountain
|
||||||
appl = manager.getApplicableRegions(inFountain);
|
appl = manager.getApplicableRegions(inFountain);
|
||||||
//assertFalse(appl.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD));
|
//assertFalse(appl.isStateFlagAllowed(AreaFlags.FLAG_FIRE_SPREAD));
|
||||||
|
|
||||||
// Inside no fire zone
|
// Inside no fire zone
|
||||||
appl = manager.getApplicableRegions(inNoFire);
|
appl = manager.getApplicableRegions(inNoFire);
|
||||||
//assertFalse(appl.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD));
|
//assertFalse(appl.isStateFlagAllowed(AreaFlags.FLAG_FIRE_SPREAD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user