package org.royaldev.thehumanity.commands.impl.game.subcommands; import com.google.common.base.Joiner; import org.jetbrains.annotations.NotNull; import org.kitteh.irc.client.library.util.Format; import org.kitteh.irc.client.library.element.User; import org.kitteh.irc.client.library.event.channel.ChannelMessageEvent; import org.royaldev.thehumanity.TheHumanity; import org.royaldev.thehumanity.cards.packs.CAHCardPack; import org.royaldev.thehumanity.commands.InGameCommand; import org.royaldev.thehumanity.game.TheHumanityGame; import org.royaldev.thehumanity.player.TheHumanityPlayer; import org.royaldev.thehumanity.util.ConversionHelper; import xyz.cardstock.cardstock.commands.CallInfo; import xyz.cardstock.cardstock.commands.Command; import java.util.List; @Command( name = "addpack", description = "Adds a card pack to the current game.", aliases = {"ap"} ) public class AddPackSubcommand extends InGameCommand { public AddPackSubcommand(final TheHumanity instance) { super(instance); } @Override public void run(@NotNull ChannelMessageEvent event, @NotNull CallInfo callInfo, @NotNull TheHumanityGame game, @NotNull TheHumanityPlayer player, @NotNull List<String> arguments) { final User u = player.getUser(); if (!game.getHost().equals(player) && !this.humanity.hasChannelMode(game.getChannel(), u, 'o')) { u.sendNotice("You are not an op or the host!"); return; } if (arguments.size() < 1) { u.sendNotice("Not enough arguments."); return; } final CAHCardPack cp = this.humanity.getOrDownloadCardPack(Joiner.on(' ').join(arguments)); if (cp == null) { u.sendNotice("No such card pack."); return; } ConversionHelper.respond(event, (game.addCardPack(cp) ? "Added" : "Could not add") + " " + Format.BOLD + cp.getName() + Format.RESET + " to the game."); } }