40 lines
1.5 KiB
Java
40 lines
1.5 KiB
Java
package cc.fascinated.vote;
|
|
|
|
import cc.fascinated.account.Account;
|
|
import cc.fascinated.bot.DiscordBot;
|
|
import cc.fascinated.bot.DiscordChannel;
|
|
import cc.fascinated.config.Lang;
|
|
import cc.fascinated.playercolor.PlayerColorProfile;
|
|
import cc.fascinated.utils.Manager;
|
|
import cc.fascinated.utils.MessageUtils;
|
|
import com.vexsoftware.votifier.model.VotifierEvent;
|
|
import net.dv8tion.jda.api.EmbedBuilder;
|
|
|
|
import java.awt.*;
|
|
|
|
public class VoteManager extends Manager {
|
|
|
|
@Override
|
|
public void onVote(Account account, VotifierEvent event) {
|
|
VoteProfile voteProfile = account.getVoteProfile();
|
|
PlayerColorProfile playerColorProfile = account.getPlayerColorProfile();
|
|
voteProfile.addVote(); // Add the vote to the player's profile
|
|
|
|
MessageUtils.broadcast(Lang.VOTE_BROADCAST.getAsString()
|
|
.replace("%player%", account.getPlayer().getName())
|
|
.replace("player-color", playerColorProfile.getColor().toString())
|
|
);
|
|
account.sendMessage(Lang.VOTE_VOTED.getAsString()
|
|
.replace("%votes%", voteProfile.getTotalVotes() + "")
|
|
);
|
|
|
|
DiscordBot.sendEmbed(DiscordChannel.VOTE_LOGS, new EmbedBuilder()
|
|
.setThumbnail("https://mc.fascinated.cc/player/head/" + account.getUuid().toString())
|
|
.setTitle("Player Voted")
|
|
.setColor(Color.GREEN)
|
|
.addField("Player", account.getPlayer().getName(), true)
|
|
.addField("Votes", voteProfile.getTotalVotes() + "", true)
|
|
);
|
|
}
|
|
}
|