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