CommandSaveAll .java

net.minecraft.command.server.CommandSaveAll (class, 85 lines): members: getCommandUsage, getCommandName, processCommand. strings: "commands.save.flushEnd".

net.minecraft.command.serverclass85 linesserverextends CommandBase2.9 KB

API Surface (3)

String getCommandName()
String getCommandUsage(ICommandSender sender)
void processCommand(ICommandSender sender, String[] args)

String literals (8)

"save-all"
"commands.save.usage"
"commands.save.start"
"flush"
"commands.save.flushStart"
"commands.save.flushEnd"
"commands.save.failed"
"commands.save.success"

Full Source

CommandSaveAll.java85 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.command.server;
2
3
import net.minecraft.command.CommandBase;
4
import net.minecraft.command.CommandException;
5
import net.minecraft.command.ICommandSender;
6
import net.minecraft.server.MinecraftServer;
7
import net.minecraft.util.ChatComponentTranslation;
8
import net.minecraft.util.IProgressUpdate;
9
import net.minecraft.world.MinecraftException;
10
import net.minecraft.world.WorldServer;
11
12
public class CommandSaveAll extends CommandBase
13
{
14
    /**
15
     * Gets the name of the command
16
     */
17
    public String getCommandName()
18
    {
19
        return "save-all";
20
    }
21
22
    /**
23
     * Gets the usage string for the command.
24
     */
25
    public String getCommandUsage(ICommandSender sender)
26
    {
27
        return "commands.save.usage";
28
    }
29
30
    /**
31
     * Callback when the command is invoked
32
     */
33
    public void processCommand(ICommandSender sender, String[] args) throws CommandException
34
    {
35
        MinecraftServer minecraftserver = MinecraftServer.getServer();
36
        sender.addChatMessage(new ChatComponentTranslation("commands.save.start", new Object[0]));
37
38
        if (minecraftserver.getConfigurationManager() != null)
39
        {
40
            minecraftserver.getConfigurationManager().saveAllPlayerData();
41
        }
42
43
        try
44
        {
45
            for (int i = 0; i < minecraftserver.worldServers.length; ++i)
46
            {
47
                if (minecraftserver.worldServers[i] != null)
48
                {
49
                    WorldServer worldserver = minecraftserver.worldServers[i];
50
                    boolean flag = worldserver.disableLevelSaving;
51
                    worldserver.disableLevelSaving = false;
52
                    worldserver.saveAllChunks(true, (IProgressUpdate)null);
53
                    worldserver.disableLevelSaving = flag;
54
                }
55
            }
56
57
            if (args.length > 0 && "flush".equals(args[0]))
58
            {
59
                sender.addChatMessage(new ChatComponentTranslation("commands.save.flushStart", new Object[0]));
60
61
                for (int j = 0; j < minecraftserver.worldServers.length; ++j)
62
                {
63
                    if (minecraftserver.worldServers[j] != null)
64
                    {
65
                        WorldServer worldserver1 = minecraftserver.worldServers[j];
66
                        boolean flag1 = worldserver1.disableLevelSaving;
67
                        worldserver1.disableLevelSaving = false;
68
                        worldserver1.saveChunkData();
69
                        worldserver1.disableLevelSaving = flag1;
70
                    }
71
                }
72
73
                sender.addChatMessage(new ChatComponentTranslation("commands.save.flushEnd", new Object[0]));
74
            }
75
        }
76
        catch (MinecraftException minecraftexception)
77
        {
78
            notifyOperators(sender, this, "commands.save.failed", new Object[] {minecraftexception.getMessage()});
79
            return;
80
        }
81
82
        notifyOperators(sender, this, "commands.save.success", new Object[0]);
83
    }
84
}
85

Deobfuscated MCP 1.8.9 source of CommandSaveAll from Marcelektro/MavenMCP-1.8.9 (net/minecraft/command/server/CommandSaveAll.java), stored verbatim.