Search in sources :

Example 1 with Hamburger

use of gartham.c10ver.economy.items.utility.foodstuffs.Hamburger in project c10ver by Gartham.

the class VoteManager method handleVoteRoleAdded.

public void handleVoteRoleAdded(Member member) {
    Instant voteTime = Instant.now();
    List<ItemBunch<?>> items = new ArrayList<>();
    items.add(new ItemBunch<>(new WeeklyCrate(), Math.random() > 0.5 ? 3 : 2));
    if (Math.random() > 0.5)
        items.add(new ItemBunch<>(new MonthlyCrate()));
    if (Math.random() > 0.95)
        items.add(new ItemBunch<>(new DailyCrate(), 50));
    items.add(new ItemBunch<>(new NormalCrate(), (long) (Math.random() * 5 + 3)));
    items.add(new ItemBunch<>(new Pizza(), (long) (Math.random() * 5 + 3)));
    items.add(new ItemBunch<>(new Sandwich(), (long) (Math.random() * 7 + 3)));
    items.add(new ItemBunch<>(new Hamburger(), (long) (Math.random() * 2 + 4)));
    items.add(new ItemBunch<>(new VoteToken(Type.NORMAL), 5));
    Map<AbstractMultiplier, Integer> multipliers = new HashMap<>();
    if (Math.random() > 0.2)
        multipliers.put(AbstractMultiplier.ofHr(12, BigDecimal.valueOf(2, 1)), 1);
    if (Math.random() > 0.3)
        multipliers.put(AbstractMultiplier.ofHr(12, BigDecimal.valueOf(3, 1)), 1);
    if (Math.random() > 0.5)
        multipliers.put(AbstractMultiplier.ofHr(12, BigDecimal.valueOf(5, 1)), 1);
    EconomyUser u = clover.getEconomy().getUser(member.getId());
    u.incrementVoteCount();
    var rec = u.reward(RewardsOperation.build(u, member.getGuild(), BigInteger.valueOf((long) (Math.random() * 3000 + 5000)), multipliers, items));
    var s = clover.getEconomy().getServer(member.getGuild().getId());
    EmbedBuilder embed = new EmbedBuilder().setAuthor(member.getUser().getAsTag() + " just voted!", null, member.getUser().getEffectiveAvatarUrl()).setDescription(member.getUser().getAsMention() + " just voted and received:\n" + Utilities.listRewards(rec) + "\n\nYou can [vote on top.gg by clicking me](https://top.gg/servers/" + member.getGuild().getId() + "/vote).");
    MessageChannel channel = s.getVoteChannel() != null ? member.getGuild().getTextChannelById(s.getVoteChannel()) : member.getUser().openPrivateChannel().complete();
    if (u.getSettings().isVoteRemindersEnabled()) {
        scheduleReminder(member, s, voteTime);
        channel.sendMessageEmbeds(embed.setFooter("----> You currently have vote reminders enabled. Disable them with: ~settings vr false <----").build()).queue();
    } else
        channel.sendMessageEmbeds(embed.setFooter("You can automatically be reminded when it's time to vote by reacting to this message! (Click the alarm clock.)").build()).queue((Consumer<? super Message>) t -> {
            t.addReaction("\u23F0").queue();
            clover.getEventHandler().getReactionAdditionProcessor().registerInputConsumer(((MessageReactionInputConsumer<MessageReactionAddEvent>) (event, b, consumer) -> {
                if (event.getReactionEmote().isEmoji() && event.getReactionEmote().getEmoji().equals("\u23F0")) {
                    clover.getEventHandler().getReactionAdditionProcessor().removeInputConsumer(consumer);
                    channel.sendMessage(member.getAsMention() + " vote reminders are now enabled for you! To turn them off, run the command: `~settings vr false`.").queue();
                    scheduleReminder(member, s, voteTime);
                    setVotingRemindersEnabled(u, s.getServerID(), true);
                    return true;
                } else
                    return false;
            }).expires(Instant.now().plusSeconds(180)).filter(member.getUser(), channel));
        });
}
Also used : Message(net.dv8tion.jda.api.entities.Message) HashMap(java.util.HashMap) DailyCrate(gartham.c10ver.economy.items.utility.crates.DailyCrate) Instant(java.time.Instant) ArrayList(java.util.ArrayList) Pizza(gartham.c10ver.economy.items.utility.foodstuffs.Pizza) Sandwich(gartham.c10ver.economy.items.utility.foodstuffs.Sandwich) Hamburger(gartham.c10ver.economy.items.utility.foodstuffs.Hamburger) VoteToken(gartham.c10ver.economy.items.valuables.VoteToken) BigInteger(java.math.BigInteger) MessageReactionInputConsumer(gartham.c10ver.commands.consumers.MessageReactionInputConsumer) NormalCrate(gartham.c10ver.economy.items.utility.crates.NormalCrate) WeeklyCrate(gartham.c10ver.economy.items.utility.crates.WeeklyCrate) MonthlyCrate(gartham.c10ver.economy.items.utility.crates.MonthlyCrate) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) EconomyUser(gartham.c10ver.economy.users.EconomyUser) MessageChannel(net.dv8tion.jda.api.entities.MessageChannel) MessageReactionInputConsumer(gartham.c10ver.commands.consumers.MessageReactionInputConsumer) Consumer(java.util.function.Consumer) ItemBunch(gartham.c10ver.economy.items.ItemBunch) AbstractMultiplier(gartham.c10ver.economy.AbstractMultiplier)

Example 2 with Hamburger

use of gartham.c10ver.economy.items.utility.foodstuffs.Hamburger in project c10ver by Gartham.

the class MonthlyCrate method open.

@Override
public RewardsOperation open() {
    List<ItemBunch<?>> items = new ArrayList<>();
    double rand = Math.random();
    items.add(new ItemBunch<>(new Hamburger(), BigInteger.valueOf((long) (rand * 3 + 1))));
    if (Math.random() < 0.2)
        items.add(new ItemBunch<>(new Pizza()));
    if (Math.random() < 0.15)
        items.add(new ItemBunch<>(new DailyCrate(), BigInteger.valueOf((long) (Math.random() * 3 + 1))));
    if (Math.random() < 0.1)
        items.add(new ItemBunch<>(new MonthlyCrate()));
    return new RewardsOperation().with(BigInteger.valueOf((long) (Math.random() * 800 + 450))).with(items);
}
Also used : Hamburger(gartham.c10ver.economy.items.utility.foodstuffs.Hamburger) Pizza(gartham.c10ver.economy.items.utility.foodstuffs.Pizza) ItemBunch(gartham.c10ver.economy.items.ItemBunch) RewardsOperation(gartham.c10ver.economy.RewardsOperation) ArrayList(java.util.ArrayList)

Aggregations

ItemBunch (gartham.c10ver.economy.items.ItemBunch)2 Hamburger (gartham.c10ver.economy.items.utility.foodstuffs.Hamburger)2 Pizza (gartham.c10ver.economy.items.utility.foodstuffs.Pizza)2 ArrayList (java.util.ArrayList)2 MessageReactionInputConsumer (gartham.c10ver.commands.consumers.MessageReactionInputConsumer)1 AbstractMultiplier (gartham.c10ver.economy.AbstractMultiplier)1 RewardsOperation (gartham.c10ver.economy.RewardsOperation)1 DailyCrate (gartham.c10ver.economy.items.utility.crates.DailyCrate)1 MonthlyCrate (gartham.c10ver.economy.items.utility.crates.MonthlyCrate)1 NormalCrate (gartham.c10ver.economy.items.utility.crates.NormalCrate)1 WeeklyCrate (gartham.c10ver.economy.items.utility.crates.WeeklyCrate)1 Sandwich (gartham.c10ver.economy.items.utility.foodstuffs.Sandwich)1 VoteToken (gartham.c10ver.economy.items.valuables.VoteToken)1 EconomyUser (gartham.c10ver.economy.users.EconomyUser)1 BigInteger (java.math.BigInteger)1 Instant (java.time.Instant)1 HashMap (java.util.HashMap)1 Consumer (java.util.function.Consumer)1 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)1 Message (net.dv8tion.jda.api.entities.Message)1