diff --git a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandPack.java b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandPack.java index 8b5c4b8ee..a6ccbc500 100644 --- a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandPack.java +++ b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandPack.java @@ -448,10 +448,10 @@ public class CommandPack implements DirectorExecutor { : BukkitRuntimeMessages.COMMAND_PACK_STATUS_BROKEN; String line = IrisLanguage.text( key, - MessageArgument.trusted("pack", C.WHITE.toString() + C.BOLD + ChatReport.clean(name)), + MessageArgument.trusted("pack", C.WHITE + ChatReport.clean(name)), MessageArgument.trusted("blocking", statusCount(result.getBlockingErrors().size(), C.RED)), MessageArgument.trusted("warnings", statusCount(result.getWarnings().size(), C.GOLD))); - return LEADING_COLOR.matcher(line).replaceFirst(statusTone(result).color().toString() + C.BOLD); + return LEADING_COLOR.matcher(line).replaceFirst(statusTone(result).color().toString()); } private static ChatReport.Tone statusTone(PackValidationResult result) { @@ -460,7 +460,7 @@ public class CommandPack implements DirectorExecutor { } private static String statusCount(int count, C color) { - return (count == 0 ? C.DARK_GRAY.toString() : color.toString() + C.BOLD) + count + C.GRAY; + return (count == 0 ? C.DARK_GRAY : color) + String.valueOf(count) + C.GRAY; } static ChatReport validationReport(PackValidationResult result) { diff --git a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandStructure.java b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandStructure.java index 4bf46cf94..4496692f5 100644 --- a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandStructure.java +++ b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandStructure.java @@ -265,7 +265,7 @@ public class CommandStructure implements DirectorExecutor { } private static String verifyCount(int count, String label, C color) { - return count == 0 ? "" : color.toString() + C.BOLD + count + C.GRAY + " " + label; + return count == 0 ? "" : color.toString() + count + C.GRAY + " " + label; } private static String unreachableLine(String keyName, List missingBiomes) { diff --git a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandStudio.java b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandStudio.java index af5e42d86..1f649e39d 100644 --- a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandStudio.java +++ b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandStudio.java @@ -116,6 +116,7 @@ import art.arcane.iris.localization.BukkitCommandMessagesExtended; @Director(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", descriptionKey = "iris.director.commandstudio.director.studio_commands") public class CommandStudio implements DirectorExecutor { private static final long CHUNK_SCAN_TIMEOUT_MS = 3_000; + private static final String REGEN_STOP_COMMAND = "/iris std regen-stop"; private CommandEdit edit; //private CommandDeepSearch deepSearch; @@ -268,9 +269,8 @@ public class CommandStudio implements DirectorExecutor { return; } - commandSender.sendReport(ChatReport.of(ChatReport.Tone.INFO, IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_REGEN_STARTED_CHUNK_S_AROUND_DELETING_REGENERATING_PLACE, MessageArgument.untrusted("chunks", chunks), MessageArgument.untrusted("centerX", centerX), MessageArgument.untrusted("centerZ", centerZ))) - .hint(regenStopHint(world), regenStopCommand(world)) - .build()); + String started = IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_REGEN_STARTED_CHUNK_S_AROUND_DELETING_REGENERATING_PLACE, MessageArgument.untrusted("chunks", chunks), MessageArgument.untrusted("centerX", centerX), MessageArgument.untrusted("centerZ", centerZ)); + commandSender.sendReport(withRegenStopHint(ChatReport.of(ChatReport.Tone.INFO, started), world).build()); Iris.info("Regen run start: world=" + world.getName() + " center=" + centerX + "," + centerZ + " radius=" + radius @@ -306,17 +306,12 @@ public class CommandStudio implements DirectorExecutor { MessageArgument.untrusted("world", world.getName()), MessageArgument.trusted("applied", running.appliedChunks()), MessageArgument.trusted("total", running.totalChunks() <= 0 ? "?" : running.totalChunks())); - sender.sendReport(ChatReport.of(ChatReport.Tone.WARNING, alreadyRunning) - .hint(regenStopHint(world), regenStopCommand(world)) - .build()); + sender.sendReport(withRegenStopHint(ChatReport.of(ChatReport.Tone.WARNING, alreadyRunning), world).build()); } - private static String regenStopCommand(World world) { - return "/iris std regen-stop world=" + world.getName(); - } - - private static String regenStopHint(World world) { - return IrisLanguage.text(RuntimeProgressMessages.CHUNK_STOP_HINT, MessageArgument.untrusted("command", regenStopCommand(world))); + private static ChatReport.Builder withRegenStopHint(ChatReport.Builder report, World world) { + String hint = IrisLanguage.text(RuntimeProgressMessages.CHUNK_STOP_HINT, MessageArgument.untrusted("command", REGEN_STOP_COMMAND)); + return report.hint(hint, REGEN_STOP_COMMAND, REGEN_STOP_COMMAND + " world=" + world.getName()); } @Director(description = "Toggle your Studio debug scoreboard", descriptionKey = "iris.director.commandstudio.director.toggle_your_studio_debug_scoreboard", aliases = {"board", "sidebar", "sb"}, origin = DirectorOrigin.PLAYER) diff --git a/core/src/main/java/art/arcane/iris/localization/ChatReport.java b/core/src/main/java/art/arcane/iris/localization/ChatReport.java index 582edab21..2ec13b896 100644 --- a/core/src/main/java/art/arcane/iris/localization/ChatReport.java +++ b/core/src/main/java/art/arcane/iris/localization/ChatReport.java @@ -178,9 +178,14 @@ public final class ChatReport { } public Builder hint(String text, String command) { + return hint(text, command, command); + } + + /** Shows {@code shownCommand} in the hint text while a click runs {@code clickCommand}. */ + public Builder hint(String text, String shownCommand, String clickCommand) { String cleaned = clean(text); - this.hint = command == null ? cleaned : cleaned.replace(command, highlight(command)); - this.hintCommand = command; + this.hint = shownCommand == null ? cleaned : cleaned.replace(shownCommand, highlight(shownCommand)); + this.hintCommand = clickCommand; return this; } diff --git a/core/src/main/java/art/arcane/iris/localization/ReportText.java b/core/src/main/java/art/arcane/iris/localization/ReportText.java index 3f6813b25..35b74456d 100644 --- a/core/src/main/java/art/arcane/iris/localization/ReportText.java +++ b/core/src/main/java/art/arcane/iris/localization/ReportText.java @@ -31,8 +31,8 @@ final class ReportText { } static String title(ChatReport.Tone tone, String plain) { - String base = tone.color().toString() + C.BOLD; - return base + highlightQuoted(plain, C.WHITE.toString() + C.BOLD, base); + String base = tone.color().toString(); + return base + highlightQuoted(plain, C.WHITE.toString(), base); } static String body(String plain) { diff --git a/core/src/test/java/art/arcane/iris/localization/ChatReportTest.java b/core/src/test/java/art/arcane/iris/localization/ChatReportTest.java index 2059679e6..8a87869dd 100644 --- a/core/src/test/java/art/arcane/iris/localization/ChatReportTest.java +++ b/core/src/test/java/art/arcane/iris/localization/ChatReportTest.java @@ -5,6 +5,7 @@ import org.junit.Test; import java.util.List; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class ChatReportTest { @@ -62,16 +63,35 @@ public class ChatReportTest { public void apostrophesAreNotTreatedAsQuotedNames() { String styled = ReportText.title(ChatReport.Tone.ERROR, "Can't open Studio for 'uitest'"); - assertTrue(styled.contains("Can't open Studio for " + C.WHITE + C.BOLD + "'uitest'")); + assertTrue(styled.contains("Can't open Studio for " + C.WHITE + "'uitest'")); } @Test - public void boldTitlesSurviveTheMarkupConversion() { - String markup = C.mini(ReportText.title(ChatReport.Tone.ERROR, "Title") + C.GRAY + " rest"); + public void titlesStayRegularWeight() { + String styled = ReportText.title(ChatReport.Tone.ERROR, "Can't open Studio for 'uitest'"); + + assertFalse(styled.contains(C.BOLD.toString())); + } + + @Test + public void boldCodesSurviveTheMarkupConversion() { + String markup = C.mini(C.RED.toString() + C.BOLD + "Title" + C.GRAY + " rest"); assertTrue(markup, markup.contains("Title rest")); } + @Test + public void hintCanShowAShorterCommandThanItRuns() { + ChatReport.Line hint = ChatReport.of(ChatReport.Tone.INFO, "t") + .hint("Stop it with /iris std regen-stop", "/iris std regen-stop", "/iris std regen-stop world=w") + .build() + .lines() + .getLast(); + + assertEquals("Stop it with /iris std regen-stop", hint.text().replaceAll("§.", "")); + assertEquals("/iris std regen-stop world=w", hint.command()); + } + private static List plainLines(ChatReport report) { return report.lines().stream().map(line -> line.text().replaceAll("§.", "")).toList(); }