Skip to content

Commit

Permalink
add votes.one-vote-per-day option (same player can vote maximum once …
Browse files Browse the repository at this point in the history
…today)
  • Loading branch information
kikelkik committed Feb 7, 2023
1 parent 2fa2ab9 commit 2f7eadd
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.vexsoftware.votifier.model.VotifierEvent;
import io.minimum.minecraft.superbvote.SuperbVote;
import io.minimum.minecraft.superbvote.commands.SuperbVoteCommand;
import io.minimum.minecraft.superbvote.configuration.SuperbVoteConfiguration;
import io.minimum.minecraft.superbvote.configuration.message.MessageContext;
import io.minimum.minecraft.superbvote.signboard.TopPlayerSignFetcher;
import io.minimum.minecraft.superbvote.storage.MysqlVoteStorage;
Expand Down Expand Up @@ -88,6 +89,14 @@ private void processVote(PlayerVotes pv, VoteStreak voteStreak, Vote vote, boole
throw new RuntimeException("No vote rewards found for '" + vote + "'");
}

boolean hasAlreadyVoted = SuperbVote.getPlugin()
.getVoteStorage()
.hasVotedToday(vote.getUuid()); // TODO: use getVotes(vote.getReceived()) and add lastVote to PlayerVotes
if (hasAlreadyVoted && SuperbVote.getPlugin().getConfig().getBoolean("votes.one-vote-per-day")) {
Date todoReplace = new Date(); // TODO: replace with lastVote date
SuperbVote.getPlugin().getLogger().log(Level.INFO, "Discarding vote: " + vote.getName() + " already voted the same day at " + todoReplace);
return;
}
if (queue) {
if (!SuperbVote.getPlugin().getConfiguration().shouldQueueVotes()) {
SuperbVote.getPlugin().getLogger().log(Level.WARNING, "Ignoring vote from " + vote.getName() + " (service: " +
Expand Down

0 comments on commit 2f7eadd

Please sign in to comment.