Skip to content

Commit

Permalink
Fixed a potential out of bounds error using getIslandAtPosition method (
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Jun 23, 2022
1 parent 24c60f5 commit 39676eb
Showing 1 changed file with 2 additions and 6 deletions.
Expand Up @@ -4,8 +4,8 @@
import com.bgsoftware.superiorskyblock.api.island.Island;
import com.bgsoftware.superiorskyblock.api.island.SortingType;
import com.bgsoftware.superiorskyblock.api.island.container.IslandsContainer;
import com.bgsoftware.superiorskyblock.core.threads.BukkitExecutor;
import com.bgsoftware.superiorskyblock.core.IslandPosition;
import com.bgsoftware.superiorskyblock.core.threads.BukkitExecutor;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -85,13 +85,9 @@ public Island getIslandByUUID(UUID uuid) {
public Island getIslandAtPosition(int position, SortingType sortingType) {
ensureSortingType(sortingType);

if (position < 0 || position > getIslandsAmount()) {
return null;
}

Set<Island> sortedIslands = this.sortedIslands.get(sortingType);

return Iterables.get(sortedIslands, position);
return position < 0 || position > sortedIslands.size() ? null : Iterables.get(sortedIslands, position);
}

@Override
Expand Down

0 comments on commit 39676eb

Please sign in to comment.