Search in sources :

Example 11 with ItemStack

use of com.sx4.bot.entities.economy.item.ItemStack in project Sx4 by sx4-discord-bot.

the class PickaxeCommand method shop.

@Command(value = "shop", description = "View all the pickaxes you are able to buy or craft")
@CommandId(360)
@Examples({ "pickaxe shop" })
@BotPermissions(permissions = { Permission.MESSAGE_EMBED_LINKS })
public void shop(Sx4CommandEvent event) {
    List<Pickaxe> pickaxes = event.getBot().getEconomyManager().getItems(Pickaxe.class);
    PagedResult<Pickaxe> paged = new PagedResult<>(event.getBot(), pickaxes).setPerPage(12).setCustomFunction(page -> {
        EmbedBuilder embed = new EmbedBuilder().setAuthor("Pickaxe Shop", null, event.getSelfUser().getEffectiveAvatarUrl()).setTitle("Page " + page.getPage() + "/" + page.getMaxPage()).setDescription("Pickaxes are a good way to gain some extra money aswell as some materials").setFooter(PagedResult.DEFAULT_FOOTER_TEXT);
        page.forEach((pickaxe, index) -> {
            List<ItemStack<CraftItem>> items = pickaxe.getCraft();
            String craft = items.isEmpty() ? "None" : items.stream().map(ItemStack::toString).collect(Collectors.joining("\n"));
            embed.addField(pickaxe.getName(), String.format("Price: $%,d\nCraft: %s\nDurability: %,d", pickaxe.getPrice(), craft, pickaxe.getMaxDurability()), true);
        });
        return new MessageBuilder().setEmbeds(embed.build());
    });
    paged.execute(event);
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) MessageBuilder(net.dv8tion.jda.api.MessageBuilder) Pickaxe(com.sx4.bot.entities.economy.item.Pickaxe) ItemStack(com.sx4.bot.entities.economy.item.ItemStack) PagedResult(com.sx4.bot.paged.PagedResult) BotPermissions(com.sx4.bot.annotations.command.BotPermissions) Command(com.jockie.bot.core.command.Command) Sx4Command(com.sx4.bot.core.Sx4Command) CommandId(com.sx4.bot.annotations.command.CommandId) Examples(com.sx4.bot.annotations.command.Examples)

Aggregations

EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)11 Sx4Command (com.sx4.bot.core.Sx4Command)10 Command (com.jockie.bot.core.command.Command)7 CommandId (com.sx4.bot.annotations.command.CommandId)7 Examples (com.sx4.bot.annotations.command.Examples)7 Document (org.bson.Document)7 Bson (org.bson.conversions.Bson)7 BotPermissions (com.sx4.bot.annotations.command.BotPermissions)6 ItemStack (com.sx4.bot.entities.economy.item.ItemStack)6 PagedResult (com.sx4.bot.paged.PagedResult)6 MessageBuilder (net.dv8tion.jda.api.MessageBuilder)6 ModuleCategory (com.sx4.bot.category.ModuleCategory)5 Sx4CommandEvent (com.sx4.bot.core.Sx4CommandEvent)5 Operators (com.sx4.bot.database.mongo.model.Operators)5 EconomyUtility (com.sx4.bot.utility.EconomyUtility)5 ExceptionUtility (com.sx4.bot.utility.ExceptionUtility)5 Permission (net.dv8tion.jda.api.Permission)5 Filters (com.mongodb.client.model.Filters)4 UpdateOptions (com.mongodb.client.model.UpdateOptions)4 List (java.util.List)4