1
0
Files
aetheria-anarchy-plugin/src/main/java/cc/fascinated/vote/VoteManager.java

40 lines
1.5 KiB
Java
Raw Normal View History

2024-04-05 17:04:19 +01:00
package cc.fascinated.vote;
import cc.fascinated.account.Account;
2024-04-05 20:30:29 +01:00
import cc.fascinated.bot.DiscordBot;
import cc.fascinated.bot.DiscordChannel;
2024-04-05 17:04:19 +01:00
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;
2024-04-05 20:30:29 +01:00
import net.dv8tion.jda.api.EmbedBuilder;
import java.awt.*;
2024-04-05 17:04:19 +01:00
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() + "")
);
2024-04-05 20:30:29 +01:00
DiscordBot.sendEmbed(DiscordChannel.VOTE_LOGS, new EmbedBuilder()
.setThumbnail("https://mc.fascinated.cc/player/head/" + account.getUuid().toString())
2024-04-05 20:30:29 +01:00
.setTitle("Player Voted")
.setColor(Color.GREEN)
.addField("Player", account.getPlayer().getName(), true)
.addField("Votes", voteProfile.getTotalVotes() + "", true)
);
2024-04-05 17:04:19 +01:00
}
}