Skip to content

Commit 7c0d135

Browse files
committed
fix out of bounds error throwing for ranksgui
1 parent bdb8d8e commit 7c0d135

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/main/java/sh/okx/rankup/ranksgui/RanksGui.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,11 @@ public void open() {
6363

6464
RankElement<Rank> rankElement0 = rankElement;
6565
ItemStack item = get((section, path0) -> Gui.getItem(plugin, section.getConfigurationSection(path0), player, rankElement0), path, rankPath, basePath, null);
66-
67-
inventory.setItem(index++, item);
68-
if (index > rows * 9) {
69-
throw new IllegalArgumentException("Ranks GUI is too small for the number of ranks. Increase the number of rows on the ranks GUI.");
66+
if (index > rows * width - offset) {
67+
throw new IllegalArgumentException("Ranks GUI is set to " + (rows * width - offset) + ", which is too small for " + index + " ranks. Set a larger valid ranks GUI.");
7068
}
71-
if (index == rowIndex) {
69+
inventory.setItem(index, item);
70+
if (++index == rowIndex) {
7271
rowIndex += 9;
7372
index += 9 - width;
7473
}

0 commit comments

Comments
 (0)