From 2f7eadd48be07213647ab7e0873dfcf41f5165aa Mon Sep 17 00:00:00 2001 From: kikelkik Date: Tue, 7 Feb 2023 22:54:36 +0100 Subject: [PATCH] add votes.one-vote-per-day option (same player can vote maximum once today) --- .../minecraft/superbvote/votes/SuperbVoteListener.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/io/minimum/minecraft/superbvote/votes/SuperbVoteListener.java b/src/main/java/io/minimum/minecraft/superbvote/votes/SuperbVoteListener.java index 6799e13..e4303a8 100644 --- a/src/main/java/io/minimum/minecraft/superbvote/votes/SuperbVoteListener.java +++ b/src/main/java/io/minimum/minecraft/superbvote/votes/SuperbVoteListener.java @@ -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; @@ -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: " +