mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-02-01 04:51:27 +01:00
flags are now type-safe
This commit is contained in:
parent
7ab49f1909
commit
3bf18c41bb
@ -18,18 +18,16 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlagContainer;
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase.FlagType;
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.nijiko.coelho.iConomy.system.Account;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
@ -249,7 +247,7 @@ public void onBlockFlow(BlockFromToEvent event) {
|
||||
Vector pt = toVector(blockFrom.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(world.getName());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.WATER_FLOW)) {
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(Flags.WATER_FLOW)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -295,18 +293,18 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||
&& !set.isStateFlagAllowed(FlagType.LIGHTER)) {
|
||||
&& !set.isStateFlagAllowed(Flags.LIGHTER)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isFireSpread && set.isStateFlagAllowed(FlagType.FIRE_SPREAD)) {
|
||||
if (isFireSpread && set.isStateFlagAllowed(Flags.FIRE_SPREAD)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.LAVA && !set.isStateFlagAllowed(FlagType.LAVA_FIRE)) {
|
||||
if (cause == IgniteCause.LAVA && !set.isStateFlagAllowed(Flags.LAVA_FIRE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -450,7 +448,7 @@ public void onBlockInteract(BlockInteractEvent event) {
|
||||
|
||||
if (!cfg.hasPermission(player, "region.bypass")) {
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
if (!set.isStateFlagAllowed(FlagType.CHEST_ACCESS) && !set.canBuild(localPlayer)) {
|
||||
if (!set.isStateFlagAllowed(Flags.CHEST_ACCESS) && !set.canBuild(localPlayer)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -465,7 +463,7 @@ public void onBlockInteract(BlockInteractEvent event) {
|
||||
ApplicableRegionSet applicableRegions = mgr.getApplicableRegions(pt);
|
||||
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, (Player)entity);
|
||||
|
||||
if (!applicableRegions.isStateFlagAllowed(FlagType.LEVER_AND_BUTTON, localPlayer)) {
|
||||
if (!applicableRegions.isStateFlagAllowed(Flags.LEVER_AND_BUTTON, localPlayer)) {
|
||||
((Player)entity).sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -609,11 +607,11 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
||||
if (region != null) {
|
||||
RegionFlagContainer flags = region.getFlags();
|
||||
|
||||
if (flags.getBooleanFlag(FlagType.BUYABLE).getValue(false)) {
|
||||
if (flags.getBooleanFlag(Flags.BUYABLE).getValue(false)) {
|
||||
if (iConomy.getBank().hasAccount(player.getName())) {
|
||||
Account account = iConomy.getBank().getAccount(player.getName());
|
||||
double balance = account.getBalance();
|
||||
double regionPrice = flags.getDoubleFlag(FlagType.PRICE).getValue();
|
||||
double regionPrice = flags.getDoubleFlag(Flags.PRICE).getValue();
|
||||
|
||||
if (balance >= regionPrice) {
|
||||
account.subtract(regionPrice);
|
||||
@ -622,7 +620,7 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
||||
DefaultDomain owners = region.getOwners();
|
||||
owners.addPlayer(player.getName());
|
||||
region.setOwners(owners);
|
||||
flags.getBooleanFlag(FlagType.BUYABLE).setValue(false);
|
||||
flags.getBooleanFlag(Flags.BUYABLE).setValue(false);
|
||||
account.save();
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + "You have not enough money.");
|
||||
|
@ -18,10 +18,10 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase.FlagType;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -115,7 +115,7 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.PVP)) {
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(Flags.PVP)) {
|
||||
((Player) attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -134,13 +134,13 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
if (!set.isStateFlagAllowed(FlagType.MOB_DAMAGE)) {
|
||||
if (!set.isStateFlagAllowed(Flags.MOB_DAMAGE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker instanceof Creeper) {
|
||||
if (!set.isStateFlagAllowed(FlagType.CREEPER_EXPLOSION)) {
|
||||
if (!set.isStateFlagAllowed(Flags.CREEPER_EXPLOSION)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -171,7 +171,7 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.PVP)) {
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(Flags.PVP)) {
|
||||
((Player) attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -183,7 +183,7 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.MOB_DAMAGE)) {
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(Flags.MOB_DAMAGE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -288,7 +288,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
Vector pt = toVector(l);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.CREEPER_EXPLOSION)) {
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(Flags.CREEPER_EXPLOSION)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -303,7 +303,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
Vector pt = toVector(l);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(FlagType.TNT)) {
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(Flags.TNT)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -403,7 +403,7 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
Vector pt = toVector(event.getEntity().getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName());
|
||||
|
||||
Boolean flagValue = mgr.getApplicableRegions(pt).getStringFlag(FlagType.DENY_SPAWN, true).getValue("").contains(creaName);
|
||||
Boolean flagValue = mgr.getApplicableRegions(pt).getStringFlag(Flags.DENY_SPAWN, true).getValue("").contains(creaName);
|
||||
if (flagValue != null) {
|
||||
if (flagValue) {
|
||||
cancelEvent = true;
|
||||
|
@ -18,13 +18,11 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.RegionGroup;
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase.FlagType;
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
@ -182,7 +180,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).isStateFlagAllowed(FlagType.LIGHTER)) {
|
||||
if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(Flags.LIGHTER)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -285,10 +283,10 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
player.getWorld().getName()).getApplicableRegions(
|
||||
BukkitUtil.toVector(location));
|
||||
|
||||
Location spawn = regions.getLocationFlag(FlagType.SPAWN_LOC, true).getValue(player.getServer());
|
||||
Location spawn = regions.getLocationFlag(Flags.SPAWN_LOC, true).getValue(player.getServer());
|
||||
|
||||
if (spawn != null) {
|
||||
RegionGroup spawnconfig = regions.getRegionGroupFlag(FlagType.SPAWN_PERM, true).getValue();
|
||||
RegionGroup spawnconfig = regions.getRegionGroupFlag(Flags.SPAWN_PERM, true).getValue();
|
||||
if (spawnconfig != null) {
|
||||
BukkitPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
||||
if (spawnconfig == RegionGroup.OWNER) {
|
||||
|
@ -20,20 +20,17 @@
|
||||
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||
import org.bukkit.event.vehicle.VehicleListener;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags;
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -65,6 +62,7 @@ public void registerEvents() {
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@Override
|
||||
public void onVehicleCreate(VehicleCreateEvent event) {
|
||||
Vehicle vhcl = event.getVehicle();
|
||||
Location vhclLoc = vhcl.getLocation();
|
||||
@ -75,7 +73,7 @@ public void onVehicleCreate(VehicleCreateEvent event) {
|
||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(vhcl.getWorld().getName());
|
||||
ApplicableRegionSet applicableRegions = mgr.getApplicableRegions(pt);
|
||||
|
||||
if (!applicableRegions.isStateFlagAllowed(FlagType.PLACE_VEHICLE)) {
|
||||
if (!applicableRegions.isStateFlagAllowed(Flags.PLACE_VEHICLE)) {
|
||||
vhcl.remove();
|
||||
return;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlagContainer;
|
||||
|
||||
/**
|
||||
@ -62,11 +62,11 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
if (region != null) {
|
||||
RegionFlagContainer flags = region.getFlags();
|
||||
|
||||
if (flags.getBooleanFlag(FlagType.BUYABLE).getValue(false)) {
|
||||
if (flags.getBooleanFlag(Flags.BUYABLE).getValue(false)) {
|
||||
if (args.length == 2) {
|
||||
if (args[1].equalsIgnoreCase("info")) {
|
||||
player.sendMessage(ChatColor.YELLOW + "Region " + id + " costs " +
|
||||
iConomy.getBank().format(flags.getDoubleFlag(FlagType.PRICE).getValue()));
|
||||
iConomy.getBank().format(flags.getDoubleFlag(Flags.PRICE).getValue()));
|
||||
if (iConomy.getBank().hasAccount(player.getName())) {
|
||||
player.sendMessage(ChatColor.YELLOW + "You have " +
|
||||
iConomy.getBank().format(
|
||||
@ -81,7 +81,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
if (iConomy.getBank().hasAccount(player.getName())) {
|
||||
Account account = iConomy.getBank().getAccount(player.getName());
|
||||
double balance = account.getBalance();
|
||||
double regionPrice = flags.getDoubleFlag(FlagType.PRICE).getValue();
|
||||
double regionPrice = flags.getDoubleFlag(Flags.PRICE).getValue();
|
||||
|
||||
if (balance >= regionPrice) {
|
||||
account.subtract(regionPrice);
|
||||
@ -90,7 +90,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
DefaultDomain owners = region.getOwners();
|
||||
owners.addPlayer(player.getName());
|
||||
region.setOwners(owners);
|
||||
flags.getBooleanFlag(FlagType.BUYABLE).setValue(false);
|
||||
flags.getBooleanFlag(Flags.BUYABLE).setValue(false);
|
||||
account.save();
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + "You have not enough money.");
|
||||
|
@ -27,7 +27,8 @@
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.FlagDataType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlagInfo;
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.LocationRegionFlagInfo;
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.RegionFlagInfo;
|
||||
import java.io.IOException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -88,19 +89,20 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
return true;
|
||||
}
|
||||
|
||||
if (nfo.dataType == FlagDataType.LOCATION) {
|
||||
if (nfo instanceof LocationRegionFlagInfo) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "Flag not supported in console mode.");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
LocationRegionFlagInfo lInfo = (LocationRegionFlagInfo)nfo;
|
||||
|
||||
Location l = player.getLocation();
|
||||
|
||||
if (valueStr != null && valueStr.equals("set")) {
|
||||
|
||||
if (region.contains(BukkitUtil.toVector(l))) {
|
||||
region.getFlags().getLocationFlag(nfo.type).setValue(l);
|
||||
region.getFlags().getLocationFlag(lInfo).setValue(l);
|
||||
sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag " + nameStr + " set to current location");
|
||||
return true;
|
||||
|
||||
@ -110,13 +112,13 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
}
|
||||
|
||||
} else if (valueStr == null || valueStr.equals("delete")) {
|
||||
region.getFlags().getLocationFlag(nfo.type).setValue((Location) null);
|
||||
region.getFlags().getLocationFlag(lInfo).setValue((Location) null);
|
||||
sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag " + nameStr + " removed.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!region.getFlags().getFlag(nfo.type).setValue(valueStr)) {
|
||||
if (!region.getFlags().getFlag(nfo).setValue(valueStr)) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid value '" + valueStr + "' for flag " + nameStr);
|
||||
return true;
|
||||
} else {
|
||||
|
@ -27,7 +27,7 @@
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlagContainer;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlagInfo;
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.RegionFlagInfo;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -81,7 +81,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
s.append(", ");
|
||||
}
|
||||
|
||||
s.append(nfo.name + ": " + flags.getFlag(nfo.type).toString());
|
||||
s.append(nfo.name + ": " + flags.getFlag(nfo).toString());
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.BLUE + "Flags: " + s.toString());
|
||||
|
@ -14,9 +14,8 @@
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.RegionGroup;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionGroupRegionFlag;
|
||||
|
||||
/**
|
||||
* @author wallnuss
|
||||
@ -47,9 +46,9 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
|
||||
RegionGroup flagright;
|
||||
if (spawn) {
|
||||
flagright = region.getFlags().getRegionGroupFlag(FlagType.SPAWN_PERM).getValue(RegionGroup.ALL);
|
||||
flagright = region.getFlags().getRegionGroupFlag(Flags.SPAWN_PERM).getValue(RegionGroup.ALL);
|
||||
} else {
|
||||
flagright = region.getFlags().getRegionGroupFlag(FlagType.TELE_PERM).getValue(RegionGroup.ALL);
|
||||
flagright = region.getFlags().getRegionGroupFlag(Flags.TELE_PERM).getValue(RegionGroup.ALL);
|
||||
}
|
||||
|
||||
LocalPlayer lPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
||||
@ -66,9 +65,9 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
Location location = null;
|
||||
|
||||
if (spawn) {
|
||||
location = region.getFlags().getLocationFlag(FlagType.SPAWN_LOC).getValue(cfg.getWorldGuardPlugin().getServer());
|
||||
location = region.getFlags().getLocationFlag(Flags.SPAWN_LOC).getValue(cfg.getWorldGuardPlugin().getServer());
|
||||
} else {
|
||||
location = region.getFlags().getLocationFlag(FlagType.TELE_LOC).getValue(cfg.getWorldGuardPlugin().getServer());
|
||||
location = region.getFlags().getLocationFlag(Flags.TELE_LOC).getValue(cfg.getWorldGuardPlugin().getServer());
|
||||
}
|
||||
if (location != null) {
|
||||
player.teleportTo(location);
|
||||
|
@ -22,9 +22,10 @@
|
||||
import java.util.Iterator;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.protection.regions.flags.*;
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.State;
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -64,35 +65,35 @@ public boolean canBuild(LocalPlayer player) {
|
||||
return global.canBuild;
|
||||
}
|
||||
|
||||
return getStateFlag(FlagType.BUILD, true).getValue(State.DENY) == State.ALLOW || isMember(player);
|
||||
return getStateFlag(Flags.BUILD, true).getValue(State.DENY) == State.ALLOW || isMember(player);
|
||||
}
|
||||
|
||||
|
||||
public boolean isStateFlagAllowed(FlagType type) {
|
||||
public boolean isStateFlagAllowed(StateRegionFlagInfo info) {
|
||||
|
||||
return isStateFlagAllowed(type, global.getDefaultValue(type));
|
||||
return isStateFlagAllowed(info, global.getDefaultValue(info.type));
|
||||
}
|
||||
|
||||
public boolean isStateFlagAllowed(FlagType type, boolean def) {
|
||||
public boolean isStateFlagAllowed(StateRegionFlagInfo info, boolean def) {
|
||||
|
||||
if (!this.isAnyRegionAffected()) {
|
||||
return def;
|
||||
}
|
||||
State defState = def ? State.ALLOW : State.DENY;
|
||||
return getStateFlag(type, true).getValue(defState) == State.ALLOW;
|
||||
return getStateFlag(info, true).getValue(defState) == State.ALLOW;
|
||||
}
|
||||
|
||||
public boolean isStateFlagAllowed(FlagType type, LocalPlayer player) {
|
||||
public boolean isStateFlagAllowed(StateRegionFlagInfo info, LocalPlayer player) {
|
||||
|
||||
if (type == FlagType.BUILD) {
|
||||
if (info.type == FlagType.BUILD) {
|
||||
return canBuild(player);
|
||||
}
|
||||
return isStateFlagAllowed(type, global.getDefaultValue(type), player);
|
||||
return isStateFlagAllowed(info, global.getDefaultValue(info.type), player);
|
||||
}
|
||||
|
||||
public boolean isStateFlagAllowed(FlagType type, boolean def, LocalPlayer player) {
|
||||
public boolean isStateFlagAllowed(StateRegionFlagInfo info, boolean def, LocalPlayer player) {
|
||||
|
||||
if (type == FlagType.BUILD) {
|
||||
if (info.type == FlagType.BUILD) {
|
||||
return canBuild(player);
|
||||
}
|
||||
|
||||
@ -101,10 +102,10 @@ 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);
|
||||
return getStateFlag(info, true).getValue(defState) == State.ALLOW || this.isMember(player);
|
||||
}
|
||||
|
||||
private RegionFlag getFlag(FlagType type, Boolean inherit) {
|
||||
private RegionFlag getFlag(RegionFlagInfo info, Boolean inherit) {
|
||||
|
||||
ProtectedRegion region = affectedRegion;
|
||||
|
||||
@ -113,11 +114,11 @@ private RegionFlag getFlag(FlagType type, Boolean inherit) {
|
||||
}
|
||||
|
||||
if (!inherit) {
|
||||
return region.getFlags().getFlag(type);
|
||||
return region.getFlags().getFlag(info);
|
||||
} else {
|
||||
RegionFlag value;
|
||||
do {
|
||||
value = region.getFlags().getFlag(type);
|
||||
value = region.getFlags().getFlag(info);
|
||||
region = region.getParent();
|
||||
|
||||
} while (!value.hasValue() && region != null);
|
||||
@ -127,9 +128,9 @@ private RegionFlag getFlag(FlagType type, Boolean inherit) {
|
||||
|
||||
}
|
||||
|
||||
public BooleanRegionFlag getBooleanFlag(FlagType type, boolean inherit) {
|
||||
public BooleanRegionFlag getBooleanFlag(BooleanRegionFlagInfo info, boolean inherit) {
|
||||
|
||||
RegionFlag flag = this.getFlag(type, inherit);
|
||||
RegionFlag flag = this.getFlag(info, inherit);
|
||||
|
||||
if (flag instanceof BooleanRegionFlag) {
|
||||
return (BooleanRegionFlag) flag;
|
||||
@ -138,9 +139,9 @@ public BooleanRegionFlag getBooleanFlag(FlagType type, boolean inherit) {
|
||||
}
|
||||
}
|
||||
|
||||
public StateRegionFlag getStateFlag(FlagType type, boolean inherit) {
|
||||
public StateRegionFlag getStateFlag(StateRegionFlagInfo info, boolean inherit) {
|
||||
|
||||
RegionFlag flag = this.getFlag(type, inherit);
|
||||
RegionFlag flag = this.getFlag(info, inherit);
|
||||
|
||||
if (flag instanceof StateRegionFlag) {
|
||||
return (StateRegionFlag) flag;
|
||||
@ -149,9 +150,9 @@ public StateRegionFlag getStateFlag(FlagType type, boolean inherit) {
|
||||
}
|
||||
}
|
||||
|
||||
public IntegerRegionFlag getIntegerFlag(FlagType type, boolean inherit) {
|
||||
public IntegerRegionFlag getIntegerFlag(IntegerRegionFlagInfo info, boolean inherit) {
|
||||
|
||||
RegionFlag flag = this.getFlag(type, inherit);
|
||||
RegionFlag flag = this.getFlag(info, inherit);
|
||||
|
||||
if (flag instanceof IntegerRegionFlag) {
|
||||
return (IntegerRegionFlag) flag;
|
||||
@ -160,9 +161,9 @@ public IntegerRegionFlag getIntegerFlag(FlagType type, boolean inherit) {
|
||||
}
|
||||
}
|
||||
|
||||
public DoubleRegionFlag getDoubleFlag(FlagType type, boolean inherit) {
|
||||
public DoubleRegionFlag getDoubleFlag(DoubleRegionFlagInfo info, boolean inherit) {
|
||||
|
||||
RegionFlag flag = this.getFlag(type, inherit);
|
||||
RegionFlag flag = this.getFlag(info, inherit);
|
||||
|
||||
if (flag instanceof DoubleRegionFlag) {
|
||||
return (DoubleRegionFlag) flag;
|
||||
@ -171,9 +172,9 @@ public DoubleRegionFlag getDoubleFlag(FlagType type, boolean inherit) {
|
||||
}
|
||||
}
|
||||
|
||||
public StringRegionFlag getStringFlag(FlagType type, boolean inherit) {
|
||||
public StringRegionFlag getStringFlag(StringRegionFlagInfo info, boolean inherit) {
|
||||
|
||||
RegionFlag flag = this.getFlag(type, inherit);
|
||||
RegionFlag flag = this.getFlag(info, inherit);
|
||||
|
||||
if (flag instanceof StringRegionFlag) {
|
||||
return (StringRegionFlag) flag;
|
||||
@ -182,9 +183,9 @@ public StringRegionFlag getStringFlag(FlagType type, boolean inherit) {
|
||||
}
|
||||
}
|
||||
|
||||
public RegionGroupRegionFlag getRegionGroupFlag(FlagType type, boolean inherit) {
|
||||
public RegionGroupRegionFlag getRegionGroupFlag(RegionGroupRegionFlagInfo info, boolean inherit) {
|
||||
|
||||
RegionFlag flag = this.getFlag(type, inherit);
|
||||
RegionFlag flag = this.getFlag(info, inherit);
|
||||
|
||||
if (flag instanceof RegionGroupRegionFlag) {
|
||||
return (RegionGroupRegionFlag) flag;
|
||||
@ -193,9 +194,9 @@ public RegionGroupRegionFlag getRegionGroupFlag(FlagType type, boolean inherit)
|
||||
}
|
||||
}
|
||||
|
||||
public LocationRegionFlag getLocationFlag(FlagType type, boolean inherit) {
|
||||
public LocationRegionFlag getLocationFlag(LocationRegionFlagInfo info, boolean inherit) {
|
||||
|
||||
RegionFlag flag = this.getFlag(type, inherit);
|
||||
RegionFlag flag = this.getFlag(info, inherit);
|
||||
|
||||
if (flag instanceof LocationRegionFlag) {
|
||||
return (LocationRegionFlag) flag;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags.FlagType;
|
||||
|
||||
/**
|
||||
* Used for default flags.
|
||||
|
@ -20,11 +20,11 @@
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase.FlagType;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import java.util.HashMap;
|
||||
@ -82,11 +82,11 @@ public void run() {
|
||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||
ApplicableRegionSet regions = mgr.getApplicableRegions(toVector(player.getLocation()));
|
||||
|
||||
int healDelay = regions.getIntegerFlag(FlagType.HEAL_DELAY, true).getValue(-1);
|
||||
int healDelay = regions.getIntegerFlag(Flags.HEAL_DELAY, true).getValue(-1);
|
||||
|
||||
if (healDelay > 0) {
|
||||
healDelay *= 1000;
|
||||
int healAmount = regions.getIntegerFlag(FlagType.HEAL_AMOUNT, true).getValue(1);
|
||||
int healAmount = regions.getIntegerFlag(Flags.HEAL_AMOUNT, true).getValue(1);
|
||||
if (now - nfo.lastHealTick > healDelay) {
|
||||
if (player.getHealth() < 20) {
|
||||
if (player.getHealth() + healAmount > 20) {
|
||||
@ -109,8 +109,8 @@ public void run() {
|
||||
|
||||
|
||||
if (nfo.lastRegion == null || !newRegionName.equals(nfo.lastRegion)) {
|
||||
String newGreetMsg = regions.getStringFlag(FlagType.GREET_MESSAGE, true).getValue();
|
||||
String farewellMsg = regions.getStringFlag(FlagType.FAREWELL_MESSAGE, true).getValue();
|
||||
String newGreetMsg = regions.getStringFlag(Flags.GREET_MESSAGE, true).getValue();
|
||||
String farewellMsg = regions.getStringFlag(Flags.FAREWELL_MESSAGE, true).getValue();
|
||||
|
||||
if (nfo.lastFarewellMsg != null) {
|
||||
player.sendMessage(nfo.lastFarewellMsg);
|
||||
@ -119,7 +119,7 @@ public void run() {
|
||||
if (newGreetMsg != null) {
|
||||
player.sendMessage(newGreetMsg);
|
||||
}
|
||||
if (regions.getBooleanFlag(FlagType.NOTIFY_GREET, false).getValue(false)) {
|
||||
if (regions.getBooleanFlag(Flags.NOTIFY_GREET, false).getValue(false)) {
|
||||
broadcastNotification(ChatColor.YELLOW + "Player " + player.getName() + " entered region " + newRegionName);
|
||||
}
|
||||
nfo.lastFarewellMsg = farewellMsg;
|
||||
@ -131,7 +131,7 @@ public void run() {
|
||||
player.sendMessage(nfo.lastFarewellMsg);
|
||||
nfo.lastFarewellMsg = null;
|
||||
}
|
||||
if (regions.getBooleanFlag(FlagType.NOTIFY_FAREWELL, false).getValue(false)) {
|
||||
if (regions.getBooleanFlag(Flags.NOTIFY_FAREWELL, false).getValue(false)) {
|
||||
broadcastNotification(ChatColor.YELLOW + "Player " + player.getName() + " left region " + nfo.lastRegion);
|
||||
}
|
||||
nfo.lastRegion = null;
|
||||
@ -140,7 +140,7 @@ public void run() {
|
||||
|
||||
//check passthrough flag
|
||||
LocalPlayer lplayer = BukkitPlayer.wrapPlayer(wg.getWgConfiguration(), player);
|
||||
if(!regions.isStateFlagAllowed(FlagType.PASSTHROUGH, lplayer))
|
||||
if(!regions.isStateFlagAllowed(Flags.PASSTHROUGH, lplayer))
|
||||
{
|
||||
Location newLoc = player.getLocation().clone();
|
||||
newLoc.setX(newLoc.getBlockX() - 30);
|
||||
|
@ -18,6 +18,8 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.RegionFlagInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
|
@ -18,6 +18,8 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.RegionFlagInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
|
@ -18,7 +18,8 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.FlagDataType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
@ -31,80 +32,25 @@
|
||||
*/
|
||||
public class FlagDatabase {
|
||||
|
||||
private static Map<FlagType, RegionFlagInfo> flagByFlagType;
|
||||
private static Map<String, RegionFlagInfo> flagByName;
|
||||
private static Map<FlagType, RegionFlagInfo> flagByFlagType = new EnumMap<FlagType, RegionFlagInfo>(FlagType.class);
|
||||
private static Map<String, RegionFlagInfo> flagByName = new HashMap<String, RegionFlagInfo>();
|
||||
|
||||
public enum FlagType {
|
||||
public static void registerFlag(RegionFlagInfo info) {
|
||||
|
||||
PASSTHROUGH, BUILD, PVP, MOB_DAMAGE, CREEPER_EXPLOSION,
|
||||
TNT, LIGHTER, FIRE_SPREAD, LAVA_FIRE, CHEST_ACCESS, WATER_FLOW,
|
||||
LEVER_AND_BUTTON, PLACE_VEHICLE, GREET_MESSAGE, FAREWELL_MESSAGE,
|
||||
NOTIFY_GREET, NOTIFY_FAREWELL, DENY_SPAWN, HEAL_DELAY, HEAL_AMOUNT,
|
||||
TELE_LOC, TELE_PERM, SPAWN_LOC, SPAWN_PERM, BUYABLE, PRICE
|
||||
|
||||
};
|
||||
|
||||
static {
|
||||
flagByFlagType = new EnumMap<FlagType, RegionFlagInfo>(FlagType.class);
|
||||
flagByName = new HashMap<String, RegionFlagInfo>();
|
||||
|
||||
registerFlag("passthrough", FlagType.PASSTHROUGH, FlagDataType.STATE);
|
||||
registerFlag("build", FlagType.BUILD, FlagDataType.STATE);
|
||||
registerFlag("pvp", FlagType.PVP, FlagDataType.STATE);
|
||||
registerFlag("mobdamage", FlagType.MOB_DAMAGE, FlagDataType.STATE);
|
||||
registerFlag("creeperexp", FlagType.CREEPER_EXPLOSION, FlagDataType.STATE);
|
||||
registerFlag("tnt", FlagType.TNT, FlagDataType.STATE);
|
||||
registerFlag("lighter", FlagType.LIGHTER, FlagDataType.STATE);
|
||||
registerFlag("firespread", FlagType.FIRE_SPREAD, FlagDataType.STATE);
|
||||
registerFlag("lavafire", FlagType.LAVA_FIRE, FlagDataType.STATE);
|
||||
registerFlag("chest", FlagType.CHEST_ACCESS, FlagDataType.STATE);
|
||||
registerFlag("waterflow", FlagType.WATER_FLOW, FlagDataType.STATE);
|
||||
registerFlag("leverandbutton", FlagType.LEVER_AND_BUTTON, FlagDataType.STATE);
|
||||
registerFlag("placevehicle", FlagType.PLACE_VEHICLE, FlagDataType.STATE);
|
||||
|
||||
registerFlag("buyable", FlagType.BUYABLE, FlagDataType.BOOLEAN);
|
||||
|
||||
registerFlag("healdelay", FlagType.HEAL_DELAY, FlagDataType.INTEGER);
|
||||
registerFlag("healamount", FlagType.HEAL_AMOUNT, FlagDataType.INTEGER);
|
||||
|
||||
registerFlag("price", FlagType.PRICE, FlagDataType.DOUBLE);
|
||||
|
||||
registerFlag("gmsg", FlagType.GREET_MESSAGE, FlagDataType.STRING);
|
||||
registerFlag("fmsg", FlagType.FAREWELL_MESSAGE, FlagDataType.STRING);
|
||||
registerFlag("denyspawn", FlagType.DENY_SPAWN, FlagDataType.STRING);
|
||||
registerFlag("notifygreet", FlagType.NOTIFY_GREET, FlagDataType.BOOLEAN);
|
||||
registerFlag("notifyfarewell", FlagType.NOTIFY_GREET, FlagDataType.BOOLEAN);
|
||||
|
||||
registerFlag("teleloc", FlagType.TELE_LOC, FlagDataType.LOCATION);
|
||||
registerFlag("spawnloc", FlagType.SPAWN_LOC, FlagDataType.LOCATION);
|
||||
|
||||
registerFlag("teleperm", FlagType.TELE_PERM, FlagDataType.REGIONGROUP);
|
||||
registerFlag("spawnperm", FlagType.SPAWN_PERM, FlagDataType.REGIONGROUP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void registerFlag(String name, FlagType type, FlagDataType dataType) {
|
||||
|
||||
RegionFlagInfo info = new RegionFlagInfo(name, type, dataType);
|
||||
flagByFlagType.put(info.type, info);
|
||||
flagByName.put(info.name, info);
|
||||
}
|
||||
|
||||
|
||||
public static RegionFlagInfo getFlagInfoFromName(String name)
|
||||
{
|
||||
public static RegionFlagInfo getFlagInfoFromName(String name) {
|
||||
return flagByName.get(name);
|
||||
}
|
||||
|
||||
public static List<RegionFlagInfo> getFlagInfoList()
|
||||
{
|
||||
public static List<RegionFlagInfo> getFlagInfoList() {
|
||||
List<RegionFlagInfo> list = new ArrayList<RegionFlagInfo>();
|
||||
list.addAll(flagByFlagType.values());
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static RegionFlag getNewInstanceOf(FlagType type, String value, RegionFlagContainer container) {
|
||||
RegionFlagInfo info = flagByFlagType.get(type);
|
||||
|
||||
@ -160,5 +106,4 @@ public static RegionFlag getNewInstanceOf(String name, String value, RegionFlagC
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
77
src/com/sk89q/worldguard/protection/regions/flags/Flags.java
Normal file
77
src/com/sk89q/worldguard/protection/regions/flags/Flags.java
Normal file
@ -0,0 +1,77 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
*/
|
||||
public class Flags {
|
||||
|
||||
public enum FlagType {
|
||||
|
||||
PASSTHROUGH, BUILD, PVP, MOB_DAMAGE, CREEPER_EXPLOSION,
|
||||
TNT, LIGHTER, FIRE_SPREAD, LAVA_FIRE, CHEST_ACCESS, WATER_FLOW,
|
||||
LEVER_AND_BUTTON, PLACE_VEHICLE, GREET_MESSAGE, FAREWELL_MESSAGE,
|
||||
NOTIFY_GREET, NOTIFY_FAREWELL, DENY_SPAWN, HEAL_DELAY, HEAL_AMOUNT,
|
||||
TELE_LOC, TELE_PERM, SPAWN_LOC, SPAWN_PERM, BUYABLE, PRICE
|
||||
};
|
||||
|
||||
// State flags
|
||||
public static StateRegionFlagInfo PASSTHROUGH = new StateRegionFlagInfo("passthrough", FlagType.PASSTHROUGH);
|
||||
public static StateRegionFlagInfo BUILD = new StateRegionFlagInfo("build", FlagType.BUILD);
|
||||
public static StateRegionFlagInfo PVP = new StateRegionFlagInfo("pvp", FlagType.PVP);
|
||||
public static StateRegionFlagInfo MOB_DAMAGE = new StateRegionFlagInfo("mobdamage", FlagType.MOB_DAMAGE);
|
||||
public static StateRegionFlagInfo CREEPER_EXPLOSION = new StateRegionFlagInfo("creeperexp", FlagType.CREEPER_EXPLOSION);
|
||||
public static StateRegionFlagInfo TNT = new StateRegionFlagInfo("tnt", FlagType.TNT);
|
||||
public static StateRegionFlagInfo LIGHTER = new StateRegionFlagInfo("lighter", FlagType.LIGHTER);
|
||||
public static StateRegionFlagInfo FIRE_SPREAD = new StateRegionFlagInfo("firespread", FlagType.FIRE_SPREAD);
|
||||
public static StateRegionFlagInfo LAVA_FIRE = new StateRegionFlagInfo("lavafire", FlagType.LAVA_FIRE);
|
||||
public static StateRegionFlagInfo CHEST_ACCESS = new StateRegionFlagInfo("chest", FlagType.CHEST_ACCESS);
|
||||
public static StateRegionFlagInfo WATER_FLOW = new StateRegionFlagInfo("waterflow", FlagType.WATER_FLOW);
|
||||
public static StateRegionFlagInfo LEVER_AND_BUTTON = new StateRegionFlagInfo("leverandbutton", FlagType.LEVER_AND_BUTTON);
|
||||
public static StateRegionFlagInfo PLACE_VEHICLE = new StateRegionFlagInfo("placevehicle", FlagType.PLACE_VEHICLE);
|
||||
|
||||
// Boolean flags
|
||||
public static BooleanRegionFlagInfo BUYABLE = new BooleanRegionFlagInfo("buyable", FlagType.BUYABLE);
|
||||
public static BooleanRegionFlagInfo NOTIFY_GREET = new BooleanRegionFlagInfo("notifygreet", FlagType.NOTIFY_GREET);
|
||||
public static BooleanRegionFlagInfo NOTIFY_FAREWELL = new BooleanRegionFlagInfo("notifyfarewell", FlagType.NOTIFY_FAREWELL);
|
||||
|
||||
// Integer flags
|
||||
public static IntegerRegionFlagInfo HEAL_DELAY = new IntegerRegionFlagInfo("healdelay", FlagType.HEAL_DELAY);
|
||||
public static IntegerRegionFlagInfo HEAL_AMOUNT = new IntegerRegionFlagInfo("healamount", FlagType.HEAL_AMOUNT);
|
||||
|
||||
// Double flags
|
||||
public static DoubleRegionFlagInfo PRICE = new DoubleRegionFlagInfo("price", FlagType.PRICE);
|
||||
|
||||
// String flags
|
||||
public static StringRegionFlagInfo GREET_MESSAGE = new StringRegionFlagInfo("gmsg", FlagType.GREET_MESSAGE);
|
||||
public static StringRegionFlagInfo FAREWELL_MESSAGE = new StringRegionFlagInfo("fmsg", FlagType.FAREWELL_MESSAGE);
|
||||
public static StringRegionFlagInfo DENY_SPAWN = new StringRegionFlagInfo("denyspawn", FlagType.DENY_SPAWN);
|
||||
|
||||
// Location flags
|
||||
public static LocationRegionFlagInfo TELE_LOC = new LocationRegionFlagInfo("teleloc", FlagType.TELE_LOC);
|
||||
public static LocationRegionFlagInfo SPAWN_LOC = new LocationRegionFlagInfo("spawnloc", FlagType.SPAWN_LOC);
|
||||
|
||||
// RegionGroup flags
|
||||
public static RegionGroupRegionFlagInfo TELE_PERM = new RegionGroupRegionFlagInfo("teleperm", FlagType.TELE_PERM);
|
||||
public static RegionGroupRegionFlagInfo SPAWN_PERM = new RegionGroupRegionFlagInfo("spawnperm", FlagType.SPAWN_PERM);
|
||||
}
|
@ -18,6 +18,8 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.RegionFlagInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.RegionFlagInfo;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.RegionFlagInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
|
@ -18,14 +18,14 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.*;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
||||
/**
|
||||
* Holds the sFlags for a region.
|
||||
*
|
||||
@ -37,7 +37,7 @@ public class RegionFlagContainer {
|
||||
private transient Map<FlagType, RegionFlag> flagData = new EnumMap<FlagType, RegionFlag>(FlagType.class);
|
||||
private transient boolean hasInit = false;
|
||||
|
||||
public RegionFlag getFlag(FlagType type) {
|
||||
private RegionFlag getFlag(FlagType type) {
|
||||
|
||||
if (!this.hasInit) {
|
||||
this.initFlagData();
|
||||
@ -102,10 +102,14 @@ public int hashCode() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public BooleanRegionFlag getBooleanFlag(FlagType type) {
|
||||
public RegionFlag getFlag(RegionFlagInfo info) {
|
||||
return this.getFlag(info.type);
|
||||
}
|
||||
|
||||
public BooleanRegionFlag getBooleanFlag(BooleanRegionFlagInfo info) {
|
||||
|
||||
RegionFlag flag = this.getFlag(info.type);
|
||||
|
||||
RegionFlag flag = this.getFlag(type);
|
||||
|
||||
if (flag instanceof BooleanRegionFlag) {
|
||||
return (BooleanRegionFlag) flag;
|
||||
} else {
|
||||
@ -113,9 +117,9 @@ public BooleanRegionFlag getBooleanFlag(FlagType type) {
|
||||
}
|
||||
}
|
||||
|
||||
public StateRegionFlag getStateFlag(FlagType type) {
|
||||
public StateRegionFlag getStateFlag(StateRegionFlagInfo info) {
|
||||
|
||||
RegionFlag flag = this.getFlag(type);
|
||||
RegionFlag flag = this.getFlag(info.type);
|
||||
|
||||
if (flag instanceof StateRegionFlag) {
|
||||
return (StateRegionFlag) flag;
|
||||
@ -124,60 +128,58 @@ public StateRegionFlag getStateFlag(FlagType type) {
|
||||
}
|
||||
}
|
||||
|
||||
public IntegerRegionFlag getIntegerFlag(FlagType type) {
|
||||
public IntegerRegionFlag getIntegerFlag(IntegerRegionFlagInfo info) {
|
||||
|
||||
RegionFlag flag = this.getFlag(info.type);
|
||||
|
||||
RegionFlag flag = this.getFlag(type);
|
||||
|
||||
if (flag instanceof IntegerRegionFlag) {
|
||||
return (IntegerRegionFlag) flag;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public DoubleRegionFlag getDoubleFlag(FlagType type) {
|
||||
|
||||
RegionFlag flag = this.getFlag(type);
|
||||
|
||||
public DoubleRegionFlag getDoubleFlag(DoubleRegionFlagInfo info) {
|
||||
|
||||
RegionFlag flag = this.getFlag(info.type);
|
||||
|
||||
if (flag instanceof DoubleRegionFlag) {
|
||||
return (DoubleRegionFlag) flag;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public StringRegionFlag getStringFlag(FlagType type) {
|
||||
|
||||
RegionFlag flag = this.getFlag(type);
|
||||
|
||||
public StringRegionFlag getStringFlag(StringRegionFlagInfo info) {
|
||||
|
||||
RegionFlag flag = this.getFlag(info.type);
|
||||
|
||||
if (flag instanceof StringRegionFlag) {
|
||||
return (StringRegionFlag) flag;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public RegionGroupRegionFlag getRegionGroupFlag(FlagType type) {
|
||||
|
||||
RegionFlag flag = this.getFlag(type);
|
||||
|
||||
public RegionGroupRegionFlag getRegionGroupFlag(RegionGroupRegionFlagInfo info) {
|
||||
|
||||
RegionFlag flag = this.getFlag(info.type);
|
||||
|
||||
if (flag instanceof RegionGroupRegionFlag) {
|
||||
return (RegionGroupRegionFlag) flag;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public LocationRegionFlag getLocationFlag(FlagType type) {
|
||||
|
||||
RegionFlag flag = this.getFlag(type);
|
||||
|
||||
public LocationRegionFlag getLocationFlag(LocationRegionFlagInfo info) {
|
||||
|
||||
RegionFlag flag = this.getFlag(info.type);
|
||||
|
||||
if (flag instanceof LocationRegionFlag) {
|
||||
return (LocationRegionFlag) flag;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.protection.regions.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.FlagDataType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
*/
|
||||
public class RegionFlagInfo {
|
||||
|
||||
public String name;
|
||||
public FlagType type;
|
||||
public FlagDataType dataType;
|
||||
|
||||
public RegionFlagInfo(String name, FlagType type, FlagDataType dataType)
|
||||
{
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.dataType = dataType;
|
||||
}
|
||||
}
|
@ -18,6 +18,8 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.RegionFlagInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
|
@ -18,6 +18,8 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.RegionFlagInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
|
@ -18,6 +18,8 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.info.RegionFlagInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
|
@ -0,0 +1,33 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags.info;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.FlagDataType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
*/
|
||||
public class BooleanRegionFlagInfo extends RegionFlagInfo<Boolean> {
|
||||
|
||||
public BooleanRegionFlagInfo(String name, FlagType type) {
|
||||
super(name, type, FlagDataType.BOOLEAN);
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags.info;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.FlagDataType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
*/
|
||||
public class DoubleRegionFlagInfo extends RegionFlagInfo<Boolean> {
|
||||
|
||||
public DoubleRegionFlagInfo(String name, FlagType type) {
|
||||
super(name, type, FlagDataType.BOOLEAN);
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags.info;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.FlagDataType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
*/
|
||||
public class IntegerRegionFlagInfo extends RegionFlagInfo<Integer> {
|
||||
|
||||
public IntegerRegionFlagInfo(String name, FlagType type) {
|
||||
super(name, type, FlagDataType.INTEGER);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags.info;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.FlagDataType;
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
*/
|
||||
public class LocationRegionFlagInfo extends RegionFlagInfo<Location> {
|
||||
|
||||
public LocationRegionFlagInfo(String name, FlagType type) {
|
||||
super(name, type, FlagDataType.LOCATION);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags.info;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.FlagDatabase;
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.FlagDataType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
*/
|
||||
public abstract class RegionFlagInfo<T> {
|
||||
|
||||
public String name;
|
||||
public FlagType type;
|
||||
public FlagDataType dataType;
|
||||
|
||||
public RegionFlagInfo(String name, FlagType type, FlagDataType dataType) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.dataType = dataType;
|
||||
FlagDatabase.registerFlag(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags.info;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.FlagDataType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.RegionGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
*/
|
||||
public class RegionGroupRegionFlagInfo extends RegionFlagInfo<RegionGroup> {
|
||||
|
||||
public RegionGroupRegionFlagInfo(String name, FlagType type) {
|
||||
super(name, type, FlagDataType.REGIONGROUP);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags.info;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.FlagDataType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.State;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
*/
|
||||
public class StateRegionFlagInfo extends RegionFlagInfo<State> {
|
||||
|
||||
public StateRegionFlagInfo(String name, FlagType type) {
|
||||
super(name, type, FlagDataType.STATE);
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.sk89q.worldguard.protection.regions.flags.info;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags.FlagType;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.FlagDataType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
*/
|
||||
public class StringRegionFlagInfo extends RegionFlagInfo<String> {
|
||||
|
||||
public StringRegionFlagInfo(String name, FlagType type) {
|
||||
super(name, type, FlagDataType.STRING);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user