    001package net.minecraft.command;
    002
    003import net.minecraft.server.MinecraftServer;
    004import net.minecraft.util.IProgressUpdate;
    005import net.minecraft.world.MinecraftException;
    006import net.minecraft.world.WorldServer;
    007
    008public class CommandServerSaveAll extends CommandBase
    009{
    010    public String getCommandName()
    011    {
    012        return "save-all";
    013    }
    014
    015    /**
    016     * Return the required permission level for this command.
    017     */
    018    public int getRequiredPermissionLevel()
    019    {
    020        return 4;
    021    }
    022
    023    public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    024    {
    025        MinecraftServer var3 = MinecraftServer.getServer();
    026        par1ICommandSender.sendChatToPlayer(par1ICommandSender.translateString("commands.save.start", new Object[0]));
    027
    028        if (var3.getConfigurationManager() != null)
    029        {
    030            var3.getConfigurationManager().saveAllPlayerData();
    031        }
    032
    033        try
    034        {
    035            for (int var4 = 0; var4 < var3.worldServers.length; ++var4)
    036            {
    037                if (var3.worldServers[var4] != null)
    038                {
    039                    WorldServer var5 = var3.worldServers[var4];
    040                    boolean var6 = var5.canNotSave;
    041                    var5.canNotSave = false;
    042                    var5.saveAllChunks(true, (IProgressUpdate)null);
    043                    var5.canNotSave = var6;
    044                }
    045            }
    046        }
    047        catch (MinecraftException var7)
    048        {
    049            notifyAdmins(par1ICommandSender, "commands.save.failed", new Object[] {var7.getMessage()});
    050            return;
    051        }
    052
    053        notifyAdmins(par1ICommandSender, "commands.save.success", new Object[0]);
    054    }
    055}