Skip to content

Commit

Permalink
Add new placeholder for number of votes since last milestone
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCodez committed Nov 24, 2024
1 parent dad0f88 commit 5b19d33
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,18 @@ public String placeholderRequest(VotingPluginUser user, String identifier) {
}
}.withDescription("Get number of votes until next available milestone").updateDataKey("MilestoneCount"));

placeholders.add(new PlaceHolder<VotingPluginUser>("lastmilestone_votes_since") {

@Override
public String placeholderRequest(VotingPluginUser user, String identifier) {
int toGo = user.getMilestoneCount() - user.getLastGottenMilestone();
if (toGo >= 0) {
return "" + toGo;
}
return "0";
}
}.withDescription("Get number of votes since last milestone").updateDataKey("MilestoneCount"));

for (final String identifier : plugin.getShopFile().getShopIdentifiers()) {
if (plugin.getShopFile().getShopIdentifierLimit(identifier) > 0) {
placeholders.add(new PlaceHolder<VotingPluginUser>("VoteShopLimit_" + identifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,33 @@ public int getNextAvailableMileStone() {

}

public int getLastGottenMilestone() {
Set<String> mVotes = plugin.getSpecialRewardsConfig().getMilestoneVotes();
ArrayList<Integer> nums = new ArrayList<Integer>();
int mileStoneCount = getMilestoneCount();
for (String vote : mVotes) {
if (MessageAPI.isInt(vote)) {
final int num = Integer.parseInt(vote);
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(num)) {
nums.add(Integer.valueOf(num));
}
}
}

int highestNum = -1;

for (Integer num : nums) {
if (mileStoneCount > num.intValue()) {
if (highestNum == -1 || num.intValue() > highestNum) {
highestNum = num.intValue();
}
}
}

return highestNum;

}

public void setReminded(boolean reminded) {
getUserData().setString("Reminded", "" + reminded);
}
Expand Down

0 comments on commit 5b19d33

Please sign in to comment.