| 1 | package net.minecraft.command.server;
|
| 2 |
|
| 3 | import java.util.List;
|
| 4 | import net.minecraft.command.CommandBase;
|
| 5 | import net.minecraft.command.CommandException;
|
| 6 | import net.minecraft.command.ICommandSender;
|
| 7 | import net.minecraft.server.MinecraftServer;
|
| 8 | import net.minecraft.util.BlockPos;
|
| 9 | import net.minecraft.util.ChatComponentText;
|
| 10 | import net.minecraft.util.ChatComponentTranslation;
|
| 11 |
|
| 12 | public class CommandListBans extends CommandBase
|
| 13 | {
|
| 14 | /**
|
| 15 | * Gets the name of the command
|
| 16 | */
|
| 17 | public String getCommandName()
|
| 18 | {
|
| 19 | return "banlist";
|
| 20 | }
|
| 21 |
|
| 22 | /**
|
| 23 | * Return the required permission level for this command.
|
| 24 | */
|
| 25 | public int getRequiredPermissionLevel()
|
| 26 | {
|
| 27 | return 3;
|
| 28 | }
|
| 29 |
|
| 30 | /**
|
| 31 | * Returns true if the given command sender is allowed to use this command.
|
| 32 | */
|
| 33 | public boolean canCommandSenderUseCommand(ICommandSender sender)
|
| 34 | {
|
| 35 | return (MinecraftServer.getServer().getConfigurationManager().getBannedIPs().isLanServer() || MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().isLanServer()) && super.canCommandSenderUseCommand(sender);
|
| 36 | }
|
| 37 |
|
| 38 | /**
|
| 39 | * Gets the usage string for the command.
|
| 40 | */
|
| 41 | public String getCommandUsage(ICommandSender sender)
|
| 42 | {
|
| 43 | return "commands.banlist.usage";
|
| 44 | }
|
| 45 |
|
| 46 | /**
|
| 47 | * Callback when the command is invoked
|
| 48 | */
|
| 49 | public void processCommand(ICommandSender sender, String[] args) throws CommandException
|
| 50 | {
|
| 51 | if (args.length >= 1 && args[0].equalsIgnoreCase("ips"))
|
| 52 | {
|
| 53 | sender.addChatMessage(new ChatComponentTranslation("commands.banlist.ips", new Object[] {Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getKeys().length)}));
|
| 54 | sender.addChatMessage(new ChatComponentText(joinNiceString(MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getKeys())));
|
| 55 | }
|
| 56 | else
|
| 57 | {
|
| 58 | sender.addChatMessage(new ChatComponentTranslation("commands.banlist.players", new Object[] {Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().getKeys().length)}));
|
| 59 | sender.addChatMessage(new ChatComponentText(joinNiceString(MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().getKeys())));
|
| 60 | }
|
| 61 | }
|
| 62 |
|
| 63 | public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
|
| 64 | {
|
| 65 | return args.length == 1 ? getListOfStringsMatchingLastWord(args, new String[] {"players", "ips"}): null;
|
| 66 | }
|
| 67 | }
|
| 68 |
|