CommandSetSpawnpoint .java

net.minecraft.command.CommandSetSpawnpoint (class): members: isUsernameIndex, addTabCompletionOptions, getRequiredPermissionLevel, getCommandUsage.

net.minecraft.commandclass69 linescommonextends CommandBase2.1 KB

API Surface (6)

String getCommandName()
int getRequiredPermissionLevel()
String getCommandUsage(ICommandSender sender)
void processCommand(ICommandSender sender, String[] args)
List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
boolean isUsernameIndex(String[] args, int index)

String literals (3)

"spawnpoint"
"commands.spawnpoint.usage"
"commands.spawnpoint.success"

Code Graph: Dependencies (5)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

CommandSetSpawnpoint.java69 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.command;
2
3
import java.util.List;
4
import net.minecraft.entity.player.EntityPlayerMP;
5
import net.minecraft.server.MinecraftServer;
6
import net.minecraft.util.BlockPos;
7
8
public class CommandSetSpawnpoint extends CommandBase
9
{
10
    /**
11
     * Gets the name of the command
12
     */
13
    public String getCommandName()
14
    {
15
        return "spawnpoint";
16
    }
17
18
    /**
19
     * Return the required permission level for this command.
20
     */
21
    public int getRequiredPermissionLevel()
22
    {
23
        return 2;
24
    }
25
26
    /**
27
     * Gets the usage string for the command.
28
     */
29
    public String getCommandUsage(ICommandSender sender)
30
    {
31
        return "commands.spawnpoint.usage";
32
    }
33
34
    /**
35
     * Callback when the command is invoked
36
     */
37
    public void processCommand(ICommandSender sender, String[] args) throws CommandException
38
    {
39
        if (args.length > 1 && args.length < 4)
40
        {
41
            throw new WrongUsageException("commands.spawnpoint.usage", new Object[0]);
42
        }
43
        else
44
        {
45
            EntityPlayerMP entityplayermp = args.length > 0 ? getPlayer(sender, args[0]) : getCommandSenderAsPlayer(sender);
46
            BlockPos blockpos = args.length > 3 ? parseBlockPos(sender, args, 1, true) : entityplayermp.getPosition();
47
48
            if (entityplayermp.worldObj != null)
49
            {
50
                entityplayermp.setSpawnPoint(blockpos, true);
51
                notifyOperators(sender, this, "commands.spawnpoint.success", new Object[] {entityplayermp.getName(), Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
52
            }
53
        }
54
    }
55
56
    public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
57
    {
58
        return args.length == 1 ? getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()) : (args.length > 1 && args.length <= 4 ? func_175771_a(args, 1, pos) : null);
59
    }
60
61
    /**
62
     * Return whether the specified command parameter index is a username parameter.
63
     */
64
    public boolean isUsernameIndex(String[] args, int index)
65
    {
66
        return index == 0;
67
    }
68
}
69

Deobfuscated MCP 1.8.9 source of CommandSetSpawnpoint from Marcelektro/MavenMCP-1.8.9 (net/minecraft/command/CommandSetSpawnpoint.java), stored verbatim.