From cf9150335738560f0e31203d1572f2d6791bed69 Mon Sep 17 00:00:00 2001 From: LMBishop <13875753+LMBishop@users.noreply.github.com> Date: Tue, 31 May 2022 20:45:24 +0100 Subject: Add extended problem descriptions and MiniMessage --- .../quests/common/config/ConfigProblem.java | 16 +-- .../common/config/ConfigProblemDescriptions.java | 115 ++++++++++++++++++--- 2 files changed, 108 insertions(+), 23 deletions(-) (limited to 'common/src/main/java') diff --git a/common/src/main/java/com/leonardobishop/quests/common/config/ConfigProblem.java b/common/src/main/java/com/leonardobishop/quests/common/config/ConfigProblem.java index d9f30c09..e2fdc093 100644 --- a/common/src/main/java/com/leonardobishop/quests/common/config/ConfigProblem.java +++ b/common/src/main/java/com/leonardobishop/quests/common/config/ConfigProblem.java @@ -4,20 +4,18 @@ public final class ConfigProblem { private final ConfigProblemType type; private final String description; + private final String extendedDescription; private final String location; - public ConfigProblem(ConfigProblemType type, String description, String location) { + public ConfigProblem(ConfigProblemType type, String description, String extendedDescription, String location) { this.type = type; this.description = description == null ? "?" : description; - ; + this.extendedDescription = extendedDescription == null ? "This error has no extended description" : extendedDescription; this.location = location == null ? "?" : location; } - public ConfigProblem(ConfigProblemType type, String description) { - this.type = type; - this.description = description == null ? "?" : description; - ; - this.location = "?"; + public ConfigProblem(ConfigProblemType type, String description, String extendedDescription) { + this(type, description, extendedDescription, null); } public ConfigProblemType getType() { @@ -28,6 +26,10 @@ public final class ConfigProblem { return description; } + public String getExtendedDescription() { + return extendedDescription; + } + public String getLocation() { return location; } diff --git a/common/src/main/java/com/leonardobishop/quests/common/config/ConfigProblemDescriptions.java b/common/src/main/java/com/leonardobishop/quests/common/config/ConfigProblemDescriptions.java index 4f4bc4bd..c1903a35 100644 --- a/common/src/main/java/com/leonardobishop/quests/common/config/ConfigProblemDescriptions.java +++ b/common/src/main/java/com/leonardobishop/quests/common/config/ConfigProblemDescriptions.java @@ -2,26 +2,105 @@ package com.leonardobishop.quests.common.config; public enum ConfigProblemDescriptions { - MALFORMED_YAML("Malformed YAML file, cannot read config"), - INVALID_QUEST_ID("ID '%s' is invalid, must be alphanumeric, unique and with no spaces"), - NO_TASKS("Quest contains no valid tasks"), - NO_TASK_TYPE("Task type not specified"), - UNKNOWN_TASK_TYPE("Task type '%s' does not exist"), - NO_DISPLAY_NAME("No name specified"), - NO_DISPLAY_MATERIAL("No material specified"), - UNKNOWN_QUEST_ITEM("Quest item '%s' does not exist"), - UNKNOWN_MATERIAL("Material '%s' does not exist"), - UNKNOWN_ENTITY_TYPE("Entity type '%s' does not exist"), - TASK_MALFORMED_NOT_SECTION("Task '%s' is not a configuration section (has no fields)"), - TASK_MISSING_FIELD("Required field '%s' is missing for task type '%s'"), - UNKNOWN_TASK_REFERENCE("Attempt to reference unknown task '%s'"), - UNKNOWN_CATEGORY("Category '%s' does not exist"), - UNKNOWN_REQUIREMENT("Quest requirement '%s' does not exist"); + MALFORMED_YAML( + "Malformed YAML file, cannot read config", + "Your configuration is not a valid YAML configuration.
" + + "Quests cannot parse this file. Please resolve the error
" + + "below, or use an online YAML checker.

" + + "%s" + ), + INVALID_QUEST_ID( + "ID '%s' is invalid, must be alphanumeric, unique and with no spaces", + "ID '%s' is invalid. Either another quest is
" + + "using this ID, or it is not alphanumeric.

" + + "Examples:
" + + "Valid: 'abc'
" + + "Valid: 'ab-c'
" + + "Valid: 'ab-1'
" + + "Invalid: 'ab c'
" + + "Invalid: ' '" + ), + NO_TASKS( + "Quest contains no valid tasks", + "The quest does not contain any valid tasks.
" + + "This may be because of an improperly indented
" + + "tasks section, or because all specified task
" + + "types do not exist." + ), + NO_TASK_TYPE("Task type not specified", + "You have not specified a type for this task.
" + + "You can specify one with the 'type:' field." + ), + UNKNOWN_TASK_TYPE("Task type '%s' does not exist", + "The task type '%s' does not exist.
" + + "This may be because of a mis-typed name, or
" + + "a plugin which this task type depends on is
" + + "not present on the server." + ), + NO_DISPLAY_NAME("No name specified", + "No display name for this quest has been
" + + "specified. This name is used in all chat messages
" + + "and quest GUIs." + ), + NO_DISPLAY_MATERIAL("No material specified", + "No material for this quest display item
" + + "has been specified." + ), + UNKNOWN_QUEST_ITEM("Quest item '%s' does not exist", + "A quest item named '%s' does not exist.
" + + "Quest items are stored in /plugins/Quests/items,
" + + "by their ID. The ID does not include the .yml
" + + "extension." + ), + UNKNOWN_MATERIAL("Material '%s' does not exist", + "Material '%s' does not exist on the server.
" + + "Please refer to the wiki for a list of javadocs
" + + "corresponding to your server version. Alternatively,
" + + "you can find the material list by searching for your
" + + "server version + 'Material ENUM'." + ), + UNKNOWN_ENTITY_TYPE("Entity type '%s' does not exist", + "Entity type '%s' does not exist on the server.
" + + "Please refer to the wiki for a list of javadocs
" + + "corresponding to your server version. Alternatively,
" + + "you can find the material list by searching for your
" + + "server version + 'EntityType ENUM'."), + TASK_MALFORMED_NOT_SECTION("Task '%s' is not a configuration section", + "Task '%s' is not properly formatted as a
" + + "configuration section. Please review the wiki
" + + "for the correct format of a task type." + ), + TASK_MISSING_FIELD("Required field '%s' is missing for task type '%s'", + "Field '%s' must be set for task '%s'
" + + "to function as expected. Please review
" + + "the relevant documentation on the wiki for
" + + "a list of mandatory fields." + ), + UNKNOWN_TASK_REFERENCE("Attempt to reference unknown task '%s'", + "A task by the ID '%s' has not been configured
" + + "for this quest. Note that the task ID can differ
" + + "from its task type. The ID is set by you; it is
" + + "the key for the task configuration section itself.

" + + "" + + "Example (highlighted in bold):
" + + "tasks:
" + + "->task-id:
" + + "--->type: ...'" + ), + UNKNOWN_CATEGORY("Category '%s' does not exist", + "Category by the ID '%s' does not exist." + ), + UNKNOWN_REQUIREMENT("Quest requirement '%s' does not exist", + "This may be the result of a cascading error
" + + "if '%s' failed to load, or a mis-typed ID." + ); private final String description; + private final String extendedDescription; - ConfigProblemDescriptions(String description) { + ConfigProblemDescriptions(String description, String extendedDescription) { this.description = description; + this.extendedDescription = extendedDescription; } @Override @@ -33,4 +112,8 @@ public enum ConfigProblemDescriptions { return String.format(description, (Object[]) format); } + public String getExtendedDescription(String... format) { + return String.format(extendedDescription, (Object[]) format); + } + } \ No newline at end of file -- cgit v1.2.3-70-g09d2