Skip to content

Commit

Permalink
Improves panel border creating method.
Browse files Browse the repository at this point in the history
Allow to change row count in panel and border material.
  • Loading branch information
BONNe committed Jan 19, 2019
1 parent 43fe78e commit 3d5dbca
Showing 1 changed file with 44 additions and 5 deletions.
49 changes: 44 additions & 5 deletions src/main/java/world/bentobox/challenges/panel/CommonGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,20 +235,59 @@ protected PanelItem getButton(CommonButtons button)


/**
* This method creates border of black panes around given panel.
* This method creates border of black panes around given panel with 5 rows.
* @param panelBuilder PanelBuilder which must be filled with border blocks.
*/
protected void fillBorder(PanelBuilder panelBuilder)
{
for (int i = 0; i < 45; i++)
this.fillBorder(panelBuilder, 5, Material.BLACK_STAINED_GLASS_PANE);
}


/**
* This method sets black stained glass pane around Panel with given row count.
* @param panelBuilder object that builds Panel.
* @param rowCount in Panel.
*/
protected void fillBorder(PanelBuilder panelBuilder, int rowCount)
{
this.fillBorder(panelBuilder, rowCount, Material.BLACK_STAINED_GLASS_PANE);
}


/**
* This method sets blocks with given Material around Panel with 5 rows.
* @param panelBuilder object that builds Panel.
* @param material that will be around Panel.
*/
protected void fillBorder(PanelBuilder panelBuilder, Material material)
{
this.fillBorder(panelBuilder, 5, material);
}


/**
* This method sets blocks with given Material around Panel with given row count.
* @param panelBuilder object that builds Panel.
* @param rowCount in Panel.
* @param material that will be around Panel.
*/
protected void fillBorder(PanelBuilder panelBuilder, int rowCount, Material material)
{
// Only for useful filling.
if (rowCount < 3)
{
return;
}

for (int i = 0; i < 9 * rowCount; i++)
{
// First (i < 9) and last (i > 35) rows must be filled
// First column (i % 9 == 0) and last column (i % 9 == 8) also must be filled.

if (i < 9 || i > 35 || i % 9 == 0 || i % 9 == 8)
if (i < 9 || i > 9 * (rowCount - 1) || i % 9 == 0 || i % 9 == 8)
{
panelBuilder.item(i,
new PanelItemBuilder().name("").icon(Material.BLACK_STAINED_GLASS_PANE).build());
panelBuilder.item(i, new PanelItemBuilder().name("&2").icon(material).build());
}
}
}
Expand Down

0 comments on commit 3d5dbca

Please sign in to comment.