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());
|
||||
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);
|
||||
return;
|
||||
}
|
||||
@ -273,18 +273,18 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||
&& !set.allowsFlag(FlagType.LIGHTER)) {
|
||||
&& !set.isStateFlagAllowed(FlagType.LIGHTER)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isFireSpread && set.allowsFlag(FlagType.FIRE_SPREAD)) {
|
||||
if (isFireSpread && set.isStateFlagAllowed(FlagType.FIRE_SPREAD)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.LAVA && !set.allowsFlag(FlagType.LAVA_FIRE)) {
|
||||
if (cause == IgniteCause.LAVA && !set.isStateFlagAllowed(FlagType.LAVA_FIRE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -428,7 +428,7 @@ public void onBlockInteract(BlockInteractEvent event) {
|
||||
|
||||
if (!cfg.hasPermission(player, "region.bypass")) {
|
||||
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.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -443,7 +443,7 @@ public void onBlockInteract(BlockInteractEvent event) {
|
||||
ApplicableRegionSet applicableRegions = mgr.getApplicableRegions(pt);
|
||||
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.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -102,7 +102,7 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
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.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -121,13 +121,13 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
if (!set.allowsFlag(FlagType.MOB_DAMAGE)) {
|
||||
if (!set.isStateFlagAllowed(FlagType.MOB_DAMAGE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker instanceof Creeper) {
|
||||
if (!set.allowsFlag(FlagType.CREEPER_EXPLOSION)) {
|
||||
if (!set.isStateFlagAllowed(FlagType.CREEPER_EXPLOSION)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -158,7 +158,7 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
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.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -170,7 +170,7 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
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);
|
||||
return;
|
||||
}
|
||||
@ -275,7 +275,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
Vector pt = toVector(l);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
@ -290,7 +290,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
Vector pt = toVector(l);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).allowsFlag(FlagType.TNT)) {
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.TNT)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ public void onPlayerItem(PlayerItemEvent event) {
|
||||
Vector pt = toVector(block.getRelative(event.getBlockFace()));
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public ApplicableRegionSet(List<ProtectedRegion> applicable, GlobalFlags global
|
||||
* @return
|
||||
*/
|
||||
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
|
||||
* @return
|
||||
*/
|
||||
public boolean allowsFlag(FlagType type) {
|
||||
return isFlagAllowed(type, global.getDefaultValue(type));
|
||||
public boolean isStateFlagAllowed(FlagType type) {
|
||||
return isStateFlagAllowed(type, global.getDefaultValue(type));
|
||||
}
|
||||
|
||||
public boolean allowsFlag(FlagType type, LocalPlayer player) {
|
||||
return isFlagAllowed(type, global.getDefaultValue(type)) || this.isMember(player);
|
||||
public boolean isStateFlagAllowed(FlagType type, LocalPlayer 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;
|
||||
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;
|
||||
return getStateFlag(type, true).getValue(defState) == State.ALLOW || this.isMember(player);
|
||||
@ -248,7 +248,7 @@ public int getAffectedRegionPriority() {
|
||||
* @return
|
||||
*/
|
||||
/*
|
||||
private boolean isFlagAllowed(String flag, boolean def, LocalPlayer player) {
|
||||
private boolean isStateFlagAllowed(String flag, boolean def, LocalPlayer player) {
|
||||
boolean found = false;
|
||||
boolean allowed = false; // Used for ALLOW override
|
||||
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 hasCleared
|
||||
|
@ -115,17 +115,17 @@ public void testNonBuildFlag() {
|
||||
|
||||
// Outside
|
||||
appl = manager.getApplicableRegions(outside);
|
||||
//assertTrue(appl.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD));
|
||||
//assertTrue(appl.isStateFlagAllowed(AreaFlags.FLAG_FIRE_SPREAD));
|
||||
// Inside courtyard
|
||||
appl = manager.getApplicableRegions(inCourtyard);
|
||||
//assertTrue(appl.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD));
|
||||
//assertTrue(appl.isStateFlagAllowed(AreaFlags.FLAG_FIRE_SPREAD));
|
||||
// Inside fountain
|
||||
appl = manager.getApplicableRegions(inFountain);
|
||||
//assertFalse(appl.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD));
|
||||
//assertFalse(appl.isStateFlagAllowed(AreaFlags.FLAG_FIRE_SPREAD));
|
||||
|
||||
// Inside no fire zone
|
||||
appl = manager.getApplicableRegions(inNoFire);
|
||||
//assertFalse(appl.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD));
|
||||
//assertFalse(appl.isStateFlagAllowed(AreaFlags.FLAG_FIRE_SPREAD));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user