Added allow-flight boolean flag for regions

Closes #198
This commit is contained in:
Deaygo 2012-03-23 16:44:19 -04:00 committed by zml2008
parent 15f0bfb9db
commit 16ce56c1ad
4 changed files with 26 additions and 2 deletions

View File

@ -1,4 +1,6 @@
5.5.2: 5.5.2:
- Added 'allow-flight' flag, which allows or disallows flight per-region
- Restructured /region list
- A cancellable event is now fired if WorldGuard disallows PvP. (for developers!) - A cancellable event is now fired if WorldGuard disallows PvP. (for developers!)
- Made /region setparent check worldguard.region.setparent.own/member.<parent> instead of worldguard.region.setparent.own/member.<child>. - Made /region setparent check worldguard.region.setparent.own/member.<parent> instead of worldguard.region.setparent.own/member.<child>.
- Allowed passing #<index> in place of a region ID, where <index> is the index as displayed by /region list. - Allowed passing #<index> in place of a region ID, where <index> is the index as displayed by /region list.

View File

@ -220,6 +220,7 @@ public static class PlayerFlagState {
public Boolean lastExitAllowed = null; public Boolean lastExitAllowed = null;
public Boolean notifiedForLeave = false; public Boolean notifiedForLeave = false;
public Boolean notifiedForEnter = false; public Boolean notifiedForEnter = false;
public Boolean lastAllowFlight = null;
public World lastWorld; public World lastWorld;
public int lastBlockX; public int lastBlockX;
public int lastBlockY; public int lastBlockY;

View File

@ -65,6 +65,7 @@
import com.sk89q.worldguard.protection.flags.DefaultFlag; import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import org.bukkit.GameMode;
/** /**
* Handles all events thrown in relation to a player. * Handles all events thrown in relation to a player.
@ -158,6 +159,7 @@ public void onPlayerMove(PlayerMoveEvent event) {
String farewell = set.getFlag(DefaultFlag.FAREWELL_MESSAGE);//, localPlayer); String farewell = set.getFlag(DefaultFlag.FAREWELL_MESSAGE);//, localPlayer);
Boolean notifyEnter = set.getFlag(DefaultFlag.NOTIFY_ENTER);//, localPlayer); Boolean notifyEnter = set.getFlag(DefaultFlag.NOTIFY_ENTER);//, localPlayer);
Boolean notifyLeave = set.getFlag(DefaultFlag.NOTIFY_LEAVE);//, localPlayer); Boolean notifyLeave = set.getFlag(DefaultFlag.NOTIFY_LEAVE);//, localPlayer);
Boolean allowFlight = set.getFlag(DefaultFlag.ALLOW_FLIGHT);//, localPlayer);
if (state.lastFarewell != null && (farewell == null if (state.lastFarewell != null && (farewell == null
|| !state.lastFarewell.equals(farewell))) { || !state.lastFarewell.equals(farewell))) {
@ -198,6 +200,24 @@ public void onPlayerMove(PlayerMoveEvent event) {
+ regionList); + regionList);
} }
if (allowFlight == null) {
if ((plugin.getServer().getDefaultGameMode() == GameMode.CREATIVE
&& player.getGameMode() == GameMode.CREATIVE)
|| player.getGameMode() == GameMode.CREATIVE) {
allowFlight = true;
} else {
allowFlight = false;
}
}
if (player.getAllowFlight() && !allowFlight) {
player.setAllowFlight(false);
state.lastAllowFlight = true;
} else if (!player.getAllowFlight() && allowFlight) {
player.setAllowFlight(true);
state.lastAllowFlight = false;
}
state.lastGreeting = greeting; state.lastGreeting = greeting;
state.lastFarewell = farewell; state.lastFarewell = farewell;
state.notifiedForEnter = notifyEnter; state.notifiedForEnter = notifyEnter;

View File

@ -80,6 +80,7 @@ public final class DefaultFlag {
public static final DoubleFlag PRICE = new DoubleFlag("price"); public static final DoubleFlag PRICE = new DoubleFlag("price");
public static final SetFlag<String> BLOCKED_CMDS = new SetFlag<String>("blocked-cmds", RegionGroup.ALL, new CommandStringFlag(null)); public static final SetFlag<String> BLOCKED_CMDS = new SetFlag<String>("blocked-cmds", RegionGroup.ALL, new CommandStringFlag(null));
public static final SetFlag<String> ALLOWED_CMDS = new SetFlag<String>("allowed-cmds", RegionGroup.ALL, new CommandStringFlag(null)); public static final SetFlag<String> ALLOWED_CMDS = new SetFlag<String>("allowed-cmds", RegionGroup.ALL, new CommandStringFlag(null));
public static final BooleanFlag ALLOW_FLIGHT = new BooleanFlag("allow-flight", RegionGroup.ALL);
public static final Flag<?>[] flagsList = new Flag<?>[] { public static final Flag<?>[] flagsList = new Flag<?>[] {
PASSTHROUGH, BUILD, CONSTRUCT, PVP, CHEST_ACCESS, PISTONS, PASSTHROUGH, BUILD, CONSTRUCT, PVP, CHEST_ACCESS, PISTONS,
@ -94,7 +95,7 @@ public final class DefaultFlag {
MUSHROOMS, LEAF_DECAY, GRASS_SPREAD, MUSHROOMS, LEAF_DECAY, GRASS_SPREAD,
FIRE_SPREAD, LAVA_FIRE, LAVA_FLOW, WATER_FLOW, FIRE_SPREAD, LAVA_FIRE, LAVA_FLOW, WATER_FLOW,
TELE_LOC, SPAWN_LOC, TELE_LOC, SPAWN_LOC,
BLOCKED_CMDS, ALLOWED_CMDS, PRICE, BUYABLE, BLOCKED_CMDS, ALLOWED_CMDS, PRICE, BUYABLE, ALLOW_FLIGHT,
}; };