    001    package net.minecraft.src;
    002
    003    import java.util.List;
    004    import net.minecraft.server.MinecraftServer;
    005
    006    public class CommandSetSpawnpoint extends CommandBase
    007    {
    008        public String getCommandName()
    009        {
    010            return "spawnpoint";
    011        }
    012
    013        /**
    014         * Return the required permission level for this command.
    015         */
    016        public int getRequiredPermissionLevel()
    017        {
    018            return 2;
    019        }
    020
    021        public String getCommandUsage(ICommandSender par1ICommandSender)
    022        {
    023            return par1ICommandSender.translateString("commands.spawnpoint.usage", new Object[0]);
    024        }
    025
    026        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    027        {
    028            EntityPlayerMP var3 = par2ArrayOfStr.length == 0 ? getCommandSenderAsPlayer(par1ICommandSender) : func_82359_c(par1ICommandSender, par2ArrayOfStr[0]);
    029
    030            if (par2ArrayOfStr.length == 4)
    031            {
    032                if (var3.worldObj != null)
    033                {
    034                    byte var4 = 1;
    035                    int var5 = 30000000;
    036                    int var10 = var4 + 1;
    037                    int var6 = parseIntBounded(par1ICommandSender, par2ArrayOfStr[var4], -var5, var5);
    038                    int var7 = parseIntBounded(par1ICommandSender, par2ArrayOfStr[var10++], 0, 256);
    039                    int var8 = parseIntBounded(par1ICommandSender, par2ArrayOfStr[var10++], -var5, var5);
    040                    var3.setSpawnChunk(new ChunkCoordinates(var6, var7, var8), true);
    041                    notifyAdmins(par1ICommandSender, "commands.spawnpoint.success", new Object[] {var3.getEntityName(), Integer.valueOf(var6), Integer.valueOf(var7), Integer.valueOf(var8)});
    042                }
    043            }
    044            else
    045            {
    046                if (par2ArrayOfStr.length > 1)
    047                {
    048                    throw new WrongUsageException("commands.spawnpoint.usage", new Object[0]);
    049                }
    050
    051                ChunkCoordinates var11 = var3.getPlayerCoordinates();
    052                var3.setSpawnChunk(var11, true);
    053                notifyAdmins(par1ICommandSender, "commands.spawnpoint.success", new Object[] {var3.getEntityName(), Integer.valueOf(var11.posX), Integer.valueOf(var11.posY), Integer.valueOf(var11.posZ)});
    054            }
    055        }
    056
    057        /**
    058         * Adds the strings available in this command to the given list of tab completion options.
    059         */
    060        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    061        {
    062            return par2ArrayOfStr.length != 1 && par2ArrayOfStr.length != 2 ? null : getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames());
    063        }
    064
    065        /**
    066         * Return whether the specified command parameter index is a username parameter.
    067         */
    068        public boolean isUsernameIndex(int par1)
    069        {
    070            return par1 == 0;
    071        }
    072    }