Skip to content

Commit 5d9b5b7

Browse files
committed
Add configurable titles and rank display for DiscordSRV top voters
1 parent d26d61a commit 5d9b5b7

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

VotingPlugin/src/main/java/com/bencodez/votingplugin/config/Config.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ public class Config extends YMLFile {
8080
@Getter
8181
private long discordSRVTopVoterChannel = 0;
8282

83+
@ConfigDataString(path = "DiscordSRV.TopVoter.Title")
84+
@Getter
85+
private String discordSRVTopVoterTitle = "&3Top Voters of the Month";
86+
87+
@ConfigDataString(path = "DiscordSRV.TopVoter.RankDisplay")
88+
@Getter
89+
private String discordSRVTopVoterRankDisplay = "&c%rank%: &6%player% - %votes% Votes";
90+
8391
@ConfigDataBoolean(path = "AllowUnJoinedCheckServer")
8492
@Getter
8593
private boolean allowUnJoinedCheckServer = true;

VotingPlugin/src/main/java/com/bencodez/votingplugin/discord/DiscordHandler.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,20 @@ public void updateDiscordLeaderboard() {
8383
long channelId = plugin.getConfigFile().getDiscordSRVTopVoterChannel();
8484
LinkedHashMap<TopVoterPlayer, Integer> topVoters = plugin.getTopVoter(TopVoter.Monthly);
8585

86-
EmbedBuilder eb = new EmbedBuilder().setTitle("Top Voters This Month").setColor(Color.CYAN)
87-
.setTimestamp(Instant.now());
86+
String title = plugin.getConfigFile().getDiscordSRVTopVoterTitle();
87+
String rankDisplay = plugin.getConfigFile().getDiscordSRVTopVoterRankDisplay();
88+
89+
EmbedBuilder eb = new EmbedBuilder().setTitle(title).setColor(Color.CYAN).setTimestamp(Instant.now());
8890

8991
int rank = 1;
9092
for (Entry<TopVoterPlayer, Integer> entry : topVoters.entrySet()) {
9193
if (rank > 10)
9294
break;
93-
eb.addField("#" + rank++ + " " + entry.getKey().getPlayerName(), entry.getValue().intValue() + " votes",
94-
false);
95+
String line = rankDisplay.replace("%rank%", String.valueOf(rank))
96+
.replace("%player%", entry.getKey().getPlayerName())
97+
.replace("%votes%", String.valueOf(entry.getValue()));
98+
eb.addField("", line, false);
99+
rank++;
95100
}
96101

97102
TextChannel channel = DiscordUtil.getJda().getTextChannelById(channelId);

VotingPlugin/src/main/resources/Config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,10 @@ DiscordSRV:
628628
Enabled: false
629629

630630
# DiscordSRV channel to send messages to
631-
Channel: 1234565 # Replace with your channel ID
631+
Channel: 1234565 # Replace with your channel ID
632+
633+
Title: '&3Top Voters of the Month'
634+
RankDisplay: '&c%rank%: &6%player% - %votes% Votes'
632635

633636

634637

0 commit comments

Comments
 (0)