diff options
Diffstat (limited to 'src')
4 files changed, 52 insertions, 7 deletions
diff --git a/src/main/java/com/leonardobishop/quests/menu/CategoryQMenu.java b/src/main/java/com/leonardobishop/quests/menu/CategoryQMenu.java index e389d9fa..a27b513e 100644 --- a/src/main/java/com/leonardobishop/quests/menu/CategoryQMenu.java +++ b/src/main/java/com/leonardobishop/quests/menu/CategoryQMenu.java @@ -5,6 +5,7 @@ import com.leonardobishop.quests.events.MenuController; import com.leonardobishop.quests.menu.element.CategoryMenuElement; import com.leonardobishop.quests.menu.element.CustomMenuElement; import com.leonardobishop.quests.menu.element.MenuElement; +import com.leonardobishop.quests.menu.element.SpacerMenuElement; import com.leonardobishop.quests.player.QPlayer; import com.leonardobishop.quests.util.Items; import com.leonardobishop.quests.util.Messages; @@ -45,10 +46,16 @@ public class CategoryQMenu implements QMenu { if (!NumberUtils.isNumber(s)) continue; int slot = Integer.parseInt(s); int repeat = plugin.getConfig().getInt("custom-elements.categories." + s + ".repeat"); - ItemStack is = plugin.getItemStack("custom-elements.categories." + s + ".display", plugin.getConfig()); + MenuElement menuElement; + if (plugin.getConfig().contains("custom-elements.categories." + s + ".display")) { + ItemStack is = plugin.getItemStack("custom-elements.categories." + s + ".display", plugin.getConfig()); + menuElement = new CustomMenuElement(is); + } else if (plugin.getConfig().getBoolean("custom-elements.categories." + s + ".spacer", false)) { + menuElement = new SpacerMenuElement(); + } else continue; // user = idiot for (int i = 0; i <= repeat; i++) { - menuElements.put(slot + i, new CustomMenuElement(is)); + menuElements.put(slot + i, menuElement); } } } diff --git a/src/main/java/com/leonardobishop/quests/menu/QuestQMenu.java b/src/main/java/com/leonardobishop/quests/menu/QuestQMenu.java index bfc78617..46891604 100644 --- a/src/main/java/com/leonardobishop/quests/menu/QuestQMenu.java +++ b/src/main/java/com/leonardobishop/quests/menu/QuestQMenu.java @@ -6,6 +6,7 @@ import com.leonardobishop.quests.events.MenuController; import com.leonardobishop.quests.menu.element.CustomMenuElement; import com.leonardobishop.quests.menu.element.MenuElement; import com.leonardobishop.quests.menu.element.QuestMenuElement; +import com.leonardobishop.quests.menu.element.SpacerMenuElement; import com.leonardobishop.quests.player.QPlayer; import com.leonardobishop.quests.player.questprogressfile.QuestProgress; import com.leonardobishop.quests.quests.Quest; @@ -65,10 +66,16 @@ public class QuestQMenu implements QMenu { if (!NumberUtils.isNumber(s)) continue; int slot = Integer.parseInt(s); int repeat = plugin.getConfig().getInt(path + "." + s + ".repeat"); - ItemStack is = plugin.getItemStack(path + "." + s + ".display", plugin.getConfig()); + MenuElement menuElement; + if (plugin.getConfig().contains(path + "." + s + ".display")) { + ItemStack is = plugin.getItemStack(path + "." + s + ".display", plugin.getConfig()); + menuElement = new CustomMenuElement(is); + } else if (plugin.getConfig().getBoolean(path + "." + s + ".spacer", false)) { + menuElement = new SpacerMenuElement(); + } else continue; // user = idiot for (int i = 0; i <= repeat; i++) { - menuElements.put(slot + i, new CustomMenuElement(is)); + menuElements.put(slot + i, menuElement); } } } diff --git a/src/main/java/com/leonardobishop/quests/menu/element/SpacerMenuElement.java b/src/main/java/com/leonardobishop/quests/menu/element/SpacerMenuElement.java new file mode 100644 index 00000000..e2859718 --- /dev/null +++ b/src/main/java/com/leonardobishop/quests/menu/element/SpacerMenuElement.java @@ -0,0 +1,15 @@ +package com.leonardobishop.quests.menu.element; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +/** + * literally has the sole purpose of returning Material.AIR + */ +public class SpacerMenuElement extends MenuElement { + + @Override + public ItemStack asItemStack() { + return new ItemStack(Material.AIR); + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 6f941bea..9dd73a0d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -141,14 +141,22 @@ gui: # lore: # - "&7This is a custom item which can be added" # - "&7to your menus. This is purely cosmetic." +# - "" +# - "&7Two empty slots should follow." # type: "DIAMOND_BLOCK" -# 1: +# 1: # <--- start from slot 2 +# spacer: true # empty slot in GUI +# repeat: 2 # repeats for 2 slots +# 3: # <--- start from slot 4 # display: -# name: "&cExample Custom Item (slots 2 - 5)" +# name: "&cExample Custom Item (slots 4 - 7)" # lore: # - "&7This is a custom item which can be added" -# - "&7to your menus, but in slot 2 and repeated" +# - "&7to your menus, but in slot 4 and repeated" # - "&73 times." +# - "&7" +# - "&7This will come after 2 empty slots." +# - "&7" # - "&7This is purely cosmetic." # type: "NETHERRACK" # repeat: 3 # repeats for 3 more slots @@ -160,6 +168,14 @@ gui: # - "&7This is a custom item which can be added" # - "&7to your menus. This is purely cosmetic." # type: "EMERALD_BLOCK" +# "quests": # apply to the general quests menu IF categories are disabled +# 0: +# display: +# name: "&cExample Custom Item (slot 1)" +# lore: +# - "&7This is a custom item which can be added" +# - "&7to your menus. This is purely cosmetic." +# type: "EMERALD_BLOCK" options: # If categories are disabled, quests will be put into one big gui. |
