From a35fd9696136f20a80c510ee7ff773f43385add0 Mon Sep 17 00:00:00 2001 From: Krakenied Date: Wed, 21 May 2025 13:53:21 +0200 Subject: Add option to set per category quest menu title Closes https://github.com/LMBishop/Quests/issues/622 --- .../quests/common/quest/Category.java | 38 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'common/src/main/java') diff --git a/common/src/main/java/com/leonardobishop/quests/common/quest/Category.java b/common/src/main/java/com/leonardobishop/quests/common/quest/Category.java index 285eff1a..6578fb3c 100644 --- a/common/src/main/java/com/leonardobishop/quests/common/quest/Category.java +++ b/common/src/main/java/com/leonardobishop/quests/common/quest/Category.java @@ -23,6 +23,7 @@ public final class Category { private static final String PERMISSION_PREFIX = "quests.category."; private final String id; + private final @Nullable String guiName; private final List registeredQuestIds; private final boolean permissionRequired; private final boolean hidden; @@ -31,24 +32,48 @@ public final class Category { * Constructs a Category with the specified parameters. * * @param id the unique identifier for the category; must not be null + * @param guiName the custom GUI title to be shown in this category quest menu * @param permissionRequired whether a permission is required to access this category * @param hidden whether the category should be hidden from view */ - public Category(final String id, final boolean permissionRequired, final boolean hidden) { + public Category(final String id, final @Nullable String guiName, final boolean permissionRequired, final boolean hidden) { this.id = Objects.requireNonNull(id, "id cannot be null"); + this.guiName = guiName; this.registeredQuestIds = new ArrayList<>(); this.permissionRequired = permissionRequired; this.hidden = hidden; } + /** + * Constructs a Category with no custom {@link Category#guiName}. + * + * @param id the unique identifier for the category; must not be null + * @param permissionRequired whether a permission is required to access this category + * @param hidden whether the category should be hidden from view + */ + public Category(final String id, final boolean permissionRequired, final boolean hidden) { + this(id, null, permissionRequired, hidden); + } + /** * Constructs a Category with {@link Category#hidden} set to {@code false}. * * @param id the unique identifier for the category; must not be null + * @param guiName the custom GUI title to be shown in this category quest menu + * @param permissionRequired whether a permission is required to access this category + */ + public Category(final String id, final @Nullable String guiName, final boolean permissionRequired) { + this(id, guiName, permissionRequired, false); + } + + /** + * Constructs a Category with no custom {@link Category#guiName} and {@link Category#hidden} set to {@code false}. + * + * @param id the unique identifier for the category; must not be null * @param permissionRequired whether a permission is required to access this category */ public Category(final String id, final boolean permissionRequired) { - this(id, permissionRequired, false); + this(id, null, permissionRequired); } /** @@ -61,6 +86,15 @@ public final class Category { return this.id; } + /** + * Returns the custom GUI title for this category. + * + * @return the category custom GUI title + */ + public @Nullable String getGUIName() { + return this.guiName; + } + /** * Checks if a specific permission is required to access this category and start quests within it. * The permission will be in the form of "quests.category.[category id]". -- cgit v1.2.3-70-g09d2