Add bypass handling to the gamemode flag

Set a player's previous gamemode when exiting a gamemode region to the server's default gamemode if there is not a previous gamemode already set
This commit is contained in:
zml2008 2012-04-21 15:12:16 -07:00
parent 25280c9fa9
commit 0fed35a80f

View File

@ -206,10 +206,12 @@ public void onPlayerMove(PlayerMoveEvent event) {
+ regionList);
}
if (gameMode != null) {
if (!hasBypass && gameMode != null) {
if (player.getGameMode() != gameMode) {
state.lastGameMode = player.getGameMode();
player.setGameMode(gameMode);
} else if (state.lastGameMode == null) {
state.lastGameMode = player.getServer().getDefaultGameMode();
}
} else {
if (state.lastGameMode != null) {
@ -237,7 +239,7 @@ public void onPlayerMove(PlayerMoveEvent event) {
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
Player player = event.getPlayer();
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(player.getWorld());
if (wcfg.useRegions) {
if (wcfg.useRegions && !plugin.getGlobalRegionManager().hasBypass(player, player.getWorld())) {
GameMode gameMode = plugin.getGlobalRegionManager().get(player.getWorld())
.getApplicableRegions(player.getLocation()).getFlag(DefaultFlag.GAME_MODE);
if (plugin.getFlagStateManager().getState(player).lastGameMode != null