Skip to content

Commit

Permalink
Add extended description to warning type
Browse files Browse the repository at this point in the history
  • Loading branch information
LMBishop committed Jul 6, 2022
1 parent 77cded0 commit 417a5fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,25 @@ public static void showProblems(CommandSender sender, Map<String, List<ConfigPro
for (ConfigProblem problem : sortedProblems.get(type)) {
if (Chat.isModernChatAvailable()) {
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>",
String extendedDescription = problem.getExtendedDescription() != null ? 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()
);
) : "<dark_grey>This error has no extended description</dark_grey>";
extendedDescription = extendedDescription.replace("'", "\\'");
String problemDescription = String.format("<%s>%s</%s><br>%s",
color,
problem.getType().getTitle(),
color,
problem.getType().getDescription()
);
problemDescription = problemDescription.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>",
"<dark_gray> | - </dark_gray><hover:show_text:'%s'><%s>%s</%s></hover><dark_gray>:</dark_gray> <hover:show_text:'%s'><gray>%s</gray></hover><dark_gray> :%s</dark_gray>",
problemDescription,
color,
problem.getType().getShortened(),
color,
Expand Down Expand Up @@ -90,7 +98,9 @@ public static void showProblems(CommandSender sender, Map<String, List<ConfigPro
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.");
if (Chat.isModernChatAvailable()) {
sender.sendMessage(ChatColor.DARK_GRAY + "Mouse-over for more information.");
}
} else {
sender.sendMessage(ChatColor.GRAY + "Quests did not detect any problems with your configuration.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public final class ConfigProblem {
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.extendedDescription = extendedDescription;
this.location = location == null ? "?" : location;
}

Expand All @@ -36,17 +36,19 @@ public String getLocation() {

public enum ConfigProblemType {

ERROR("Error", "E", 1),
WARNING("Warning", "W", 2);
ERROR("Error", "E", 1, "An error prevents a quest from being loaded"),
WARNING("Warning", "W", 2, "A warning indicates a quest may not work as expected");

private final String title;
private final String shortened;
private final int priority;
private final String description;

ConfigProblemType(String title, String shortened, int priority) {
ConfigProblemType(String title, String shortened, int priority, String description) {
this.title = title;
this.shortened = shortened;
this.priority = priority;
this.description = description;
}

public String getTitle() {
Expand All @@ -61,5 +63,8 @@ public int getPriority() {
return priority;
}

public String getDescription() {
return description;
}
}
}

0 comments on commit 417a5fa

Please sign in to comment.