sxcybot

Discord bot for OSRS based channels
git clone git://git.wimdupont.com/sxcybot.git
Log | Files | Refs | README | LICENSE

commit fe5c7af4a4b7bc65df70aa06de19fed00785daf2
parent 4d2018082bb926402ca78288d29721234034455d
Author: Wim Dupont <wim@wimdupont.com>
Date:   Mon, 23 May 2022 19:12:46 +0200

update deprecations and versions

Diffstat:
Msrc/main/java/com/sxcy/sxcybot/listeners/AdminCommandListener.java | 3+--
Msrc/main/java/com/sxcy/sxcybot/services/CleanuperScheduler.java | 3+--
Msrc/main/java/com/sxcy/sxcybot/services/guild/pvmrole/impl/PvmRoleSnapshotComparatorServiceImpl.java | 7+++----
3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/sxcy/sxcybot/listeners/AdminCommandListener.java b/src/main/java/com/sxcy/sxcybot/listeners/AdminCommandListener.java @@ -24,7 +24,6 @@ import javax.annotation.Nonnull; import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; import java.util.stream.Stream; @Component @@ -108,7 +107,7 @@ public class AdminCommandListener extends ListenerAdapter { private void isPrivileged(Stream<Role> roleStream, MessageReceivedEvent event, int elevation) throws InsufficientPrivilegesException { List<GuildRole> guildRoles = guildRoleService.findAllByElevationLessThanEqual(elevation); if (roleStream.noneMatch(hasPrivilage(event, guildRoles))) - throw new InsufficientPrivilegesException(guildRoles.stream().map(GuildRole::getName).collect(Collectors.toList())); + throw new InsufficientPrivilegesException(guildRoles.stream().map(GuildRole::getName).toList()); } private Predicate<Role> hasPrivilage(MessageReceivedEvent event, List<GuildRole> guildRoles) { diff --git a/src/main/java/com/sxcy/sxcybot/services/CleanuperScheduler.java b/src/main/java/com/sxcy/sxcybot/services/CleanuperScheduler.java @@ -15,7 +15,6 @@ import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.util.Comparator; import java.util.List; -import java.util.stream.Collectors; @Component @RequiredArgsConstructor @@ -48,7 +47,7 @@ public class CleanuperScheduler { pvmKcSnapshotList = pvmKcSnapshotList.stream() .sorted(Comparator.comparing(PvmKcSnapshot::getCreatedDate).reversed()) .skip(2) - .collect(Collectors.toList()); + .toList(); log.info("deleted {} from {}", pvmKcSnapshotList.size(), pvmRoleUser.getDiscordName()); pvmKcSnapshotService.deleteAll(pvmKcSnapshotList); } diff --git a/src/main/java/com/sxcy/sxcybot/services/guild/pvmrole/impl/PvmRoleSnapshotComparatorServiceImpl.java b/src/main/java/com/sxcy/sxcybot/services/guild/pvmrole/impl/PvmRoleSnapshotComparatorServiceImpl.java @@ -23,7 +23,6 @@ import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; @Slf4j @Service @@ -47,7 +46,7 @@ public class PvmRoleSnapshotComparatorServiceImpl implements PvmRoleSnapshotComp .sorted(Comparator.comparing(PvmKcSnapshot::getCreatedDate) .reversed()) .limit(persisted ? 2 : 1) - .collect(Collectors.toList()); + .toList(); for (PvmRole pvmRole : scoreBoard.keySet()) { BigDecimal points1 = calculatePoints(pvmRole, persisted ? pvmKcSnapshots.get(0) : unpersistedSnapshots.get(0)); BigDecimal points2 = calculatePoints(pvmRole, pvmKcSnapshots.get(persisted ? 1 : 0)); @@ -60,7 +59,7 @@ public class PvmRoleSnapshotComparatorServiceImpl implements PvmRoleSnapshotComp private BigDecimal calculatePoints(PvmRole pvmRole, PvmKcSnapshot pvmKcSnapshot) { BigDecimal points = BigDecimal.ZERO; - for (PvmUserKc pvmUserKc : pvmKcSnapshot.getPvmUserKcList().stream().filter(f -> pvmRole.value == f.getOsrsHiscoreBoss().getPvmRole()).collect(Collectors.toList())) { + for (PvmUserKc pvmUserKc : pvmKcSnapshot.getPvmUserKcList().stream().filter(f -> pvmRole.value == f.getOsrsHiscoreBoss().getPvmRole()).toList()) { points = points.add(BigDecimal.valueOf(pvmUserKc.getOsrsHiscoreBoss().getMultiplier()).multiply(BigDecimal.valueOf(pvmUserKc.getKc()))); } return points; @@ -75,7 +74,7 @@ public class PvmRoleSnapshotComparatorServiceImpl implements PvmRoleSnapshotComp () -> new EntityNotFoundException(String.format("No hiScores found for %s", pvmRoleUser.getRsn())) ); List<PvmUserKc> pvmUserKcList = new ArrayList<>(); - for (OsrsBossKc osrsBossKc : osrsBossKcList.stream().filter(r -> Integer.parseInt(r.getKc()) > 0).collect(Collectors.toList())) { + for (OsrsBossKc osrsBossKc : osrsBossKcList.stream().filter(r -> Integer.parseInt(r.getKc()) > 0).toList()) { try { PvmUserKc pvmUserKc = PvmUserKc.builder() .pvmRoleUser(pvmRoleUser)