From d7b2c70b787c284797933e74ecfa5bacf5fc3579 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 2 Jun 2018 21:41:27 +0200 Subject: [PATCH] Fixed unaccurate logic in PanelBuilder#nextSlot() --- .../bskyblock/api/panels/builders/PanelBuilder.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/us/tastybento/bskyblock/api/panels/builders/PanelBuilder.java b/src/main/java/us/tastybento/bskyblock/api/panels/builders/PanelBuilder.java index 2c55286cc..7ed59ec74 100644 --- a/src/main/java/us/tastybento/bskyblock/api/panels/builders/PanelBuilder.java +++ b/src/main/java/us/tastybento/bskyblock/api/panels/builders/PanelBuilder.java @@ -71,10 +71,13 @@ public class PanelBuilder { /** * Get the next free slot number - * @return next slot number + * @return next slot number, or -1 in case none has been found. */ public int nextSlot() { - return items.isEmpty() ? 0 : items.lastKey() + 1; + for (int i = 0 ; i < (size == 0 ? 54 : size) ; i++) { + if (!slotOccupied(i)) return i; + } + return -1; } /**