diff --git a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java index ceb162e9..8fa26c25 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java @@ -654,14 +654,16 @@ public class MVWorld { } private boolean setGameMode(GameMode mode) { - + this.gameMode = mode; config.setProperty("worlds." + this.name + ".gamemode", this.gameMode.toString()); saveConfig(); - - for(Player p : this.plugin.getServer().getWorld(this.getName()).getPlayers()) { - this.plugin.log(Level.FINER, "Setting " + p.getName() + "'s GameMode to " + this.gameMode.toString()); - this.plugin.getPlayerListener().handleGameMode(p, this); + + if (this.plugin.getConfig().getBoolean("enforcegamemodes", true)) { + for (Player p : this.plugin.getServer().getWorld(this.getName()).getPlayers()) { + this.plugin.log(Level.FINER, "Setting " + p.getName() + "'s GameMode to " + this.gameMode.toString()); + this.plugin.getPlayerListener().handleGameMode(p, this); + } } return true; } diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java index a536f5b9..10dd6ef1 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java @@ -72,7 +72,9 @@ public class MVPlayerListener extends PlayerListener { if(event.isBedSpawn() && this.plugin.getConfig().getBoolean("bedrespawn", true)) { // Handle the Players GameMode setting for the new world. - this.handleGameMode(event.getPlayer(), event.getRespawnLocation().getWorld()); + if (this.plugin.getConfig().getBoolean("enforcegamemodes", true)) { + this.handleGameMode(event.getPlayer(), event.getRespawnLocation().getWorld()); + } this.plugin.log(Level.FINE, "Spawning " + event.getPlayer().getName() + " at their bed"); return; } @@ -98,7 +100,9 @@ public class MVPlayerListener extends PlayerListener { event.setRespawnLocation(respawnEvent.getPlayersRespawnLocation()); // Handle the Players GameMode setting for the new world. - this.handleGameMode(event.getPlayer(), respawnEvent.getPlayersRespawnLocation().getWorld()); + if (this.plugin.getConfig().getBoolean("enforcegamemodes", true)) { + this.handleGameMode(event.getPlayer(), respawnEvent.getPlayersRespawnLocation().getWorld()); + } } private Location getMostAccurateRespawnLocation(World w) { @@ -118,7 +122,9 @@ public class MVPlayerListener extends PlayerListener { event.getPlayer().sendMessage("If you just wanna see all of the Multiverse Help, type: " + ChatColor.GREEN + "/mv"); } // Handle the Players GameMode setting for the new world. - this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld()); + if (this.plugin.getConfig().getBoolean("enforcegamemodes", true)) { + this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld()); + } } @Override