CommandPardonIp .java

net.minecraft.command.server.CommandPardonIp (class, 77 lines): members: canCommandSenderUseCommand, addTabCompletionOptions, getRequiredPermissionLevel.

net.minecraft.command.serverclass77 linesserverextends CommandBase2.3 KB

API Surface (6)

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

String literals (4)

"pardon-ip"
"commands.unbanip.usage"
"commands.unbanip.success"
"commands.unbanip.invalid"

Full Source

CommandPardonIp.java77 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.command.server;
2
3
import java.util.List;
4
import java.util.regex.Matcher;
5
import net.minecraft.command.CommandBase;
6
import net.minecraft.command.CommandException;
7
import net.minecraft.command.ICommandSender;
8
import net.minecraft.command.SyntaxErrorException;
9
import net.minecraft.command.WrongUsageException;
10
import net.minecraft.server.MinecraftServer;
11
import net.minecraft.util.BlockPos;
12
13
public class CommandPardonIp extends CommandBase
14
{
15
    /**
16
     * Gets the name of the command
17
     */
18
    public String getCommandName()
19
    {
20
        return "pardon-ip";
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
     * Returns true if the given command sender is allowed to use this command.
33
     */
34
    public boolean canCommandSenderUseCommand(ICommandSender sender)
35
    {
36
        return MinecraftServer.getServer().getConfigurationManager().getBannedIPs().isLanServer() && super.canCommandSenderUseCommand(sender);
37
    }
38
39
    /**
40
     * Gets the usage string for the command.
41
     */
42
    public String getCommandUsage(ICommandSender sender)
43
    {
44
        return "commands.unbanip.usage";
45
    }
46
47
    /**
48
     * Callback when the command is invoked
49
     */
50
    public void processCommand(ICommandSender sender, String[] args) throws CommandException
51
    {
52
        if (args.length == 1 && args[0].length() > 1)
53
        {
54
            Matcher matcher = CommandBanIp.field_147211_a.matcher(args[0]);
55
56
            if (matcher.matches())
57
            {
58
                MinecraftServer.getServer().getConfigurationManager().getBannedIPs().removeEntry(args[0]);
59
                notifyOperators(sender, this, "commands.unbanip.success", new Object[] {args[0]});
60
            }
61
            else
62
            {
63
                throw new SyntaxErrorException("commands.unbanip.invalid", new Object[0]);
64
            }
65
        }
66
        else
67
        {
68
            throw new WrongUsageException("commands.unbanip.usage", new Object[0]);
69
        }
70
    }
71
72
    public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
73
    {
74
        return args.length == 1 ? getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getKeys()) : null;
75
    }
76
}
77

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