Fix Unhandled exception when executing command is top

During early game if there are less then 10 islands the IntStream.range fails. We add Math.min to either select the amount of islands available or a top of 10.
This commit is contained in:
Len 2024-03-09 10:19:01 +01:00
parent 49c5cc94c1
commit 875d770742

View File

@ -27,7 +27,7 @@ public class IslandTop extends PlayerSubCommand {
//TODO allow players to iterate through the list
List<IslandData> islandData = IslandData.getIslandData(pluginConfiguration.topRefreshMinutesCoolDown());
String islandRankings = IntStream.range(0, 10)
String islandRankings = IntStream.range(0, Math.min(10, islandData.size()))
.mapToObj(i -> (i + 1) + ". " + islandData.get(i).format(playerIslandId))
.collect(Collectors.joining("\n"));