summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bukkit/build.gradle10
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java2
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/config/BukkitQuestsLoader.java48
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BucketInteractionTaskType.java4
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BuildingCertainTaskType.java4
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/FarmingCertainTaskType.java4
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/FishingCertainTaskType.java4
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningCertainTaskType.java4
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MobkillingCertainTaskType.java4
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/TamingCertainTaskType.java4
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/PlaceholderAPIEvaluateTaskType.java10
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/CommandUtils.java25
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/TaskUtils.java38
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/chat/Chat.java42
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/chat/MiniMessageParser.java26
-rw-r--r--common/src/main/java/com/leonardobishop/quests/common/config/ConfigProblem.java16
-rw-r--r--common/src/main/java/com/leonardobishop/quests/common/config/ConfigProblemDescriptions.java115
17 files changed, 293 insertions, 67 deletions
diff --git a/bukkit/build.gradle b/bukkit/build.gradle
index fd8238fe..fa1c3e69 100644
--- a/bukkit/build.gradle
+++ b/bukkit/build.gradle
@@ -42,6 +42,7 @@ repositories {
maven { url = 'https://nexus.bencodez.com/repository/maven-public/'}
// NuVotifier
maven { url = 'https://repo.leonardobishop.com/releases/'}
+ // Adventure
mavenCentral()
}
@@ -103,7 +104,9 @@ dependencies {
// SuperiorSkyblock
compileOnly 'com.bgsoftware:SuperiorSkyblockAPI:1.8.4'
// VotingPlugin
- compileOnly 'com.bencodez:votingplugin:6.8.3'
+ compileOnly ('com.bencodez:votingplugin:6.8.3') {
+ exclude group: 'dev.dbassett'
+ }
// MMOItems
compileOnly 'net.Indyuce:MMOItems:6.5'
compileOnly 'io.lumine:MythicLib:1.1.1'
@@ -117,6 +120,10 @@ dependencies {
implementation 'com.zaxxer:HikariCP:4.0.3'
// slf4j
implementation 'org.slf4j:slf4j-simple:1.7.30'
+ // adventure
+ implementation 'net.kyori:adventure-platform-bukkit:4.1.0'
+ // mini message
+ implementation "net.kyori:adventure-text-minimessage:4.10.1"
compileOnly fileTree(dir: 'libs', includes: ['*.jar'])
}
@@ -129,5 +136,6 @@ shadowJar {
relocate 'org.bstats', 'com.leonardobishop.quests.libs.bstats'
relocate 'com.zaxxer.hikari', 'com.leonardobishop.quests.libs.hikaricp'
relocate 'org.slf4j', 'com.leonardobishop.quests.libs.slf4j'
+ relocate 'net.kyori', 'com.leonardobishop.quests.libs.adventure'
archiveClassifier.set('')
} \ No newline at end of file
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java
index d0f4e151..c6e3e260 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java
@@ -438,7 +438,7 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests {
}
} else {
configProblems = Collections.singletonMap("<MAIN CONFIG> config.yml",
- Collections.singletonList(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR, ConfigProblemDescriptions.MALFORMED_YAML.getDescription())));
+ Collections.singletonList(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR, ConfigProblemDescriptions.MALFORMED_YAML.getDescription(), ConfigProblemDescriptions.MALFORMED_YAML.getExtendedDescription())));
}
}
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/config/BukkitQuestsLoader.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/config/BukkitQuestsLoader.java
index 9291caee..56a0927e 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/config/BukkitQuestsLoader.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/config/BukkitQuestsLoader.java
@@ -20,6 +20,7 @@ import com.leonardobishop.quests.common.tasktype.TaskTypeManager;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
@@ -148,8 +149,12 @@ public class BukkitQuestsLoader implements QuestsLoader {
// test QUEST file integrity
try {
config.loadFromString(processed.toString());
- } catch (Exception ex) {
- configProblems.put(relativeLocation.getPath(), Collections.singletonList(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR, ConfigProblemDescriptions.MALFORMED_YAML.getDescription())));
+ } catch (InvalidConfigurationException ex) {
+ configProblems.put(relativeLocation.getPath(), Collections.singletonList(new ConfigProblem(
+ ConfigProblem.ConfigProblemType.ERROR,
+ ConfigProblemDescriptions.MALFORMED_YAML.getDescription(),
+ ConfigProblemDescriptions.MALFORMED_YAML.getExtendedDescription(ex.getMessage())
+ )));
return FileVisitResult.CONTINUE;
}
@@ -158,13 +163,18 @@ public class BukkitQuestsLoader implements QuestsLoader {
List<ConfigProblem> problems = new ArrayList<>();
if (!StringUtils.isAlphanumeric(id)) {
- problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR, ConfigProblemDescriptions.INVALID_QUEST_ID.getDescription(id)));
+ problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR,
+ ConfigProblemDescriptions.INVALID_QUEST_ID.getDescription(id),
+ ConfigProblemDescriptions.INVALID_QUEST_ID.getExtendedDescription(id)));
}
// CHECK EVERYTHING WRONG WITH THE QUEST FILE BEFORE ACTUALLY LOADING THE QUEST
if (!config.isConfigurationSection("tasks")) {
- problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR, ConfigProblemDescriptions.NO_TASKS.getDescription(), "tasks"));
+ problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR,
+ ConfigProblemDescriptions.NO_TASKS.getDescription(),
+ ConfigProblemDescriptions.NO_TASKS.getExtendedDescription(),
+ "tasks"));
} else { //continue
int validTasks = 0;
for (String taskId : config.getConfigurationSection("tasks").getKeys(false)) {
@@ -173,12 +183,18 @@ public class BukkitQuestsLoader implements QuestsLoader {
String taskType = config.getString(taskRoot + ".type");
if (!config.isConfigurationSection(taskRoot)) {
- problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING, ConfigProblemDescriptions.TASK_MALFORMED_NOT_SECTION.getDescription(taskId), taskRoot));
+ problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
+ ConfigProblemDescriptions.TASK_MALFORMED_NOT_SECTION.getDescription(taskId),
+ ConfigProblemDescriptions.TASK_MALFORMED_NOT_SECTION.getExtendedDescription(taskId),
+ taskRoot));
continue;
}
if (taskType == null) {
- problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING, ConfigProblemDescriptions.NO_TASK_TYPE.getDescription(), taskRoot));
+ problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
+ ConfigProblemDescriptions.NO_TASK_TYPE.getDescription(),
+ ConfigProblemDescriptions.NO_TASK_TYPE.getExtendedDescription(),
+ taskRoot));
continue;
}
@@ -192,7 +208,10 @@ public class BukkitQuestsLoader implements QuestsLoader {
problems.addAll(t.validateConfig(taskRoot, configValues));
} else {
- problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING, ConfigProblemDescriptions.UNKNOWN_TASK_TYPE.getDescription(taskType), taskRoot));
+ problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
+ ConfigProblemDescriptions.UNKNOWN_TASK_TYPE.getDescription(taskType),
+ ConfigProblemDescriptions.UNKNOWN_TASK_TYPE.getExtendedDescription(taskType),
+ taskRoot));
isValid = false;
}
@@ -201,7 +220,10 @@ public class BukkitQuestsLoader implements QuestsLoader {
}
}
if (validTasks == 0) {
- problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR, ConfigProblemDescriptions.NO_TASKS.getDescription(), "tasks"));
+ problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR,
+ ConfigProblemDescriptions.NO_TASKS.getDescription(),
+ ConfigProblemDescriptions.NO_TASKS.getExtendedDescription(),
+ "tasks"));
}
}
@@ -269,7 +291,10 @@ public class BukkitQuestsLoader implements QuestsLoader {
if (c != null) {
c.registerQuestId(id);
} else {
- problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING, ConfigProblemDescriptions.UNKNOWN_CATEGORY.getDescription(category), "options.category"));
+ problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
+ ConfigProblemDescriptions.UNKNOWN_CATEGORY.getDescription(category),
+ ConfigProblemDescriptions.UNKNOWN_CATEGORY.getExtendedDescription(category),
+ "options.category"));
}
}
@@ -353,7 +378,10 @@ public class BukkitQuestsLoader implements QuestsLoader {
List<ConfigProblem> problems = new ArrayList<>();
for (String req : loadedQuest.getValue().getRequirements()) {
if (questManager.getQuestById(req) == null) {
- problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING, ConfigProblemDescriptions.UNKNOWN_REQUIREMENT.getDescription(req), "options.requires"));
+ problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
+ ConfigProblemDescriptions.UNKNOWN_REQUIREMENT.getDescription(req),
+ ConfigProblemDescriptions.UNKNOWN_REQUIREMENT.getExtendedDescription(req),
+ "options.requires"));
}
}
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BucketInteractionTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BucketInteractionTaskType.java
index 48d72190..e070e27d 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BucketInteractionTaskType.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BucketInteractionTaskType.java
@@ -36,7 +36,9 @@ public abstract class BucketInteractionTaskType extends BukkitTaskType {
String[] split = configBlock.split(":");
if (Material.getMaterial(String.valueOf(split[0])) == null) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
- ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(configBlock), root + ".bucket"));
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(configBlock),
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getExtendedDescription(configBlock),
+ root + ".bucket"));
}
}
if (TaskUtils.configValidateExists(root + ".amount", config.get("amount"), problems, "amount", super.getType()))
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BuildingCertainTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BuildingCertainTaskType.java
index b52933cb..a8e59494 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BuildingCertainTaskType.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BuildingCertainTaskType.java
@@ -58,7 +58,9 @@ public final class BuildingCertainTaskType extends BukkitTaskType {
String[] split = materialName.split(":");
if (Material.getMaterial(String.valueOf(split[0])) == null) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
- ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(materialName), root + "." + source));
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(materialName),
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getExtendedDescription(materialName),
+ root + "." + source));
}
}
}
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/FarmingCertainTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/FarmingCertainTaskType.java
index 19dbc2ff..4f475780 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/FarmingCertainTaskType.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/FarmingCertainTaskType.java
@@ -64,7 +64,9 @@ public final class FarmingCertainTaskType extends BukkitTaskType {
for (String materialName : checkBlocks) {
if (Material.getMaterial(String.valueOf(materialName)) == null) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
- ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(materialName), root + "." + source));
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(materialName),
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getExtendedDescription(materialName),
+ root + "." + source));
}
}
}
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/FishingCertainTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/FishingCertainTaskType.java
index fcd07cde..fbe846fa 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/FishingCertainTaskType.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/FishingCertainTaskType.java
@@ -38,7 +38,9 @@ public final class FishingCertainTaskType extends BukkitTaskType {
if (TaskUtils.configValidateExists(root + ".item", config.get("item"), problems, "item", super.getType())) {
if (Material.getMaterial(String.valueOf(config.get("item"))) == null) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
- ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(String.valueOf(config.get("item"))), root + ".item.item"));
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(String.valueOf(config.get("item"))),
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getExtendedDescription(String.valueOf(config.get("item"))),
+ root + ".item.item"));
}
}
if (TaskUtils.configValidateExists(root + ".amount", config.get("amount"), problems, "amount", super.getType()))
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningCertainTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningCertainTaskType.java
index 9e3175fa..35fc9b81 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningCertainTaskType.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningCertainTaskType.java
@@ -58,7 +58,9 @@ public final class MiningCertainTaskType extends BukkitTaskType {
String[] split = materialName.split(":");
if (Material.getMaterial(String.valueOf(split[0])) == null) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
- ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(materialName), root + "." + source));
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(materialName),
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getExtendedDescription(materialName),
+ root + "." + source));
}
}
}
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MobkillingCertainTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MobkillingCertainTaskType.java
index 8b2f488a..c68af762 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MobkillingCertainTaskType.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MobkillingCertainTaskType.java
@@ -58,7 +58,9 @@ public final class MobkillingCertainTaskType extends BukkitTaskType {
EntityType.valueOf(mobName);
} catch (IllegalArgumentException ex) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
- ConfigProblemDescriptions.UNKNOWN_ENTITY_TYPE.getDescription(mobName), root + "." + source));
+ ConfigProblemDescriptions.UNKNOWN_ENTITY_TYPE.getDescription(mobName),
+ ConfigProblemDescriptions.UNKNOWN_ENTITY_TYPE.getExtendedDescription(mobName),
+ root + "." + source));
}
}
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/TamingCertainTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/TamingCertainTaskType.java
index 002fbda6..70aef33b 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/TamingCertainTaskType.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/TamingCertainTaskType.java
@@ -40,7 +40,9 @@ public final class TamingCertainTaskType extends BukkitTaskType {
EntityType.valueOf(String.valueOf(config.get("mob")));
} catch (IllegalArgumentException ex) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
- ConfigProblemDescriptions.UNKNOWN_ENTITY_TYPE.getDescription(String.valueOf(config.get("mob"))), root + ".mob"));
+ ConfigProblemDescriptions.UNKNOWN_ENTITY_TYPE.getDescription(String.valueOf(config.get("mob"))),
+ ConfigProblemDescriptions.UNKNOWN_ENTITY_TYPE.getExtendedDescription(String.valueOf(config.get("mob"))),
+ root + ".mob"));
}
}
return problems;
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/PlaceholderAPIEvaluateTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/PlaceholderAPIEvaluateTaskType.java
index 706fcfcd..999beacf 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/PlaceholderAPIEvaluateTaskType.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/PlaceholderAPIEvaluateTaskType.java
@@ -43,7 +43,13 @@ public final class PlaceholderAPIEvaluateTaskType extends BukkitTaskType {
operator = Operator.valueOf(operatorStr);
} catch (IllegalArgumentException ex) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
- "Operator '" + operatorStr + "' does not exist.", root + ".operator"));
+ "Operator '" + operatorStr + "' does not exist",
+ "Valid operators are:<br>" +
+ "- GREATER_THAN<br>" +
+ "- LESS_THAN<br>" +
+ "- GREATER_THAN_OR_EQUAL_TO<br>" +
+ "- LESS_THAN_OR_EQUAL_TO<br>",
+ root + ".operator"));
}
if (operator != null && evalExists) {
String evalStr = String.valueOf(config.get("evaluates"));
@@ -51,7 +57,7 @@ public final class PlaceholderAPIEvaluateTaskType extends BukkitTaskType {
Double.parseDouble(evalStr);
} catch (IllegalArgumentException ex) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
- "Numeric operator specified, but placeholder evaluation '" + evalStr + "' is not numeric.", root + ".evaluates"));
+ "Numeric operator specified, but placeholder evaluation '" + evalStr + "' is not numeric", null, root + ".evaluates"));
}
}
}
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/CommandUtils.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/CommandUtils.java
index 90e529a2..ca14e6ac 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/CommandUtils.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/CommandUtils.java
@@ -5,6 +5,7 @@ import com.leonardobishop.quests.bukkit.util.chat.Chat;
import com.leonardobishop.quests.common.config.ConfigProblem;
import com.leonardobishop.quests.common.player.QPlayer;
import com.leonardobishop.quests.common.player.questprogressfile.QuestProgressFile;
+import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
@@ -48,9 +49,26 @@ public class CommandUtils {
for (ConfigProblem.ConfigProblemType type : ConfigProblem.ConfigProblemType.values()) {
if (sortedProblems.containsKey(type)) {
for (ConfigProblem problem : sortedProblems.get(type)) {
- sender.sendMessage(ChatColor.DARK_GRAY + " | - " + Chat.matchConfigProblemToColor(problem.getType())
- + problem.getType().getShortened() + ChatColor.DARK_GRAY + ": "
- + ChatColor.GRAY + problem.getDescription() + ChatColor.DARK_GRAY + " :" + problem.getLocation());
+ String color = Chat.matchConfigProblemToColorName(problem.getType());
+ String extendedDescription = String.format("<%s>%s</%s><br><gray>Problem location: </gray><white>%s</white><br><br><grey>%s</grey>",
+ color,
+ problem.getDescription(),
+ color,
+ problem.getLocation(),
+ problem.getExtendedDescription()
+ );
+ extendedDescription = extendedDescription.replace("'", "\\'");
+
+ String message = String.format(
+ "<dark_gray> | - </dark_gray><%s>%s</%s><dark_gray>:</dark_gray> <hover:show_text:'%s'><gray>%s</gray></hover><dark_gray> :%s</dark_gray>",
+ color,
+ problem.getType().getShortened(),
+ color,
+ extendedDescription,
+ problem.getDescription(),
+ problem.getLocation()
+ );
+ Chat.send(sender, message);
count++;
}
}
@@ -66,6 +84,7 @@ public class CommandUtils {
sender.sendMessage(ChatColor.DARK_GRAY.toString() + "----");
sender.sendMessage(ChatColor.GRAY.toString() + count + " problem(s) | " + String.join(ChatColor.DARK_GRAY + ", ", legend));
+ sender.sendMessage(ChatColor.DARK_GRAY.toString() + "Mouse-over for more information.");
} else {
sender.sendMessage(ChatColor.GRAY + "Quests did not detect any problems with your configuration.");
}
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/TaskUtils.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/TaskUtils.java
index c9f36b3e..66d804b6 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/TaskUtils.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/TaskUtils.java
@@ -53,7 +53,7 @@ public class TaskUtils {
if (object == null) {
if (!allowNull) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR,
- String.format("Expected a number for '%s', but got null instead", (Object[]) args), path));
+ String.format("Expected a number for '%s', but got null instead", (Object[]) args), null, path));
}
return;
}
@@ -62,11 +62,11 @@ public class TaskUtils {
double d = Double.parseDouble(String.valueOf(object));
if (greaterThanZero && d <= 0) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR,
- String.format("Value for field '%s' must be greater than 0", (Object[]) args), path));
+ String.format("Value for field '%s' must be greater than 0", (Object[]) args), null, path));
}
} catch (ClassCastException ex) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR,
- String.format("Expected a number for '%s', but got '" + object + "' instead", (Object[]) args), path));
+ String.format("Expected a number for '%s', but got '" + object + "' instead", (Object[]) args), null, path));
}
}
@@ -74,7 +74,7 @@ public class TaskUtils {
if (object == null) {
if (!allowNull) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR,
- String.format("Expected an integer for '%s', but got null instead", (Object[]) args), path));
+ String.format("Expected an integer for '%s', but got null instead", (Object[]) args), null, path));
}
return;
}
@@ -83,11 +83,11 @@ public class TaskUtils {
Integer i = (Integer) object;
if (greaterThanZero && i <= 0) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR,
- String.format("Value for field '%s' must be greater than 0", (Object[]) args), path));
+ String.format("Value for field '%s' must be greater than 0", (Object[]) args), null, path));
}
} catch (ClassCastException ex) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR,
- String.format("Expected an integer for '%s', but got '" + object + "' instead", (Object[]) args), path));
+ String.format("Expected an integer for '%s', but got '" + object + "' instead", (Object[]) args), null, path));
}
}
@@ -95,7 +95,7 @@ public class TaskUtils {
if (object == null) {
if (!allowNull) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR,
- String.format("Expected a boolean for '%s', but got null instead", (Object[]) args), path));
+ String.format("Expected a boolean for '%s', but got null instead", (Object[]) args), null, path));
}
return;
}
@@ -104,7 +104,7 @@ public class TaskUtils {
Boolean b = (Boolean) object;
} catch (ClassCastException ex) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR,
- String.format("Expected a boolean for '%s', but got '" + object + "' instead", (Object[]) args), path));
+ String.format("Expected a boolean for '%s', but got '" + object + "' instead", (Object[]) args), null, path));
}
}
@@ -112,7 +112,7 @@ public class TaskUtils {
if (object == null) {
if (!allowNull) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR,
- String.format("Expected item configuration for '%s', but got null instead", (Object[]) args), path));
+ String.format("Expected item configuration for '%s', but got null instead", (Object[]) args), null, path));
}
return;
}
@@ -124,7 +124,9 @@ public class TaskUtils {
String type = section.getString("quest-item");
if (plugin.getQuestItemRegistry().getItem(section.getString("quest-item")) == null) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
- ConfigProblemDescriptions.UNKNOWN_QUEST_ITEM.getDescription(type), path + ".item.quest-item"));
+ ConfigProblemDescriptions.UNKNOWN_QUEST_ITEM.getDescription(type),
+ ConfigProblemDescriptions.UNKNOWN_QUEST_ITEM.getExtendedDescription(type),
+ path + ".item.quest-item"));
}
} else {
String itemloc = "item";
@@ -133,19 +135,25 @@ public class TaskUtils {
}
if (!section.contains(itemloc)) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
- ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(""), path + ".type"));
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(""),
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getExtendedDescription(""),
+ path + ".type"));
} else {
String type = String.valueOf(section.get(itemloc));
if (!plugin.getItemGetter().isValidMaterial(type)) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
- ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(type), path + itemloc));
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(type),
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getExtendedDescription(type),
+ path + itemloc));
}
}
}
} else {
if (Material.getMaterial(String.valueOf(object)) == null) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.WARNING,
- ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(String.valueOf(object)), path));
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getDescription(String.valueOf(object)),
+ ConfigProblemDescriptions.UNKNOWN_MATERIAL.getExtendedDescription(String.valueOf(object)),
+ path));
}
}
}
@@ -153,7 +161,9 @@ public class TaskUtils {
public static boolean configValidateExists(String path, Object object, List<ConfigProblem> problems, String... args) {
if (object == null) {
problems.add(new ConfigProblem(ConfigProblem.ConfigProblemType.ERROR,
- String.format(ConfigProblemDescriptions.TASK_MISSING_FIELD.getDescription(args), (Object[]) args), path));
+ ConfigProblemDescriptions.TASK_MISSING_FIELD.getDescription(args),
+ ConfigProblemDescriptions.TASK_MISSING_FIELD.getExtendedDescription(args),
+ path));
return false;
}
return true;
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/chat/Chat.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/chat/Chat.java
index 9f81b08b..64c2fdc8 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/chat/Chat.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/chat/Chat.java
@@ -1,8 +1,11 @@
package com.leonardobishop.quests.bukkit.util.chat;
+import com.leonardobishop.quests.bukkit.BukkitQuestsPlugin;
import com.leonardobishop.quests.common.config.ConfigProblem;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Entity;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
@@ -11,38 +14,42 @@ import java.util.List;
public class Chat {
- private static final ColorAdapter colorAdapter;
+ private static final ColorAdapter legacyColorAdapter;
+ private static final MiniMessageParser miniMessageParser;
static {
String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];;
if (version.startsWith("v1_7") || version.startsWith("v1_8") || version.startsWith("v1_9")
|| version.startsWith("v1_10") || version.startsWith("v1_11") || version.startsWith("v1_12")
|| version.startsWith("v1_13") || version.startsWith("v1_14") || version.startsWith("v1_15")) {
- colorAdapter = new CodedColorAdapter();
+ legacyColorAdapter = new CodedColorAdapter();
} else {
- colorAdapter = new HexColorAdapter();
+ legacyColorAdapter = new HexColorAdapter();
}
+ miniMessageParser = new MiniMessageParser(Bukkit.getPluginManager().getPlugin("Quests"));
}
@Contract("null -> null")
+ @Deprecated // use send instead
public static String color(@Nullable String s) {
- return colorAdapter.color(s);
+ return legacyColorAdapter.color(s);
}
@Contract("null -> null")
+ @Deprecated // use send instead
public static List<String> color(@Nullable List<String> s) {
if (s == null || s.size() == 0) return s;
List<String> colored = new ArrayList<>();
for (String line : s) {
- colored.add(colorAdapter.color(line));
+ colored.add(legacyColorAdapter.color(line));
}
return colored;
}
@Contract("null -> null")
public static String strip(@Nullable String s) {
- return colorAdapter.strip(s);
+ return legacyColorAdapter.strip(s);
}
public static ChatColor matchConfigProblemToColor(ConfigProblem.ConfigProblemType configProblem) {
@@ -56,4 +63,27 @@ public class Chat {
}
}
+ public static String matchConfigProblemToColorName(ConfigProblem.ConfigProblemType configProblem) {
+ switch (configProblem) {
+ case ERROR:
+ return "red";
+ case WARNING:
+ return "yellow";
+ default:
+ return "white";
+ }
+ }
+
+ /**
+ * Send a message to a given command sender. The given message will be parsed for legacy
+ * colours and minimessage formatting.
+ *
+ * @param who the player to send to
+ * @param message the message to send
+ */
+ public static void send(CommandSender who, String message) {
+// String colouredMessage = legacyColorAdapter.color(message);
+ miniMessageParser.send(who, message);
+ }
+
}
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/chat/MiniMessageParser.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/chat/MiniMessageParser.java
new file mode 100644
index 00000000..c27df430
--- /dev/null
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/chat/MiniMessageParser.java
@@ -0,0 +1,26 @@
+package com.leonardobishop.quests.bukkit.util.chat;
+
+import net.kyori.adventure.audience.Audience;
+import net.kyori.adventure.platform.bukkit.BukkitAudiences;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.MiniMessage;
+import org.bukkit.command.CommandSender;
+import org.bukkit.plugin.Plugin;
+
+public class MiniMessageParser {
+
+ private final BukkitAudiences adventure;
+ private final MiniMessage miniMessage;
+
+ public MiniMessageParser(Plugin plugin) {
+ adventure = BukkitAudiences.create(plugin);
+ miniMessage = MiniMessage.miniMessage();
+ }
+
+ public void send(CommandSender who, String message) {
+ Audience audience = adventure.sender(who);
+ Component component = miniMessage.deserialize(message);
+ audience.sendMessage(component);
+ }
+
+}
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 ? "<dark_grey>This error has no extended description</dark_grey>" : 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.<br>" +
+ "Quests cannot parse this file. Please resolve the error<br>" +
+ "below, or use an online YAML checker.<br><br>" +
+ "%s"
+ ),
+ INVALID_QUEST_ID(
+ "ID '%s' is invalid, must be alphanumeric, unique and with no spaces",
+ "ID '%s' is invalid. Either another quest is<br>" +
+ "using this ID, or it is not alphanumeric.<br><br>" +
+ "Examples:<br>" +
+ "Valid: 'abc'<br>" +
+ "Valid: 'ab-c'<br>" +
+ "Valid: 'ab-1'<br>" +
+ "Invalid: 'ab c'<br>" +
+ "Invalid: ' '"
+ ),
+ NO_TASKS(
+ "Quest contains no valid tasks",
+ "The quest does not contain any valid tasks.<br>" +
+ "This may be because of an improperly indented<br>" +
+ "tasks section, or because all specified task<br>" +
+ "types do not exist."
+ ),
+ NO_TASK_TYPE("Task type not specified",
+ "You have not specified a type for this task.<br>" +
+ "You can specify one with the 'type:' field."
+ ),
+ UNKNOWN_TASK_TYPE("Task type '%s' does not exist",
+ "The task type '%s' does not exist.<br>" +
+ "This may be because of a mis-typed name, or<br>" +
+ "a plugin which this task type depends on is<br>" +
+ "not present on the server."
+ ),
+ NO_DISPLAY_NAME("No name specified",
+ "No display name for this quest has been<br>" +
+ "specified. This name is used in all chat messages<br>" +
+ "and quest GUIs."
+ ),
+ NO_DISPLAY_MATERIAL("No material specified",
+ "No material for this quest display item<br>" +
+ "has been specified."
+ ),
+ UNKNOWN_QUEST_ITEM("Quest item '%s' does not exist",
+ "A quest item named '%s' does not exist.<br>" +
+ "Quest items are stored in /plugins/Quests/items,<br>" +
+ "by their ID. The ID does not include the .yml<br>" +
+ "extension."
+ ),
+ UNKNOWN_MATERIAL("Material '%s' does not exist",
+ "Material '%s' does not exist on the server.<br>" +
+ "Please refer to the wiki for a list of javadocs<br>" +
+ "corresponding to your server version. Alternatively,<br>" +
+ "you can find the material list by searching for your<br>" +
+ "server version + 'Material ENUM'."
+ ),
+ UNKNOWN_ENTITY_TYPE("Entity type '%s' does not exist",
+ "Entity type '%s' does not exist on the server.<br>" +
+ "Please refer to the wiki for a list of javadocs<br>" +
+ "corresponding to your server version. Alternatively,<br>" +
+ "you can find the material list by searching for your<br>" +
+ "server version + 'EntityType ENUM'."),
+ TASK_MALFORMED_NOT_SECTION("Task '%s' is not a configuration section",
+ "Task '%s' is not properly formatted as a<br>" +
+ "configuration section. Please review the wiki<br>" +
+ "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'<br>" +
+ "to function as expected. Please review<br>" +
+ "the relevant documentation on the wiki for<br>" +
+ "a list of mandatory fields."
+ ),
+ UNKNOWN_TASK_REFERENCE("Attempt to reference unknown task '%s'",
+ "A task by the ID '%s' has not been configured<br>" +
+ "for this quest. Note that the task ID can differ<br>" +
+ "from its task type. The ID is set by you; it is<br>" +
+ "the key for the task configuration section itself.<br><br>" +
+ "" +
+ "Example (highlighted in <bold>bold</bold>):<br>" +
+ "tasks:<br>" +
+ "<dark_grey>-></dark_grey><bold>task-id</bold>:<br>" +
+ "<dark_grey>---></dark_grey>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<br>" +
+ "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