Search in sources :

Example 6 with CraftItem

use of com.sx4.bot.entities.economy.item.CraftItem 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

Command (com.jockie.bot.core.command.Command)6 BotPermissions (com.sx4.bot.annotations.command.BotPermissions)6 CommandId (com.sx4.bot.annotations.command.CommandId)6 Examples (com.sx4.bot.annotations.command.Examples)6 Sx4Command (com.sx4.bot.core.Sx4Command)6 ItemStack (com.sx4.bot.entities.economy.item.ItemStack)6 PagedResult (com.sx4.bot.paged.PagedResult)6 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)6 MessageBuilder (net.dv8tion.jda.api.MessageBuilder)6 Argument (com.jockie.bot.core.argument.Argument)3 com.mongodb.client.model (com.mongodb.client.model)3 UpdateResult (com.mongodb.client.result.UpdateResult)3 AlternativeOptions (com.sx4.bot.annotations.argument.AlternativeOptions)3 DefaultNumber (com.sx4.bot.annotations.argument.DefaultNumber)3 Limit (com.sx4.bot.annotations.argument.Limit)3 ModuleCategory (com.sx4.bot.category.ModuleCategory)3 Sx4CommandEvent (com.sx4.bot.core.Sx4CommandEvent)3 Operators (com.sx4.bot.database.mongo.model.Operators)3 Alternative (com.sx4.bot.entities.argument.Alternative)3 CraftItem (com.sx4.bot.entities.economy.item.CraftItem)3