Fix && should be ||, Allow Creative mode, Set all players in a world to a specific mode when it's changed

This commit is contained in:
Eric Stokes 2011-09-14 20:06:03 -06:00
parent 40c4ce0a37
commit 97168043ff
3 changed files with 14 additions and 3 deletions

View File

@ -424,11 +424,12 @@ public class MVWorld {
}
}
if (name.equalsIgnoreCase("gamemode") && name.equalsIgnoreCase("mode")) {
if (name.equalsIgnoreCase("gamemode") || name.equalsIgnoreCase("mode")) {
try {
GameMode mode = GameMode.valueOf(value);
GameMode mode = GameMode.valueOf(value.toUpperCase());
return this.setGameMode(mode);
} catch (Exception e) {
System.out.print("BLASKNKENFW");
}
}
@ -653,9 +654,15 @@ 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);
}
return true;
}

View File

@ -614,4 +614,8 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
return this.worldManager;
}
public MVPlayerListener getPlayerListener() {
return this.playerListener;
}
}

View File

@ -174,7 +174,7 @@ public class MVPlayerListener extends PlayerListener {
}
}
private void handleGameMode(Player player, MVWorld world) {
public void handleGameMode(Player player, MVWorld world) {
// We perform this task one tick later to MAKE SURE that the player actually reaches the
// destination world, otherwise we'd be changing the player mode if they havent moved anywhere.
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new HandleGameMode(player, world), 1L);