From 26361b833fd119ce91505c6a77b8d7943bd28b9b Mon Sep 17 00:00:00 2001 From: LoJoSho Date: Wed, 16 Aug 2023 13:39:03 -0500 Subject: [PATCH] fix: shades not working between empty columns --- .../hmccosmetics/config/Settings.java | 4 +++ .../com/hibiscusmc/hmccosmetics/gui/Menu.java | 33 +++++++++++-------- common/src/main/resources/config.yml | 1 + 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/Settings.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/Settings.java index 66599cfd..e44f59f8 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/Settings.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/Settings.java @@ -51,6 +51,7 @@ public class Settings { private static final String SEQUENT_ROW_SHIFT_PATH = "sequent-row-shift"; private static final String INDIVIDUAL_COLUMN_SHIFT_PATH = "individual-column-shift"; private static final String BACKGROUND_PATH = "background"; + private static final String CLEAR_BACKGROUND_PATH = "clear-background"; private static final String EQUIPPED_COSMETIC_COLOR_PATH = "equipped-cosmetic-color"; private static final String EQUIPABLE_COSMETIC_COLOR_PATH = "equipable-cosmetic-color"; private static final String LOCKED_COSMETIC_COLOR_PATH = "locked-cosmetic-color"; @@ -119,6 +120,8 @@ public class Settings { @Getter private static String background; @Getter + private static String clearBackground; + @Getter private static String equippedCosmeticColor; @Getter private static String equipableCosmeticColor; @@ -170,6 +173,7 @@ public class Settings { sequentRowShift = shadingSettings.node(SEQUENT_ROW_SHIFT_PATH).getString(); individualColumnShift = shadingSettings.node(INDIVIDUAL_COLUMN_SHIFT_PATH).getString(); background = shadingSettings.node(BACKGROUND_PATH).getString(); + clearBackground = shadingSettings.node(CLEAR_BACKGROUND_PATH).getString(); equippedCosmeticColor = shadingSettings.node(EQUIPPED_COSMETIC_COLOR_PATH).getString(); equipableCosmeticColor = shadingSettings.node(EQUIPABLE_COSMETIC_COLOR_PATH).getString(); lockedCosmeticColor = shadingSettings.node(LOCKED_COSMETIC_COLOR_PATH).getString(); diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/Menu.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/Menu.java index 287e035e..e4c6a45a 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/Menu.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/Menu.java @@ -172,23 +172,25 @@ public class Menu { int row = 0; if (shading) { for (int i = 0; i < gui.getInventory().getSize(); i++) { + // Handles the title + if (i % 9 == 0) { + if (row == 0) { + title.append(Settings.getFirstRowShift()); // Goes back to the start of the gui + } else { + title.append(Settings.getSequentRowShift()); + } + row += 1; + } else { + title.append(Settings.getIndividualColumnShift()); // Goes to the next slot + } + + boolean occupied = false; + if (items.containsKey(i)) { // Handles the items MenuItem item = items.get(i); updateItem(user, gui, item); - // Handles the title - if (i % 9 == 0) { - if (row == 0) { - title.append(Settings.getFirstRowShift()); // Goes back to the start of the gui - } else { - title.append(Settings.getSequentRowShift()); - } - row += 1; - } else { - title.append(Settings.getIndividualColumnShift()); // Goes to the next slot - } - if (item.type().getId().equalsIgnoreCase("cosmetic")) { Cosmetic cosmetic = Cosmetics.getCosmetic(item.itemConfig().node("cosmetic").getString("")); if (cosmetic == null) continue; @@ -201,9 +203,14 @@ public class Menu { title.append(Settings.getLockedCosmeticColor()); } } - title.append(Settings.getBackground().replaceAll("", String.valueOf(row))); + occupied = true; } } + if (occupied) { + title.append(Settings.getBackground().replaceAll("", String.valueOf(row))); + } else { + title.append(Settings.getClearBackground().replaceAll("", String.valueOf(row))); + } } MessagesUtil.sendDebugMessages("Updated menu with title " + title); gui.updateTitle(StringUtils.parseStringToString(Hooks.processPlaceholders(user.getPlayer(), title.toString()))); diff --git a/common/src/main/resources/config.yml b/common/src/main/resources/config.yml index e116e2f7..8e0ee145 100644 --- a/common/src/main/resources/config.yml +++ b/common/src/main/resources/config.yml @@ -60,6 +60,7 @@ menu-settings: sequent-row-shift: " " # Oraxen: " " / ItemsAdder: " :offset_-169:" (Space is important here!) individual-column-shift: "" # Oraxen: "" / ItemsAdder: ":offset_-3:" background: ":colorable> " # Oraxen: ":colorable> " / ItemsAdder: ":shade_row_:colorable: " + clear-background: ":colorable> " # Oraxen: ":colorable> " / ItemsAdder: ":clear_row_:colorable: " #These use MiniMessage for color! https://docs.advntr.dev/minimessage/format.html#color equipped-cosmetic-color: "" equipable-cosmetic-color: ""