Added water flow flag

This commit is contained in:
DarkLiKally 2011-02-24 23:13:13 +01:00
parent 933987ac0a
commit 5f12d99e73
7 changed files with 31 additions and 8 deletions

View File

@ -74,13 +74,14 @@ regions:
enable: on
wand: 287
default:
build: true
chest-access: false
pvp: true
lighter: true
tnt: true
creeper: true
mobdamage: true
build: on
chest-access: off
pvp: on
lighter: on
tnt: on
creeper: on
mobdamage: on
waterflow: on
blacklist:
logging:

View File

@ -34,6 +34,7 @@
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.blacklist.events.*;
import com.sk89q.worldguard.protection.GlobalFlags;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.AreaFlags;
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
@ -207,6 +208,17 @@ public void onBlockFlow(BlockFromToEvent event) {
return;
}
}
if (plugin.useRegions) {
Vector pt = toVector(blockFrom.getLocation());
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(world.getName());
if (!mgr.getApplicableRegions(pt)
.allowsFlag("waterflow")) {
event.setCancelled(true);
return;
}
}
}
/**

View File

@ -113,7 +113,7 @@ public class WorldGuardPlugin extends JavaPlugin {
public boolean teleportOnSuffocation;
public boolean useRegions;
public int regionWand = 287;
public String blockCreatureSpawn;
public String blockCreatureSpawn = "";
/**
* Construct the plugin.
*
@ -314,6 +314,7 @@ public void loadConfiguration() {
globalFlags.canTnt = config.getBoolean("regions.default.tnt", true);
globalFlags.allowCreeper = config.getBoolean("regions.default.creeper", true);
globalFlags.allowMobDamage = config.getBoolean("regions.default.mobdamage", true);
globalFlags.allowWaterflow = config.getBoolean("regions.default.waterflow", true);
globalRegionManager.setGlobalFlags(globalFlags);
try {

View File

@ -55,6 +55,7 @@ public static enum FlagValueType { STRING, BOOLEAN, INT, FLOAT, DOUBLE, STATE };
flagList.add(new FlagInfo("firespread", null, FlagValueType.STATE, "states", "firespread"));
flagList.add(new FlagInfo("lavafirespread", null, FlagValueType.STATE, "states", "lavafirespread"));
flagList.add(new FlagInfo("chest", null, FlagValueType.STATE, "states", "chest"));
flagList.add(new FlagInfo("waterflow", null, FlagValueType.STATE, "states", "waterflow"));
}
public static FlagInfo getFlagInfo(String name, String subName) {

View File

@ -85,6 +85,8 @@ public boolean allowsFlag(String flag) {
def = global.allowCreeper;
} else if (flag.equals(AreaFlags.FLAG_MOB_DAMAGE)) {
def = global.allowMobDamage;
} else if (flag.equals(AreaFlags.FLAG_WATER_FLOW)) {
def = global.allowWaterflow;
}
return isFlagAllowed(flag, def, null);

View File

@ -32,4 +32,5 @@ public class GlobalFlags {
public boolean canTnt = true;
public boolean allowCreeper = true;
public boolean allowMobDamage = true;
public boolean allowWaterflow = true;
}

View File

@ -45,6 +45,7 @@ public enum State {
public static final String FLAG_FIRE_SPREAD = "f";
public static final String FLAG_LAVA_FIRE = "F";
public static final String FLAG_CHEST_ACCESS = "C";
public static final String FLAG_WATER_FLOW = "w";
/**
* Get the user-friendly name of a flag. If a name isn't known, then
@ -74,6 +75,8 @@ public static String getFlagName(String flag) {
return "lava fire spread";
} else if (flag.equals(FLAG_CHEST_ACCESS)) {
return "chest access";
} else if (flag.equals(FLAG_WATER_FLOW)) {
return "water flow";
} else {
return flag;
}
@ -106,6 +109,8 @@ public static String fromAlias(String name) {
return FLAG_LAVA_FIRE;
} else if (name.equalsIgnoreCase("chest")) {
return FLAG_CHEST_ACCESS;
} else if (name.equalsIgnoreCase("waterflow")) {
return FLAG_WATER_FLOW;
} else {
return null;
}