Skip to content

Commit

Permalink
fix out of bounds error throwing for ranksgui
Browse files Browse the repository at this point in the history
  • Loading branch information
NicBOMB committed Oct 26, 2022
1 parent 9241c45 commit 360e48d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/java/sh/okx/rankup/ranksgui/RanksGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ public void open() {

RankElement<Rank> rankElement0 = rankElement;
ItemStack item = get((section, path0) -> Gui.getItem(plugin, section.getConfigurationSection(path0), player, rankElement0), path, rankPath, basePath, null);

inventory.setItem(index++, item);
if (index > rows * 9) {
throw new IllegalArgumentException("Ranks GUI is too small for the number of ranks. Increase the number of rows on the ranks GUI.");
if (index > rows * width - offset) {
throw new IllegalArgumentException("Ranks GUI is set to " + (rows * width - offset) + ", which is too small for " + index + " ranks. Set a larger valid ranks GUI.");
}
if (index == rowIndex) {
inventory.setItem(index, item);
if (++index == rowIndex) {
rowIndex += 9;
index += 9 - width;
}
Expand Down

0 comments on commit 360e48d

Please sign in to comment.