mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 08:14:45 +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
@@ -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) {
|
||||
|
||||
@@ -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<String> missingBiomes) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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