Update about menu appearance, button colors

This commit is contained in:
William committed 2022-08-24 00:01:47 +01:00
1 parent e3194ba15a
commit 86c9251c37
2 files changed
+27 -9

No files matched your search

@@ -30,8 +30,8 @@ public class HuskHomesCommand extends CommandBase implements ConsoleExecutable,
AboutMenu.Credit.of("Log1x").withDescription("Code"))
.addButtons(
AboutMenu.Link.of("https://william278.net/docs/huskhomes").withText("Documentation").withIcon("⛏"),
AboutMenu.Link.of("https://github.com/WiIIiam278/HuskHomes2/issues").withText("Issues").withIcon("❌"),
AboutMenu.Link.of("https://discord.gg/tVYhJfyDWG").withText("Discord").withIcon("⭐"));
AboutMenu.Link.of("https://github.com/WiIIiam278/HuskHomes2/issues").withText("Issues").withIcon("❌").withColor("#ff9f0f"),
AboutMenu.Link.of("https://discord.gg/tVYhJfyDWG").withText("Discord").withIcon("⭐").withColor("#6773f5"));
}
@Override
@@ -27,7 +27,7 @@ public class AboutMenu {
private AboutMenu(@NotNull String title) {
this.title = title;
this.buttons = new ArrayList<>();
this.attributions = new HashMap<>();
this.attributions = new LinkedHashMap<>();
}
@NotNull
@@ -64,7 +64,8 @@ public class AboutMenu {
@NotNull
public MineDown toMineDown() {
final StringJoiner menu = new StringJoiner("\n")
.add("[" + title + "](#00fb9a bold)" + (version != null ? " [| Version " + version + "](#00fb9a)" : ""));
.add("[" + Locales.escapeMineDown(title) + "](#00fb9a bold)"
+ (version != null ? " [| Version " + Locales.escapeMineDown(version.toString()) + "](#00fb9a)" : ""));
if (description != null) {
menu.add("[" + Locales.escapeMineDown(description) + "](gray)");
}
@@ -75,9 +76,10 @@ public class AboutMenu {
for (Map.Entry<String, List<Credit>> entry : attributions.entrySet()) {
final StringJoiner creditJoiner = new StringJoiner(", ");
for (final Credit credit : entry.getValue()) {
creditJoiner.add("[" + credit.name + "](gray" +
(credit.description != null ? " show_text=&7" + credit.description : "") +
(credit.url != null ? " open_url=" + MineDown.escape(credit.url) : "") + ")");
creditJoiner.add("[" + credit.name + "](" + credit.color +
(credit.description != null ? " show_text=&7" + Locales.escapeMineDown(credit.description) : "") +
(credit.url != null ? " open_url=" + Locales.escapeMineDown(credit.url) : "")
+ ")");
}
if (!creditJoiner.toString().isBlank()) {
@@ -89,8 +91,8 @@ public class AboutMenu {
final StringJoiner buttonsJoiner = new StringJoiner(" ");
for (final Link link : buttons) {
buttonsJoiner.add("[[" + (link.icon != null ? link.icon + " " : "")
+ link.text + "…]](#00fb9a show_text=&7Click to open link open_url="
+ MineDown.escape(link.url) + ")");
+ Locales.escapeMineDown(link.text) + "…]](" + link.color + " "
+ "show_text=&7Click to open link open_url=" + Locales.escapeMineDown(link.url) + ")");
}
menu.add("").add("[Links:](gray) " + buttonsJoiner);
}
@@ -135,6 +137,9 @@ public class AboutMenu {
@NotNull
private String text = "Link";
@NotNull
private String color = "#00fb9a";
@Nullable
private String icon;
@@ -159,6 +164,11 @@ public class AboutMenu {
return this;
}
public Link withColor(@NotNull String color) {
this.color = color;
return this;
}
}
public static class Credit {
@@ -171,6 +181,9 @@ public class AboutMenu {
@Nullable
private String url;
@NotNull
private String color = "gray";
private Credit(@NotNull String name) {
this.name = name;
}
@@ -189,6 +202,11 @@ public class AboutMenu {
return this;
}
public Credit withColor(@NotNull String color) {
this.color = color;
return this;
}
}
}