mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-01 18:24:06 +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;
|
: BukkitRuntimeMessages.COMMAND_PACK_STATUS_BROKEN;
|
||||||
String line = IrisLanguage.text(
|
String line = IrisLanguage.text(
|
||||||
key,
|
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("blocking", statusCount(result.getBlockingErrors().size(), C.RED)),
|
||||||
MessageArgument.trusted("warnings", statusCount(result.getWarnings().size(), C.GOLD)));
|
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) {
|
private static ChatReport.Tone statusTone(PackValidationResult result) {
|
||||||
@@ -460,7 +460,7 @@ public class CommandPack implements DirectorExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String statusCount(int count, C color) {
|
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) {
|
static ChatReport validationReport(PackValidationResult result) {
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ public class CommandStructure implements DirectorExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String verifyCount(int count, String label, C color) {
|
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) {
|
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")
|
@Director(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", descriptionKey = "iris.director.commandstudio.director.studio_commands")
|
||||||
public class CommandStudio implements DirectorExecutor {
|
public class CommandStudio implements DirectorExecutor {
|
||||||
private static final long CHUNK_SCAN_TIMEOUT_MS = 3_000;
|
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 CommandEdit edit;
|
||||||
//private CommandDeepSearch deepSearch;
|
//private CommandDeepSearch deepSearch;
|
||||||
|
|
||||||
@@ -268,9 +269,8 @@ public class CommandStudio implements DirectorExecutor {
|
|||||||
return;
|
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)))
|
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));
|
||||||
.hint(regenStopHint(world), regenStopCommand(world))
|
commandSender.sendReport(withRegenStopHint(ChatReport.of(ChatReport.Tone.INFO, started), world).build());
|
||||||
.build());
|
|
||||||
Iris.info("Regen run start: world=" + world.getName()
|
Iris.info("Regen run start: world=" + world.getName()
|
||||||
+ " center=" + centerX + "," + centerZ
|
+ " center=" + centerX + "," + centerZ
|
||||||
+ " radius=" + radius
|
+ " radius=" + radius
|
||||||
@@ -306,17 +306,12 @@ public class CommandStudio implements DirectorExecutor {
|
|||||||
MessageArgument.untrusted("world", world.getName()),
|
MessageArgument.untrusted("world", world.getName()),
|
||||||
MessageArgument.trusted("applied", running.appliedChunks()),
|
MessageArgument.trusted("applied", running.appliedChunks()),
|
||||||
MessageArgument.trusted("total", running.totalChunks() <= 0 ? "?" : running.totalChunks()));
|
MessageArgument.trusted("total", running.totalChunks() <= 0 ? "?" : running.totalChunks()));
|
||||||
sender.sendReport(ChatReport.of(ChatReport.Tone.WARNING, alreadyRunning)
|
sender.sendReport(withRegenStopHint(ChatReport.of(ChatReport.Tone.WARNING, alreadyRunning), world).build());
|
||||||
.hint(regenStopHint(world), regenStopCommand(world))
|
|
||||||
.build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String regenStopCommand(World world) {
|
private static ChatReport.Builder withRegenStopHint(ChatReport.Builder report, World world) {
|
||||||
return "/iris std regen-stop world=" + world.getName();
|
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());
|
||||||
|
|
||||||
private static String regenStopHint(World world) {
|
|
||||||
return IrisLanguage.text(RuntimeProgressMessages.CHUNK_STOP_HINT, MessageArgument.untrusted("command", regenStopCommand(world)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Director(description = "Toggle your Studio debug scoreboard", descriptionKey = "iris.director.commandstudio.director.toggle_your_studio_debug_scoreboard", aliases = {"board", "sidebar", "sb"}, origin = DirectorOrigin.PLAYER)
|
@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) {
|
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);
|
String cleaned = clean(text);
|
||||||
this.hint = command == null ? cleaned : cleaned.replace(command, highlight(command));
|
this.hint = shownCommand == null ? cleaned : cleaned.replace(shownCommand, highlight(shownCommand));
|
||||||
this.hintCommand = command;
|
this.hintCommand = clickCommand;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ final class ReportText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static String title(ChatReport.Tone tone, String plain) {
|
static String title(ChatReport.Tone tone, String plain) {
|
||||||
String base = tone.color().toString() + C.BOLD;
|
String base = tone.color().toString();
|
||||||
return base + highlightQuoted(plain, C.WHITE.toString() + C.BOLD, base);
|
return base + highlightQuoted(plain, C.WHITE.toString(), base);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String body(String plain) {
|
static String body(String plain) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.junit.Test;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class ChatReportTest {
|
public class ChatReportTest {
|
||||||
@@ -62,16 +63,35 @@ public class ChatReportTest {
|
|||||||
public void apostrophesAreNotTreatedAsQuotedNames() {
|
public void apostrophesAreNotTreatedAsQuotedNames() {
|
||||||
String styled = ReportText.title(ChatReport.Tone.ERROR, "Can't open Studio for 'uitest'");
|
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
|
@Test
|
||||||
public void boldTitlesSurviveTheMarkupConversion() {
|
public void titlesStayRegularWeight() {
|
||||||
String markup = C.mini(ReportText.title(ChatReport.Tone.ERROR, "Title") + C.GRAY + " rest");
|
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"));
|
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) {
|
private static List<String> plainLines(ChatReport report) {
|
||||||
return report.lines().stream().map(line -> line.text().replaceAll("§.", "")).toList();
|
return report.lines().stream().map(line -> line.text().replaceAll("§.", "")).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user