CommandOp .java

net.minecraft.command.server.CommandOp (class, 88 lines): members: addTabCompletionOptions, getRequiredPermissionLevel, getCommandUsage, getCommandName.

net.minecraft.command.serverclass88 linesserverextends CommandBase2.5 KB

API Surface (5)

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

String literals (3)

"commands.op.usage"
"commands.op.failed"
"commands.op.success"

Code Graph: Dependencies (6)

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

Full Source

CommandOp.java88 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.command.server;
2
3
import com.google.common.collect.Lists;
4
import com.mojang.authlib.GameProfile;
5
import java.util.List;
6
import net.minecraft.command.CommandBase;
7
import net.minecraft.command.CommandException;
8
import net.minecraft.command.ICommandSender;
9
import net.minecraft.command.WrongUsageException;
10
import net.minecraft.server.MinecraftServer;
11
import net.minecraft.util.BlockPos;
12
13
public class CommandOp extends CommandBase
14
{
15
    /**
16
     * Gets the name of the command
17
     */
18
    public String getCommandName()
19
    {
20
        return "op";
21
    }
22
23
    /**
24
     * Return the required permission level for this command.
25
     */
26
    public int getRequiredPermissionLevel()
27
    {
28
        return 3;
29
    }
30
31
    /**
32
     * Gets the usage string for the command.
33
     */
34
    public String getCommandUsage(ICommandSender sender)
35
    {
36
        return "commands.op.usage";
37
    }
38
39
    /**
40
     * Callback when the command is invoked
41
     */
42
    public void processCommand(ICommandSender sender, String[] args) throws CommandException
43
    {
44
        if (args.length == 1 && args[0].length() > 0)
45
        {
46
            MinecraftServer minecraftserver = MinecraftServer.getServer();
47
            GameProfile gameprofile = minecraftserver.getPlayerProfileCache().getGameProfileForUsername(args[0]);
48
49
            if (gameprofile == null)
50
            {
51
                throw new CommandException("commands.op.failed", new Object[] {args[0]});
52
            }
53
            else
54
            {
55
                minecraftserver.getConfigurationManager().addOp(gameprofile);
56
                notifyOperators(sender, this, "commands.op.success", new Object[] {args[0]});
57
            }
58
        }
59
        else
60
        {
61
            throw new WrongUsageException("commands.op.usage", new Object[0]);
62
        }
63
    }
64
65
    public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
66
    {
67
        if (args.length == 1)
68
        {
69
            String s = args[args.length - 1];
70
            List<String> list = Lists.<String>newArrayList();
71
72
            for (GameProfile gameprofile : MinecraftServer.getServer().getGameProfiles())
73
            {
74
                if (!MinecraftServer.getServer().getConfigurationManager().canSendCommands(gameprofile) && doesStringStartWith(s, gameprofile.getName()))
75
                {
76
                    list.add(gameprofile.getName());
77
                }
78
            }
79
80
            return list;
81
        }
82
        else
83
        {
84
            return null;
85
        }
86
    }
87
}
88

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