Added the ability to customize the row count.

This commit is contained in:
Brianna 2020-12-14 15:24:00 -06:00
parent cb73819252
commit 29a1ce057e

View File

@ -72,6 +72,10 @@ public class CustomizableGui extends Gui {
loadedGuis.put(guiKey, customContent); loadedGuis.put(guiKey, customContent);
this.customContent = customContent; this.customContent = customContent;
int rows = config.getInt("overrides.__ROWS__", -1);
if (rows != -1)
customContent.setRows(rows);
for (ConfigSection section : config.getSections("overrides")) { for (ConfigSection section : config.getSections("overrides")) {
if (section.contains("row") || section.contains("col") if (section.contains("row") || section.contains("col")
|| section.contains("mirrorrow") || section.contains("mirrorcol")) { || section.contains("mirrorrow") || section.contains("mirrorcol")) {
@ -114,6 +118,12 @@ public class CustomizableGui extends Gui {
blankItem = GuiUtils.getBorderItem(customContent.getCustomizedButton("__DEFAULT__").item); blankItem = GuiUtils.getBorderItem(customContent.getCustomizedButton("__DEFAULT__").item);
} }
@NotNull
public Gui setRows(int rows) {
int customRows = customContent.getRows();
return super.setRows(customRows != -1 ? customRows : rows);
}
@NotNull @NotNull
protected Inventory generateInventory(@NotNull GuiManager manager) { protected Inventory generateInventory(@NotNull GuiManager manager) {
applyCustomItems(); applyCustomItems();
@ -132,7 +142,6 @@ public class CustomizableGui extends Gui {
for (CustomButton customButton : customContent.getCustomButtons().values()) for (CustomButton customButton : customContent.getCustomButtons().values())
if (!(customButton instanceof MirrorFill)) if (!(customButton instanceof MirrorFill))
applyCustomItem(customButton); applyCustomItem(customButton);
} }
private void applyCustomItem(CustomButton customButton) { private void applyCustomItem(CustomButton customButton) {
@ -625,6 +634,8 @@ public class CustomizableGui extends Gui {
private final Map<String, CustomButton> customButtons = new HashMap<>(); private final Map<String, CustomButton> customButtons = new HashMap<>();
private final List<String> disabledButtons = new ArrayList<>(); private final List<String> disabledButtons = new ArrayList<>();
private int rows = -1;
public CustomContent(String guiKey) { public CustomContent(String guiKey) {
this.guiKey = guiKey; this.guiKey = guiKey;
} }
@ -680,5 +691,13 @@ public class CustomizableGui extends Gui {
public boolean isButtonDisabled(String button) { public boolean isButtonDisabled(String button) {
return disabledButtons.contains(button); return disabledButtons.contains(button);
} }
public int getRows() {
return rows;
}
public void setRows(int rows) {
this.rows = rows;
}
} }
} }