-
Notifications
You must be signed in to change notification settings - Fork 1
ModelLayout
You are sick of having to write every single inventory slot into the ExactLayout? Well the ModelLayout is for you!
Generally the ModelLayout is just a advanced version of the ExactLayout with a small own specification language.
This language can always be looked up here or in the docs of the class.
To create a ModelLayout object we instatiate as followed:
ModelLayout layout = new ModelLayout("1:1-9=i,1:2|3=d,*=g");
layout.set('i', new GUILabel("Test", Material.IRON_BLOCK));
layout.set('d', new GUILabel("Test", Material.DIAMOND_BLOCK));
layout.set('g', new GUILabel("Test", Material.GOLD_BLOCK));
The ModelLayout can take different, multiple operations trough the String parameter.
Each operation is seperated by a ,
and resolved from left to right, so the left operation will be executed first.
Operations always take in some sort of coordinate related to the gui (start at 1:1 at the top left corner) and a char
as a variable that defines the Element that should be placed at that position.
In the following, x:y will be reffered as the choosed coordinate and i
as the defined item
Operation | Description | Example |
---|---|---|
x:y=i | The exact operations will place i at x:y | 1:3=i |
x:y-x1=i | Will draw a horizontal line from x:y to x1 with i | 1:3-9=i |
x:y|y1=i | Will draw a vertical line from x:y to y1 with i | 5:1|4=i |
x:y#x1:y1=i | Will draw a rect from x:y (top left) to x1:y1 (bottom right) | 3:2#4:3=i |
*=i | Will fill all empty slots with i | *=i |
Since operations are executed from left to right, operations can override previously executed operations:
3:3=i,1:3-9=d -> i
would be placed at 3:3 but afterwards a line of d
is drawn from 1:3 to 9:3 and i would be overriden.
The hight of the gui is automatically calculated by the highest y
value found in the definition string.