@@ -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