Skip to content

Commit 02b8d01

Browse files
authored
Merge pull request #1520 from semisolar/feature/votestreak-shared-progress-only
Add shared VoteStreaks progress groups
2 parents 6e6986a + 2193fa4 commit 02b8d01

4 files changed

Lines changed: 427 additions & 26 deletions

File tree

VotingPlugin/src/main/java/com/bencodez/votingplugin/commands/CommandLoader.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,9 +938,9 @@ public void execute(CommandSender sender, String[] args) {
938938
}
939939

940940
if (plugin.getVoteStreakHandler().resetVoteStreak(user, target)) {
941-
sendMessage(sender, "&cReset VoteStreak '" + target + "' for '" + args[1] + "'");
941+
sendMessage(sender, "&cReset VoteStreak state '" + target + "' for '" + args[1] + "'");
942942
} else {
943-
sendMessage(sender, "&cVoteStreak not found: &e" + target);
943+
sendMessage(sender, "&cVoteStreak or progress group not found: &e" + target);
944944
}
945945
}
946946
});
@@ -2826,6 +2826,7 @@ public void updateReplacements() {
28262826
for (VoteStreakDefinition def : plugin.getVoteStreakHandler().getDefinitions()) {
28272827
voteStreaks.add(def.getId());
28282828
}
2829+
voteStreaks.addAll(plugin.getVoteStreakHandler().getProgressGroups());
28292830

28302831
TabCompleteHandler.getInstance().addTabCompleteOption(new TabCompleteHandle("(votestreak)", voteStreaks) {
28312832

@@ -2835,6 +2836,7 @@ public void reload() {
28352836
for (VoteStreakDefinition def : plugin.getVoteStreakHandler().getDefinitions()) {
28362837
voteStreaks.add(def.getId());
28372838
}
2839+
voteStreaks.addAll(plugin.getVoteStreakHandler().getProgressGroups());
28382840
setReplace(voteStreaks);
28392841
}
28402842

VotingPlugin/src/main/java/com/bencodez/votingplugin/specialrewards/votestreak/VoteStreakDefinition.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,25 @@ public final class VoteStreakDefinition {
2323

2424
@Getter
2525
private final boolean recurring;
26+
@Getter
27+
private final String progressGroup;
28+
@Getter
29+
private final String rewardPath;
2630

2731
public VoteStreakDefinition(String id, VoteStreakType type, boolean enabled, int requiredAmount, int votesRequired,
2832
int allowMissedAmount, int allowMissedPeriod, boolean recurring) {
33+
this(id, type, enabled, requiredAmount, votesRequired, allowMissedAmount, allowMissedPeriod, recurring, "",
34+
"VoteStreaks." + id + ".Rewards");
35+
}
36+
37+
public VoteStreakDefinition(String id, VoteStreakType type, boolean enabled, int requiredAmount, int votesRequired,
38+
int allowMissedAmount, int allowMissedPeriod, boolean recurring, String progressGroup) {
39+
this(id, type, enabled, requiredAmount, votesRequired, allowMissedAmount, allowMissedPeriod, recurring,
40+
progressGroup, "VoteStreaks." + id + ".Rewards");
41+
}
42+
43+
public VoteStreakDefinition(String id, VoteStreakType type, boolean enabled, int requiredAmount, int votesRequired,
44+
int allowMissedAmount, int allowMissedPeriod, boolean recurring, String progressGroup, String rewardPath) {
2945
this.id = id;
3046
this.type = type;
3147
this.enabled = enabled;
@@ -34,6 +50,9 @@ public VoteStreakDefinition(String id, VoteStreakType type, boolean enabled, int
3450
this.allowMissedPeriod = Math.max(0, allowMissedPeriod);
3551
this.votesRequired = Math.max(1, votesRequired);
3652
this.recurring = recurring;
53+
this.progressGroup = progressGroup == null ? "" : progressGroup.trim();
54+
this.rewardPath = rewardPath == null || rewardPath.trim().isEmpty() ? "VoteStreaks." + id + ".Rewards"
55+
: rewardPath.trim();
3756
}
3857

3958
}

0 commit comments

Comments
 (0)