commit 57e3e7150fb9c6ee11726033cc6c2c128316ac52
parent 09d30aa67a3d9a4a4af233fa26222ac64591f3b5
Author: WimDupont <WimDupont@users.noreply.gitlab.com>
Date: Mon, 3 Jan 2022 19:02:43 +0100
PvmRole allow next in line to win role when winner's discord is not found
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/main/java/com/sxcy/sxcybot/services/guild/pvmrole/impl/PvmRoleAssignerServiceImpl.java b/src/main/java/com/sxcy/sxcybot/services/guild/pvmrole/impl/PvmRoleAssignerServiceImpl.java
@@ -46,12 +46,13 @@ public class PvmRoleAssignerServiceImpl implements PvmRoleAssignerService {
guild.loadMembers().onSuccess(memberlist -> {
long limit = 5;
int i = 1;
+ int winningRank = 1;
for (Map.Entry<PvmRoleUser, BigDecimal> entry : scoreBoard.get(pvmRole).entrySet()) {
if (limit-- == 0) break;
Optional<Member> member = memberlist.stream().filter(f -> entry.getKey().getDiscordName().equalsIgnoreCase(f.getUser().getName()) || entry.getKey().getDiscordName().equalsIgnoreCase(f.getNickname())).findFirst();
if (member.isPresent()) {
embedBuilder.addField(String.format("#%s %s", i, entry.getKey().getRsn()), String.format("%s with a score of %s!", member.get(), entry.getValue()), false);
- if (i == 1 && persist) {
+ if (i == winningRank && persist) {
Optional<Role> role = guild.getRoles().stream().filter(f -> rolename.equalsIgnoreCase(f.getName())).findFirst();
if (role.isPresent()) {
guild.findMembersWithRoles(role.get())
@@ -68,6 +69,8 @@ public class PvmRoleAssignerServiceImpl implements PvmRoleAssignerService {
}
}
} else {
+ if (i == winningRank) winningRank++;
+ embedBuilder.addField(String.format("#%s %s", i, entry.getKey().getRsn()), String.format("%s with a score of %s!", entry.getKey().getDiscordName(), entry.getValue()), false);
textChannel.sendMessage(String.format("No guildmember found for discordname %s. User did not receive any awards.", entry.getKey().getDiscordName())).queue();
}
i++;