    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        public int func_82362_a()
    014        {
    015            return 2;
    016        }
    017
    018        public String getCommandUsage(ICommandSender par1ICommandSender)
    019        {
    020            return par1ICommandSender.translateString("commands.spawnpoint.usage", new Object[0]);
    021        }
    022
    023        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    024        {
    025            EntityPlayerMP var3 = par2ArrayOfStr.length == 0 ? getCommandSenderAsPlayer(par1ICommandSender) : func_82359_c(par1ICommandSender, par2ArrayOfStr[0]);
    026
    027            if (par2ArrayOfStr.length == 4)
    028            {
    029                if (var3.worldObj != null)
    030                {
    031                    byte var4 = 1;
    032                    int var5 = 30000000;
    033                    int var10 = var4 + 1;
    034                    int var6 = parseIntBounded(par1ICommandSender, par2ArrayOfStr[var4], -var5, var5);
    035                    int var7 = parseIntBounded(par1ICommandSender, par2ArrayOfStr[var10++], 0, 256);
    036                    int var8 = parseIntBounded(par1ICommandSender, par2ArrayOfStr[var10++], -var5, var5);
    037                    var3.setSpawnChunk(new ChunkCoordinates(var6, var7, var8), true);
    038                    notifyAdmins(par1ICommandSender, "commands.spawnpoint.success", new Object[] {var3.getEntityName(), Integer.valueOf(var6), Integer.valueOf(var7), Integer.valueOf(var8)});
    039                }
    040            }
    041            else
    042            {
    043                if (par2ArrayOfStr.length > 1)
    044                {
    045                    throw new WrongUsageException("commands.spawnpoint.usage", new Object[0]);
    046                }
    047
    048                ChunkCoordinates var11 = var3.func_82114_b();
    049                var3.setSpawnChunk(var11, true);
    050                notifyAdmins(par1ICommandSender, "commands.spawnpoint.success", new Object[] {var3.getEntityName(), Integer.valueOf(var11.posX), Integer.valueOf(var11.posY), Integer.valueOf(var11.posZ)});
    051            }
    052        }
    053
    054        /**
    055         * Adds the strings available in this command to the given list of tab completion options.
    056         */
    057        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    058        {
    059            return par2ArrayOfStr.length != 1 && par2ArrayOfStr.length != 2 ? null : getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames());
    060        }
    061
    062        public boolean func_82358_a(int par1)
    063        {
    064            return par1 == 0;
    065        }
    066    }