Skip to content
This repository was archived by the owner on Nov 10, 2021. It is now read-only.

Commit 3bc9dcd

Browse files
committed
Add getRows method in Inventory
1 parent 6df74c1 commit 3bc9dcd

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/main/java/com/froxynetwork/froxyapi/inventory/Inventory.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public interface Inventory {
4343
*/
4444
public InventoryProvider getInventoryProvider();
4545

46+
/**
47+
* @return The number of rows
48+
*/
49+
public int getRows();
50+
4651
/**
4752
* Set an item at specific pos.<br />
4853
*
@@ -56,8 +61,8 @@ public interface Inventory {
5661
public default void set(int col, int row, ClickableItem item) {
5762
if (col < 1 || col > 9)
5863
throw new IllegalArgumentException("col must be between 1 and 9");
59-
if (row < 1 || row > 6)
60-
throw new IllegalArgumentException("row must be between 1 and the maximum number of rows");
64+
if (row < 1 || row > getRows())
65+
throw new IllegalArgumentException("row must be between 1 and " + getRows());
6166
set(locToPos(row, col), item);
6267
}
6368

@@ -102,8 +107,8 @@ public default void rectangle(int row, int col, int width, int height, Clickable
102107
// 10 - col because width starts with 1 and not 0
103108
if (width < 1 || width > 10 - col)
104109
throw new IllegalArgumentException("The width must be between 1 and " + (10 - col));
105-
if (height < 1 || height > 7 - col)
106-
throw new IllegalArgumentException("The height must be between 1 and " + (7 - col));
110+
if (height < 1 || height > getRows() + 1 - col)
111+
throw new IllegalArgumentException("The height must be between 1 and " + (getRows() + 1 - col));
107112
rectangle(locToPos(row, col), width, height, item);
108113
}
109114

0 commit comments

Comments
 (0)