From 58c69227d0d0d254fd3dbcd5a6c381383ad0d872 Mon Sep 17 00:00:00 2001 From: Fulminazzo Date: Thu, 11 Apr 2024 23:46:49 +0200 Subject: [PATCH] Fixed addContent methods --- gui/base/src/main/java/it/angrybear/yagl/guis/GUIImpl.java | 2 +- .../src/main/java/it/angrybear/yagl/guis/ResizableGUI.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/base/src/main/java/it/angrybear/yagl/guis/GUIImpl.java b/gui/base/src/main/java/it/angrybear/yagl/guis/GUIImpl.java index acc42522..b049d6ec 100644 --- a/gui/base/src/main/java/it/angrybear/yagl/guis/GUIImpl.java +++ b/gui/base/src/main/java/it/angrybear/yagl/guis/GUIImpl.java @@ -74,7 +74,7 @@ public boolean isMovable(int slot) { int j = 0; for (int i = 0; i < contents.length; i++) { j = addSingle(contents[i], j); - if (j == -1) + if (j >= size()) throw new IllegalArgumentException(String.format("Could not set content at index %s because contents are already full", i)); } return this; diff --git a/gui/base/src/main/java/it/angrybear/yagl/guis/ResizableGUI.java b/gui/base/src/main/java/it/angrybear/yagl/guis/ResizableGUI.java index 0239a898..c94fd72d 100644 --- a/gui/base/src/main/java/it/angrybear/yagl/guis/ResizableGUI.java +++ b/gui/base/src/main/java/it/angrybear/yagl/guis/ResizableGUI.java @@ -1,8 +1,8 @@ package it.angrybear.yagl.guis; -import org.jetbrains.annotations.NotNull; import it.angrybear.yagl.contents.GUIContent; +import org.jetbrains.annotations.NotNull; /** * Represents a "chest" GUI that can be resized. @@ -39,7 +39,7 @@ public ResizableGUI(int size) { for (int i = 0; i < contents.length; i++) { GUIContent content = contents[i]; j = addSingle(content, j); - if (j != -1) continue; + if (j < size()) continue; if (size() < MAX_SIZE) { resize(size() + 9); this.contents.set(j, new Contents(content));