Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
SaveCommand.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 SaveCommand extends VanillaCommand {
14  public SaveCommand() {
15  super("save-all");
16  this.description = "Saves the server to disk";
17  this.usageMessage = "/save-all";
18  this.setPermission("bukkit.command.save.perform");
19  }
20 
21  @Override
22  public boolean execute(CommandSender sender, String currentAlias, String[] args) {
23  if (!testPermission(sender)) return true;
24 
25  Command.broadcastCommandMessage(sender, "Forcing save..");
26 
28 
29  for (World world : Bukkit.getWorlds()) {
30  world.save();
31  }
32 
33  Command.broadcastCommandMessage(sender, "Save complete.");
34 
35  return true;
36  }
37 
38  @Override
39  public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
40  Validate.notNull(sender, "Sender cannot be null");
41  Validate.notNull(args, "Arguments cannot be null");
42  Validate.notNull(alias, "Alias cannot be null");
43 
44  return ImmutableList.of();
45  }
46 }
boolean testPermission(CommandSender target)
void setPermission(String permission)
static List< World > getWorlds()
Definition: Bukkit.java:229
static void savePlayers()
Definition: Bukkit.java:308