From 360e48d0aefec7660e2b9af8673efea33cce13f5 Mon Sep 17 00:00:00 2001 From: NicBOMB <19939315+NicBOMB@users.noreply.github.com> Date: Sun, 10 Jul 2022 16:48:32 -0700 Subject: [PATCH] fix out of bounds error throwing for ranksgui --- src/main/java/sh/okx/rankup/ranksgui/RanksGui.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/sh/okx/rankup/ranksgui/RanksGui.java b/src/main/java/sh/okx/rankup/ranksgui/RanksGui.java index c792865..e713187 100644 --- a/src/main/java/sh/okx/rankup/ranksgui/RanksGui.java +++ b/src/main/java/sh/okx/rankup/ranksgui/RanksGui.java @@ -63,12 +63,11 @@ public void open() { RankElement 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; }