mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Lighter report weight
- Keep bold only on the Iris tag - Show the short regen-stop command; the click still targets the world
This commit is contained in:
1 parent
496bdab2c3
commit
6dd22fa34e
6 files changed
+43
-23
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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("<bold>Title<reset><gray> 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<String> plainLines(ChatReport report) {
|
||||
return report.lines().stream().map(line -> line.text().replaceAll("§.", "")).toList();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user