package net.minecraft.server; import com.mojang.authlib.GameProfile; import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.suggestion.SuggestionsBuilder; import java.util.Collection; import java.util.Iterator; public class CommandPardon { private static final SimpleCommandExceptionType a = new SimpleCommandExceptionType(new ChatMessage("commands.pardon.failed", new Object[0])); public static void a(com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> com_mojang_brigadier_commanddispatcher) { com_mojang_brigadier_commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) CommandDispatcher.a("pardon").requires((commandlistenerwrapper) -> { return commandlistenerwrapper.getServer().getPlayerList().getIPBans().isEnabled() && commandlistenerwrapper.hasPermission(3); })).then(CommandDispatcher.a("targets", (ArgumentType) ArgumentProfile.a()).suggests((commandcontext, suggestionsbuilder) -> { return ICompletionProvider.a(((CommandListenerWrapper) commandcontext.getSource()).getServer().getPlayerList().getProfileBans().getEntries(), suggestionsbuilder); }).executes((commandcontext) -> { return a((CommandListenerWrapper) commandcontext.getSource(), ArgumentProfile.a(commandcontext, "targets")); }))); } private static int a(CommandListenerWrapper commandlistenerwrapper, Collection<GameProfile> collection) throws CommandSyntaxException { GameProfileBanList gameprofilebanlist = commandlistenerwrapper.getServer().getPlayerList().getProfileBans(); int i = 0; Iterator iterator = collection.iterator(); while (iterator.hasNext()) { GameProfile gameprofile = (GameProfile) iterator.next(); if (gameprofilebanlist.isBanned(gameprofile)) { gameprofilebanlist.remove(gameprofile); ++i; commandlistenerwrapper.sendMessage(new ChatMessage("commands.pardon.success", new Object[]{ChatComponentUtils.a(gameprofile)}), true); } } if (i == 0) { throw CommandPardon.a.create(); } else { return i; } } }