Skip to content

Commit

Permalink
Add vote reminder broadcasts to vote party, WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCodez committed Oct 13, 2023
1 parent ea646b8 commit 2433005
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions VotingPlugin/Resources/SpecialRewards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> votePartyVoteReminderAtVotes = new ArrayList<String>();

@ConfigDataListString(path = "VoteParty.GlobalRandomCommand")
@Getter
private ArrayList<String> votePartyGlobalRandomCommand = new ArrayList<String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,30 @@ public void setVotedUsers(ArrayList<String> 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) {
if (plugin.getSpecialRewardsConfig().isVotePartyCountOfflineVotes() || user.isOnline()) {
addTotal(user);
addVotePlayer(user);
check(user, forceBungee);
checkVoteReminder();
}
}
}
Expand Down

0 comments on commit 2433005

Please sign in to comment.