CommandDefaultGameMode .java

net.minecraft.command.CommandDefaultGameMode (class): members: setGameType, getCommandUsage, getCommandName, processCommand. strings: "defaultgamemode".

net.minecraft.commandclass58 linescommonextends CommandGameMode1.8 KB

API Surface (4)

String getCommandName()
String getCommandUsage(ICommandSender sender)
void processCommand(ICommandSender sender, String[] args)
void setGameType(WorldSettings.GameType gameMode)

String literals (4)

"defaultgamemode"
"commands.defaultgamemode.usage"
"commands.defaultgamemode.success"
"gameMode."

Code Graph: Dependencies (6)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

CommandDefaultGameMode.java58 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.command;
2
3
import net.minecraft.entity.player.EntityPlayerMP;
4
import net.minecraft.server.MinecraftServer;
5
import net.minecraft.util.ChatComponentTranslation;
6
import net.minecraft.world.WorldSettings;
7
8
public class CommandDefaultGameMode extends CommandGameMode
9
{
10
    /**
11
     * Gets the name of the command
12
     */
13
    public String getCommandName()
14
    {
15
        return "defaultgamemode";
16
    }
17
18
    /**
19
     * Gets the usage string for the command.
20
     */
21
    public String getCommandUsage(ICommandSender sender)
22
    {
23
        return "commands.defaultgamemode.usage";
24
    }
25
26
    /**
27
     * Callback when the command is invoked
28
     */
29
    public void processCommand(ICommandSender sender, String[] args) throws CommandException
30
    {
31
        if (args.length <= 0)
32
        {
33
            throw new WrongUsageException("commands.defaultgamemode.usage", new Object[0]);
34
        }
35
        else
36
        {
37
            WorldSettings.GameType worldsettings$gametype = this.getGameModeFromCommand(sender, args[0]);
38
            this.setGameType(worldsettings$gametype);
39
            notifyOperators(sender, this, "commands.defaultgamemode.success", new Object[] {new ChatComponentTranslation("gameMode." + worldsettings$gametype.getName(), new Object[0])});
40
        }
41
    }
42
43
    protected void setGameType(WorldSettings.GameType gameMode)
44
    {
45
        MinecraftServer minecraftserver = MinecraftServer.getServer();
46
        minecraftserver.setGameType(gameMode);
47
48
        if (minecraftserver.getForceGamemode())
49
        {
50
            for (EntityPlayerMP entityplayermp : MinecraftServer.getServer().getConfigurationManager().getPlayerList())
51
            {
52
                entityplayermp.setGameType(gameMode);
53
                entityplayermp.fallDistance = 0.0F;
54
            }
55
        }
56
    }
57
}
58

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