    001package net.minecraft.command;
    002
    003import net.minecraft.server.MinecraftServer;
    004import net.minecraft.util.StatCollector;
    005import net.minecraft.world.EnumGameType;
    006
    007public class CommandDefaultGameMode extends CommandGameMode
    008{
    009    public String getCommandName()
    010    {
    011        return "defaultgamemode";
    012    }
    013
    014    public String getCommandUsage(ICommandSender par1ICommandSender)
    015    {
    016        return par1ICommandSender.translateString("commands.defaultgamemode.usage", new Object[0]);
    017    }
    018
    019    public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    020    {
    021        if (par2ArrayOfStr.length > 0)
    022        {
    023            EnumGameType enumgametype = this.getGameModeFromCommand(par1ICommandSender, par2ArrayOfStr[0]);
    024            this.setGameType(enumgametype);
    025            String s = StatCollector.translateToLocal("gameMode." + enumgametype.getName());
    026            notifyAdmins(par1ICommandSender, "commands.defaultgamemode.success", new Object[] {s});
    027        }
    028        else
    029        {
    030            throw new WrongUsageException("commands.defaultgamemode.usage", new Object[0]);
    031        }
    032    }
    033
    034    protected void setGameType(EnumGameType par1EnumGameType)
    035    {
    036        MinecraftServer.getServer().setGameType(par1EnumGameType);
    037    }
    038}