Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void applyLayout(ItemStack[] itemStacks, @Nullable Locale locale) {
*/
@Override
public InventoryLayoutImpl setItem(int slot, ItemStack.Builder itemBuilder, @Nullable InventoryClick clickEvent) {
Check.argCondition(slot < 0 || slot > contents.length, INDEX_ERROR);
Check.argCondition(slot < 0 || slot >= contents.length, INDEX_ERROR);
this.contents[slot] = new InventorySlot(itemBuilder, clickEvent);
return this;
}
Expand All @@ -110,7 +110,7 @@ public InventoryLayoutImpl setItem(int slot, ItemStack.Builder itemBuilder, @Nul
*/
@Override
public InventoryLayoutImpl setItem(int slot, ItemStack itemStack, @Nullable InventoryClick clickEvent) {
Check.argCondition(slot < 0 || slot > contents.length, INDEX_ERROR);
Check.argCondition(slot < 0 || slot >= contents.length, INDEX_ERROR);
this.contents[slot] = new InventorySlot(itemStack, clickEvent);
return this;
}
Expand All @@ -120,7 +120,7 @@ public InventoryLayoutImpl setItem(int slot, ItemStack itemStack, @Nullable Inve
*/
@Override
public InventoryLayoutImpl setItem(int slot, ISlot iSlot, InventoryClick clickEvent) {
Check.argCondition(slot < 0 || slot > contents.length, INDEX_ERROR);
Check.argCondition(slot < 0 || slot >= contents.length, INDEX_ERROR);
iSlot.setClick(clickEvent);
contents[slot] = iSlot;
return this;
Expand All @@ -131,7 +131,7 @@ public InventoryLayoutImpl setItem(int slot, ISlot iSlot, InventoryClick clickEv
*/
@Override
public InventoryLayoutImpl setItem(int slot, ISlot slotItem) {
Check.argCondition(slot < 0 || slot > contents.length, INDEX_ERROR);
Check.argCondition(slot < 0 || slot >= contents.length, INDEX_ERROR);
contents[slot] = slotItem;
return this;
}
Expand All @@ -141,7 +141,7 @@ public InventoryLayoutImpl setItem(int slot, ISlot slotItem) {
*/
@Override
public InventoryLayoutImpl blank(int slot) {
Check.argCondition(slot < 0 || slot > contents.length, INDEX_ERROR);
Check.argCondition(slot < 0 || slot >= contents.length, INDEX_ERROR);
this.contents[slot] = BLANK_SLOT;
return this;
}
Expand All @@ -151,7 +151,7 @@ public InventoryLayoutImpl blank(int slot) {
*/
@Override
public InventoryLayoutImpl clear(int slot) {
Check.argCondition(slot < 0 || slot > contents.length, INDEX_ERROR);
Check.argCondition(slot < 0 || slot >= contents.length, INDEX_ERROR);
contents[slot] = BLANK_SLOT;
return this;
}
Expand All @@ -161,7 +161,7 @@ public InventoryLayoutImpl clear(int slot) {
*/
@Override
public InventoryLayoutImpl update(int index, @Nullable InventoryClick listener) {
Check.argCondition(index < 0 || index > contents.length, INDEX_ERROR);
Check.argCondition(index < 0 || index >= contents.length, INDEX_ERROR);
contents[index].setClick(listener == null ? CANCEL_CLICK : listener);
return this;
}
Expand All @@ -171,7 +171,7 @@ public InventoryLayoutImpl update(int index, @Nullable InventoryClick listener)
*/
@Override
public InventoryLayoutImpl update(int index, @Nullable ItemStack stack) {
Check.argCondition(index < 0 || index > contents.length, INDEX_ERROR);
Check.argCondition(index < 0 || index >= contents.length, INDEX_ERROR);
contents[index].setItemStack(stack);
return this;
}
Expand All @@ -181,7 +181,7 @@ public InventoryLayoutImpl update(int index, @Nullable ItemStack stack) {
*/
@Override
public InventoryLayoutImpl update(int index, ItemStack stack, @Nullable InventoryClick click) {
Check.argCondition(index < 0 || index > contents.length, INDEX_ERROR);
Check.argCondition(index < 0 || index >= contents.length, INDEX_ERROR);
var slot = contents[index];
slot.setItemStack(stack);
slot.setClick(click == null ? CANCEL_CLICK : click);
Expand All @@ -193,7 +193,7 @@ public InventoryLayoutImpl update(int index, ItemStack stack, @Nullable Inventor
*/
@Override
public InventoryLayout remove(int index) {
Check.argCondition(index < 0 || index > this.contents.length,
Check.argCondition(index < 0 || index >= this.contents.length,
"The given index does not fit into the array (0, " + this.contents.length + ")");
this.contents[index] = BLANK_SLOT;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ void failItemSet() {

catchError(IllegalArgumentException.class, () -> layout.setItem(-1, slot));
catchError(IllegalArgumentException.class, () -> layout.setItem(100, slot));

int exactSize = layout.getSize();
catchError(IllegalArgumentException.class, () -> layout.setItem(exactSize, ItemStack.of(Material.PAPER)));
catchError(IllegalArgumentException.class, () -> layout.setItem(exactSize, slot));
catchError(IllegalArgumentException.class, () -> layout.blank(exactSize));
catchError(IllegalArgumentException.class, () -> layout.clear(exactSize));
catchError(IllegalArgumentException.class, () -> layout.remove(exactSize));
}

@Test
Expand Down
Loading