Skip to content

Commit

Permalink
Added close item in decorations
Browse files Browse the repository at this point in the history
  • Loading branch information
WaterArchery committed Aug 15, 2024
1 parent 8b92855 commit cdd823f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.waterarchery</groupId>
<artifactId>LitTournaments</artifactId>
<version>1.1.7</version>
<version>1.1.8</version>
<packaging>jar</packaging>

<name>LitTournaments</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public void initializeDefaults() {
addOptional(ConfigPart.noComment("Decoration.item3.Slot", 36));
addOptional(ConfigPart.noComment("Decoration.item3.Lore", List.of()));

addOptional(ConfigPart.noComment("Decoration.closeItem.Name", "&cClose Menu"));
addOptional(ConfigPart.noComment("Decoration.closeItem.Material", "BARRIER"));
addOptional(ConfigPart.noComment("Decoration.closeItem.CustomModelData", -1));
addOptional(ConfigPart.noComment("Decoration.closeItem.HideAttributes", true));
addOptional(ConfigPart.noComment("Decoration.closeItem.Action", "close"));
addOptional(ConfigPart.noComment("Decoration.closeItem.Slot", 40));
addOptional(ConfigPart.noComment("Decoration.closeItem.Lore", List.of()));

addOptional(ConfigPart.noComment("Decoration.item4.Name", "&8"));
addOptional(ConfigPart.noComment("Decoration.item4.Material", "GREEN_STAINED_GLASS_PANE"));
addOptional(ConfigPart.noComment("Decoration.item4.CustomModelData", -1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ public void decorateGUI(FileConfiguration yml, BaseGui gui, ConfigManager manage
for (String decorationItem : Objects.requireNonNull(yml.getConfigurationSection("Decoration")).getKeys(false)) {
ItemStack itemStack = craftItemStack(manager, decorationItem, "Decoration", null);
int slot = yml.getInt("Decoration." + decorationItem + ".Slot");
GuiItem guiItem = ItemBuilder.from(itemStack).asGuiItem();
String action = yml.getString("Decoration." + decorationItem + ".Action", "none");

GuiItem guiItem = ItemBuilder.from(itemStack)
.asGuiItem(event -> {
if (action.equalsIgnoreCase("close")) event.getWhoClicked().closeInventory();
});

gui.setItem(slot, guiItem);
}
Expand Down

0 comments on commit cdd823f

Please sign in to comment.