Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
SaveOffCommand.java
1 package org.bukkit.command.defaults;
2 
3 import java.util.List;
4 
5 import org.apache.commons.lang.Validate;
6 import org.bukkit.Bukkit;
7 import org.bukkit.World;
10 
11 import com.google.common.collect.ImmutableList;
12 
13 public class SaveOffCommand extends VanillaCommand {
14  public SaveOffCommand() {
15  super("save-off");
16  this.description = "Disables server autosaving";
17  this.usageMessage = "/save-off";
18  this.setPermission("bukkit.command.save.disable");
19  }
20 
21  @Override
22  public boolean execute(CommandSender sender, String currentAlias, String[] args) {
23  if (!testPermission(sender)) return true;
24 
25  for (World world : Bukkit.getWorlds()) {
26  world.setAutoSave(false);
27  }
28 
29  Command.broadcastCommandMessage(sender, "Disabled level saving..");
30  return true;
31  }
32 
33  @Override
34  public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
35  Validate.notNull(sender, "Sender cannot be null");
36  Validate.notNull(args, "Arguments cannot be null");
37  Validate.notNull(alias, "Alias cannot be null");
38 
39  return ImmutableList.of();
40  }
41 }
boolean testPermission(CommandSender target)
void setPermission(String permission)
static List< World > getWorlds()
Definition: Bukkit.java:229