    001    package net.minecraft.src;
    002
    003    import java.util.List;
    004    import net.minecraft.server.MinecraftServer;
    005
    006    public class CommandGameRule extends CommandBase
    007    {
    008        public String getCommandName()
    009        {
    010            return "gamerule";
    011        }
    012
    013        public int func_82362_a()
    014        {
    015            return 2;
    016        }
    017
    018        public String getCommandUsage(ICommandSender par1ICommandSender)
    019        {
    020            return par1ICommandSender.translateString("commands.gamerule.usage", new Object[0]);
    021        }
    022
    023        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    024        {
    025            String var6;
    026
    027            if (par2ArrayOfStr.length == 2)
    028            {
    029                var6 = par2ArrayOfStr[0];
    030                String var7 = par2ArrayOfStr[1];
    031                GameRules var8 = this.func_82366_d();
    032
    033                if (var8.func_82765_e(var6))
    034                {
    035                    var8.func_82764_b(var6, var7);
    036                    notifyAdmins(par1ICommandSender, "commands.gamerule.success", new Object[0]);
    037                }
    038                else
    039                {
    040                    notifyAdmins(par1ICommandSender, "commands.gamerule.norule", new Object[] {var6});
    041                }
    042            }
    043            else if (par2ArrayOfStr.length == 1)
    044            {
    045                var6 = par2ArrayOfStr[0];
    046                GameRules var4 = this.func_82366_d();
    047
    048                if (var4.func_82765_e(var6))
    049                {
    050                    String var5 = var4.func_82767_a(var6);
    051                    par1ICommandSender.sendChatToPlayer(var6 + " = " + var5);
    052                }
    053                else
    054                {
    055                    notifyAdmins(par1ICommandSender, "commands.gamerule.norule", new Object[] {var6});
    056                }
    057            }
    058            else if (par2ArrayOfStr.length == 0)
    059            {
    060                GameRules var3 = this.func_82366_d();
    061                par1ICommandSender.sendChatToPlayer(joinNiceString(var3.func_82763_b()));
    062            }
    063            else
    064            {
    065                throw new WrongUsageException("commands.gamerule.usage", new Object[0]);
    066            }
    067        }
    068
    069        /**
    070         * Adds the strings available in this command to the given list of tab completion options.
    071         */
    072        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    073        {
    074            return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, this.func_82366_d().func_82763_b()) : (par2ArrayOfStr.length == 2 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"true", "false"}): null);
    075        }
    076
    077        private GameRules func_82366_d()
    078        {
    079            return MinecraftServer.getServer().worldServerForDimension(0).func_82736_K();
    080        }
    081    }