mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-28 05:25:20 +01:00
Added water flow flag
This commit is contained in:
parent
933987ac0a
commit
5f12d99e73
15
config.yml
15
config.yml
@ -74,13 +74,14 @@ regions:
|
|||||||
enable: on
|
enable: on
|
||||||
wand: 287
|
wand: 287
|
||||||
default:
|
default:
|
||||||
build: true
|
build: on
|
||||||
chest-access: false
|
chest-access: off
|
||||||
pvp: true
|
pvp: on
|
||||||
lighter: true
|
lighter: on
|
||||||
tnt: true
|
tnt: on
|
||||||
creeper: true
|
creeper: on
|
||||||
mobdamage: true
|
mobdamage: on
|
||||||
|
waterflow: on
|
||||||
|
|
||||||
blacklist:
|
blacklist:
|
||||||
logging:
|
logging:
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.blacklist.events.*;
|
import com.sk89q.worldguard.blacklist.events.*;
|
||||||
|
import com.sk89q.worldguard.protection.GlobalFlags;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
import com.sk89q.worldguard.protection.regions.AreaFlags;
|
import com.sk89q.worldguard.protection.regions.AreaFlags;
|
||||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
|
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
|
||||||
@ -207,6 +208,17 @@ public void onBlockFlow(BlockFromToEvent event) {
|
|||||||
return;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,7 +113,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
|||||||
public boolean teleportOnSuffocation;
|
public boolean teleportOnSuffocation;
|
||||||
public boolean useRegions;
|
public boolean useRegions;
|
||||||
public int regionWand = 287;
|
public int regionWand = 287;
|
||||||
public String blockCreatureSpawn;
|
public String blockCreatureSpawn = "";
|
||||||
/**
|
/**
|
||||||
* Construct the plugin.
|
* Construct the plugin.
|
||||||
*
|
*
|
||||||
@ -314,6 +314,7 @@ public void loadConfiguration() {
|
|||||||
globalFlags.canTnt = config.getBoolean("regions.default.tnt", true);
|
globalFlags.canTnt = config.getBoolean("regions.default.tnt", true);
|
||||||
globalFlags.allowCreeper = config.getBoolean("regions.default.creeper", true);
|
globalFlags.allowCreeper = config.getBoolean("regions.default.creeper", true);
|
||||||
globalFlags.allowMobDamage = config.getBoolean("regions.default.mobdamage", true);
|
globalFlags.allowMobDamage = config.getBoolean("regions.default.mobdamage", true);
|
||||||
|
globalFlags.allowWaterflow = config.getBoolean("regions.default.waterflow", true);
|
||||||
globalRegionManager.setGlobalFlags(globalFlags);
|
globalRegionManager.setGlobalFlags(globalFlags);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -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("firespread", null, FlagValueType.STATE, "states", "firespread"));
|
||||||
flagList.add(new FlagInfo("lavafirespread", null, FlagValueType.STATE, "states", "lavafirespread"));
|
flagList.add(new FlagInfo("lavafirespread", null, FlagValueType.STATE, "states", "lavafirespread"));
|
||||||
flagList.add(new FlagInfo("chest", null, FlagValueType.STATE, "states", "chest"));
|
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) {
|
public static FlagInfo getFlagInfo(String name, String subName) {
|
||||||
|
@ -85,6 +85,8 @@ public boolean allowsFlag(String flag) {
|
|||||||
def = global.allowCreeper;
|
def = global.allowCreeper;
|
||||||
} else if (flag.equals(AreaFlags.FLAG_MOB_DAMAGE)) {
|
} else if (flag.equals(AreaFlags.FLAG_MOB_DAMAGE)) {
|
||||||
def = global.allowMobDamage;
|
def = global.allowMobDamage;
|
||||||
|
} else if (flag.equals(AreaFlags.FLAG_WATER_FLOW)) {
|
||||||
|
def = global.allowWaterflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isFlagAllowed(flag, def, null);
|
return isFlagAllowed(flag, def, null);
|
||||||
|
@ -32,4 +32,5 @@ public class GlobalFlags {
|
|||||||
public boolean canTnt = true;
|
public boolean canTnt = true;
|
||||||
public boolean allowCreeper = true;
|
public boolean allowCreeper = true;
|
||||||
public boolean allowMobDamage = true;
|
public boolean allowMobDamage = true;
|
||||||
|
public boolean allowWaterflow = true;
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ public enum State {
|
|||||||
public static final String FLAG_FIRE_SPREAD = "f";
|
public static final String FLAG_FIRE_SPREAD = "f";
|
||||||
public static final String FLAG_LAVA_FIRE = "F";
|
public static final String FLAG_LAVA_FIRE = "F";
|
||||||
public static final String FLAG_CHEST_ACCESS = "C";
|
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
|
* 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";
|
return "lava fire spread";
|
||||||
} else if (flag.equals(FLAG_CHEST_ACCESS)) {
|
} else if (flag.equals(FLAG_CHEST_ACCESS)) {
|
||||||
return "chest access";
|
return "chest access";
|
||||||
|
} else if (flag.equals(FLAG_WATER_FLOW)) {
|
||||||
|
return "water flow";
|
||||||
} else {
|
} else {
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
@ -106,6 +109,8 @@ public static String fromAlias(String name) {
|
|||||||
return FLAG_LAVA_FIRE;
|
return FLAG_LAVA_FIRE;
|
||||||
} else if (name.equalsIgnoreCase("chest")) {
|
} else if (name.equalsIgnoreCase("chest")) {
|
||||||
return FLAG_CHEST_ACCESS;
|
return FLAG_CHEST_ACCESS;
|
||||||
|
} else if (name.equalsIgnoreCase("waterflow")) {
|
||||||
|
return FLAG_WATER_FLOW;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user