From 243300534ceac0bfc57fdf5d9808e1997b408287 Mon Sep 17 00:00:00 2001 From: BenCodez Date: Thu, 12 Oct 2023 20:04:02 -0400 Subject: [PATCH] Add vote reminder broadcasts to vote party, WIP --- VotingPlugin/Resources/SpecialRewards.yml | 4 ++++ .../config/SpecialRewardsConfig.java | 8 ++++++++ .../votingplugin/voteparty/VoteParty.java | 17 +++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/VotingPlugin/Resources/SpecialRewards.yml b/VotingPlugin/Resources/SpecialRewards.yml index 560a6b45a..e0dd3cd3b 100644 --- a/VotingPlugin/Resources/SpecialRewards.yml +++ b/VotingPlugin/Resources/SpecialRewards.yml @@ -93,6 +93,10 @@ VoteParty: CountOfflineVotes: true # Broadcast when vote party reached Broadcast: '&cReached the vote party amount!' + # Send a broadcast at a certain number of votes left and send a vote reminder + VoteReminderBroadcast: '%votesrequired% left to go, go vote!' + # List of votes required amounts for when to send vote party reminders + VoteReminderAtVotes: [] # List of commands to execute, these only execute once. # %player% does not work here GlobalCommands: [] diff --git a/VotingPlugin/src/com/bencodez/votingplugin/config/SpecialRewardsConfig.java b/VotingPlugin/src/com/bencodez/votingplugin/config/SpecialRewardsConfig.java index ccee9d458..d7b056782 100644 --- a/VotingPlugin/src/com/bencodez/votingplugin/config/SpecialRewardsConfig.java +++ b/VotingPlugin/src/com/bencodez/votingplugin/config/SpecialRewardsConfig.java @@ -67,6 +67,14 @@ public class SpecialRewardsConfig extends YMLFile { @Getter private boolean votePartyResetExtraVotesMonthly = false; + @ConfigDataString(path = "VoteParty.VoteReminderBroadcast") + @Getter + private String votePartyVoteReminderBroadcast = "%votesrequired% left to go, go vote!"; + + @ConfigDataListString(path = "VoteParty.VoteReminderAtVotes") + @Getter + private ArrayList votePartyVoteReminderAtVotes = new ArrayList(); + @ConfigDataListString(path = "VoteParty.GlobalRandomCommand") @Getter private ArrayList votePartyGlobalRandomCommand = new ArrayList(); diff --git a/VotingPlugin/src/com/bencodez/votingplugin/voteparty/VoteParty.java b/VotingPlugin/src/com/bencodez/votingplugin/voteparty/VoteParty.java index 2a1592268..7974ec83e 100644 --- a/VotingPlugin/src/com/bencodez/votingplugin/voteparty/VoteParty.java +++ b/VotingPlugin/src/com/bencodez/votingplugin/voteparty/VoteParty.java @@ -344,6 +344,22 @@ public void setVotedUsers(ArrayList value) { plugin.getServerData().saveData(); } + public void checkVoteReminder() { + int neededVotes = getNeededVotes(); + + for (String str : plugin.getSpecialRewardsConfig().getVotePartyVoteReminderAtVotes()) { + if (StringParser.getInstance().isInt(str)) { + int num = Integer.parseInt(str); + if (neededVotes == num) { + String broadcastMessage = plugin.getSpecialRewardsConfig().getVotePartyVoteReminderBroadcast(); + broadcastMessage = StringParser.getInstance().replacePlaceHolder(broadcastMessage, "votesrequired", + "" + neededVotes); + MiscUtils.getInstance().broadcast(broadcastMessage); + } + } + } + } + public synchronized void vote(VotingPluginUser user, boolean realVote, boolean forceBungee) { if (plugin.getSpecialRewardsConfig().isVotePartyEnabled()) { if (plugin.getSpecialRewardsConfig().isVotePartyCountFakeVotes() || realVote) { @@ -351,6 +367,7 @@ public synchronized void vote(VotingPluginUser user, boolean realVote, boolean f addTotal(user); addVotePlayer(user); check(user, forceBungee); + checkVoteReminder(); } } }