mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-02 02:34:24 +00:00
Lay out console output on a status gutter
Aligned label rows and next-step commands, per CLI guidelines
This commit is contained in:
1 parent
6fb25fb53e
commit
46b5c33cf1
19 files changed
+451
-157
No files matched your search
@@ -40,12 +40,20 @@ final class IrisBootstrapSequence {
|
|||||||
requireUsableWorldStorage(startupPaths);
|
requireUsableWorldStorage(startupPaths);
|
||||||
ProvisionResult provisioned = provision(context, startupPaths);
|
ProvisionResult provisioned = provision(context, startupPaths);
|
||||||
Path datapackRoot = provisioned.datapackRoot();
|
Path datapackRoot = provisioned.datapackRoot();
|
||||||
context.getLogger().info("Iris startup datapack is {} at {}", provisioned.status(), datapackRoot);
|
context.getLogger().info("{} {}", provisionOutcome(provisioned.status()), datapackRoot);
|
||||||
} catch (Throwable failure) {
|
} catch (Throwable failure) {
|
||||||
armStartupFailure(context, failure);
|
armStartupFailure(context, failure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String provisionOutcome(DefaultPackBootstrapProvisioner.ProvisionStatus status) {
|
||||||
|
return switch (status) {
|
||||||
|
case INSTALLED -> "Installed the startup datapack at";
|
||||||
|
case UPDATED -> "Updated the startup datapack at";
|
||||||
|
case UNCHANGED -> "The startup datapack is already up to date at";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private static void loadRuntimeLibraries(BootstrapContext context) {
|
private static void loadRuntimeLibraries(BootstrapContext context) {
|
||||||
SlimJar.loadBootstrap(
|
SlimJar.loadBootstrap(
|
||||||
context.getDataDirectory().resolve("cache").resolve("libraries"),
|
context.getDataDirectory().resolve("cache").resolve("libraries"),
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import art.arcane.iris.integration.MultiverseSVC;
|
|||||||
import art.arcane.iris.localization.C;
|
import art.arcane.iris.localization.C;
|
||||||
import art.arcane.iris.localization.ChatReport;
|
import art.arcane.iris.localization.ChatReport;
|
||||||
import art.arcane.iris.localization.ConsoleGlyphs;
|
import art.arcane.iris.localization.ConsoleGlyphs;
|
||||||
|
import art.arcane.iris.localization.ConsoleLayout;
|
||||||
import art.arcane.iris.localization.IrisLanguage;
|
import art.arcane.iris.localization.IrisLanguage;
|
||||||
import art.arcane.iris.pack.datapack.DatapackIngestService;
|
import art.arcane.iris.pack.datapack.DatapackIngestService;
|
||||||
import art.arcane.iris.pack.datapack.DatapackIngestService.StartupValidationOutcome;
|
import art.arcane.iris.pack.datapack.DatapackIngestService.StartupValidationOutcome;
|
||||||
@@ -145,6 +146,7 @@ import java.io.PrintStream;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -311,7 +313,7 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
|||||||
static void msg(String string) {
|
static void msg(String string) {
|
||||||
try {
|
try {
|
||||||
Iris plugin = Iris.instance;
|
Iris plugin = Iris.instance;
|
||||||
String markup = ConsoleGlyphs.console().fit(string);
|
String markup = ConsoleGlyphs.console().fit(ConsoleLayout.onGutter(ChatReport.Tone.INFO, string));
|
||||||
if (shadesConsole()) {
|
if (shadesConsole()) {
|
||||||
logShaded(Level.INFO, logPrefix() + markup);
|
logShaded(Level.INFO, logPrefix() + markup);
|
||||||
return;
|
return;
|
||||||
@@ -409,11 +411,11 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void success(String string) {
|
static void success(String string) {
|
||||||
Iris.msg(C.IRIS + string);
|
Iris.msg(ChatReport.Tone.SUCCESS.marked(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void info(String format, Object... args) {
|
static void info(String format, Object... args) {
|
||||||
Iris.msg(C.WHITE + safeFormat(format, args));
|
Iris.msg(safeFormat(format, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String safeFormat(String format, Object... args) {
|
private static String safeFormat(String format, Object... args) {
|
||||||
@@ -608,7 +610,7 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void diagnostic(Level level, String rawMessage) {
|
private static void diagnostic(Level level, String rawMessage) {
|
||||||
String message = ConsoleGlyphs.console().fit(rawMessage);
|
String message = ConsoleGlyphs.console().fit(ConsoleLayout.onGutter(diagnosticTone(level), rawMessage));
|
||||||
if (shadesConsole()) {
|
if (shadesConsole()) {
|
||||||
logShaded(level, logPrefix() + C.escapeTags(message));
|
logShaded(level, logPrefix() + C.escapeTags(message));
|
||||||
return;
|
return;
|
||||||
@@ -623,6 +625,13 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
|||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ChatReport.Tone diagnosticTone(Level level) {
|
||||||
|
if (level == Level.SEVERE) {
|
||||||
|
return ChatReport.Tone.ERROR;
|
||||||
|
}
|
||||||
|
return level == Level.WARNING ? ChatReport.Tone.WARNING : ChatReport.Tone.INFO;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean shadesConsole() {
|
private static boolean shadesConsole() {
|
||||||
return IrisSettings.get().getGeneral().isUseConsoleCustomColors();
|
return IrisSettings.get().getGeneral().isUseConsoleCustomColors();
|
||||||
}
|
}
|
||||||
@@ -859,21 +868,33 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
|||||||
|
|
||||||
private void report() {
|
private void report() {
|
||||||
String total = seconds(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startedAt));
|
String total = seconds(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startedAt));
|
||||||
String phases = slowestFirst(phaseMillis, REPORTED_PHASE_MIN_MS);
|
IrisLogging.notice(ChatReport.Tone.SUCCESS.marked(C.BOLD + "Enabled in " + total));
|
||||||
String enabled = phases.isEmpty() ? "Enabled in " + total : "Enabled in " + total + " (" + phases + ")";
|
slowestFirst(phaseMillis, REPORTED_PHASE_MIN_MS)
|
||||||
IrisLogging.notice(ChatReport.Tone.SUCCESS.marked(C.RESET + enabled));
|
.forEach(phase -> logRow(titleCase(phase.getKey()), seconds(phase.getValue())));
|
||||||
String slowServices = slowestFirst(serviceMillis, SLOW_SERVICE_MIN_MS);
|
String slowServices = slowestFirst(serviceMillis, SLOW_SERVICE_MIN_MS).stream()
|
||||||
|
.map(service -> service.getKey() + " " + seconds(service.getValue()))
|
||||||
|
.collect(Collectors.joining(", "));
|
||||||
if (!slowServices.isEmpty()) {
|
if (!slowServices.isEmpty()) {
|
||||||
IrisLogging.notice("Slow services: " + slowServices);
|
logRow("Slow Services", slowServices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String slowestFirst(Map<String, Long> millisByName, long minimumMillis) {
|
private static void logRow(String label, String value) {
|
||||||
|
ConsoleLayout.labelRows(label, value).forEach(IrisLogging::notice);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Map.Entry<String, Long>> slowestFirst(Map<String, Long> millisByName, long minimumMillis) {
|
||||||
return millisByName.entrySet().stream()
|
return millisByName.entrySet().stream()
|
||||||
.filter(entry -> entry.getValue() >= minimumMillis)
|
.filter(entry -> entry.getValue() >= minimumMillis)
|
||||||
.sorted(Map.Entry.<String, Long>comparingByValue().reversed())
|
.sorted(Map.Entry.<String, Long>comparingByValue().reversed())
|
||||||
.map(entry -> entry.getKey() + " " + seconds(entry.getValue()))
|
.toList();
|
||||||
.collect(Collectors.joining(", "));
|
}
|
||||||
|
|
||||||
|
private static String titleCase(String camelCaseName) {
|
||||||
|
String spaced = camelCaseName.replaceAll("(?<=[a-z])(?=[A-Z])", " ");
|
||||||
|
return Arrays.stream(spaced.split(" "))
|
||||||
|
.map(word -> word.isEmpty() ? word : Character.toUpperCase(word.charAt(0)) + word.substring(1))
|
||||||
|
.collect(Collectors.joining(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String seconds(long millis) {
|
private static String seconds(long millis) {
|
||||||
|
|||||||
+6
-5
@@ -51,20 +51,21 @@ final class IrisEngineStatus {
|
|||||||
private static ChatReport section(TextKey header, String... statLines) {
|
private static ChatReport section(TextKey header, String... statLines) {
|
||||||
ChatReport.Builder report = ChatReport.of(ChatReport.Tone.INFO, stripTrailingColon(IrisLanguage.text(header))).unlimited();
|
ChatReport.Builder report = ChatReport.of(ChatReport.Tone.INFO, stripTrailingColon(IrisLanguage.text(header))).unlimited();
|
||||||
for (String statLine : statLines) {
|
for (String statLine : statLines) {
|
||||||
report.styledItem(themedStat(statLine));
|
addStat(report, statLine);
|
||||||
}
|
}
|
||||||
return report.build();
|
return report.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Status keys render as {@code - Label: value}; the label and value are recoloured to the Iris theme. */
|
/** Status keys render as {@code - Label: value}; a labelled stat becomes a report entry, anything else a plain item. */
|
||||||
private static String themedStat(String statLine) {
|
private static void addStat(ChatReport.Builder report, String statLine) {
|
||||||
String cleaned = ChatReport.clean(statLine);
|
String cleaned = ChatReport.clean(statLine);
|
||||||
String withoutDash = cleaned.startsWith("-") ? cleaned.substring(1).strip() : cleaned;
|
String withoutDash = cleaned.startsWith("-") ? cleaned.substring(1).strip() : cleaned;
|
||||||
int separator = withoutDash.indexOf(": ");
|
int separator = withoutDash.indexOf(": ");
|
||||||
if (separator < 0) {
|
if (separator < 0) {
|
||||||
return withoutDash;
|
report.styledItem(withoutDash);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return ChatReport.label(withoutDash.substring(0, separator), withoutDash.substring(separator + 2));
|
report.entry(withoutDash.substring(0, separator), withoutDash.substring(separator + 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String stripTrailingColon(String header) {
|
private static String stripTrailingColon(String header) {
|
||||||
|
|||||||
+1
-1
@@ -240,7 +240,7 @@ public final class IrisWorldGeneratorResolver {
|
|||||||
if (hasPendingExternalContent(result, IrisServices.getOrNull(ExternalDataSVC.class))
|
if (hasPendingExternalContent(result, IrisServices.getOrNull(ExternalDataSVC.class))
|
||||||
&& packDirectory != null
|
&& packDirectory != null
|
||||||
&& PackValidator.validateForDatapackBootstrap(packDirectory).isLoadable()) {
|
&& PackValidator.validateForDatapackBootstrap(packDirectory).isLoadable()) {
|
||||||
Iris.info("Pack '" + result.getPackName() + "' is waiting for external block providers to initialize.");
|
Iris.info("Waiting for external block providers before loading pack '" + result.getPackName() + "'…");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PackBootReporter.logBroken(result, minecraftVersion);
|
PackBootReporter.logBroken(result, minecraftVersion);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package art.arcane.iris.diagnostics.splash;
|
package art.arcane.iris.diagnostics.splash;
|
||||||
|
|
||||||
import art.arcane.iris.BuildConstants;
|
import art.arcane.iris.BuildConstants;
|
||||||
|
import art.arcane.iris.localization.ConsoleLayout;
|
||||||
import art.arcane.iris.pack.BuiltInPackUpdates;
|
import art.arcane.iris.pack.BuiltInPackUpdates;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@@ -17,6 +18,8 @@ public final class IrisSplashComposer {
|
|||||||
private static final int SPARE_INFO_ROWS = 3;
|
private static final int SPARE_INFO_ROWS = 3;
|
||||||
private static final int PACKS_SHOWN = 6;
|
private static final int PACKS_SHOWN = 6;
|
||||||
private static final int SHORT_COMMIT_LENGTH = 7;
|
private static final int SHORT_COMMIT_LENGTH = 7;
|
||||||
|
private static final int LABEL_WIDTH = 14;
|
||||||
|
private static final String FACT_GAP = " ";
|
||||||
|
|
||||||
private IrisSplashComposer() {
|
private IrisSplashComposer() {
|
||||||
}
|
}
|
||||||
@@ -50,17 +53,23 @@ public final class IrisSplashComposer {
|
|||||||
return hidden > 0 ? shown + " +" + hidden + " more" : shown;
|
return hidden > 0 ? shown + " +" + hidden + " more" : shown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The first fact's value starts in the shared value column; further facts on the row follow after a gap. */
|
||||||
private static String styledRow(List<Detail> row, InfoStyle style) {
|
private static String styledRow(List<Detail> row, InfoStyle style) {
|
||||||
StringBuilder styled = new StringBuilder();
|
StringBuilder styled = new StringBuilder();
|
||||||
for (Detail detail : row) {
|
for (Detail detail : row) {
|
||||||
String separator = styled.isEmpty() ? " " : " | ";
|
String label = styled.isEmpty()
|
||||||
String label = separator + detail.label() + ": ";
|
? " " + padRight(detail.label(), LABEL_WIDTH)
|
||||||
|
: FACT_GAP + detail.label() + " ";
|
||||||
styled.append(detail.key() ? style.label(label) : style.quietLabel(label))
|
styled.append(detail.key() ? style.label(label) : style.quietLabel(label))
|
||||||
.append(detail.key() ? style.value(detail.value()) : style.quietValue(detail.value()));
|
.append(detail.key() ? style.value(detail.value()) : style.quietValue(detail.value()));
|
||||||
}
|
}
|
||||||
return styled.toString();
|
return styled.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String padRight(String text, int width) {
|
||||||
|
return text + " ".repeat(Math.max(1, width - text.length()));
|
||||||
|
}
|
||||||
|
|
||||||
private static String shortCommit() {
|
private static String shortCommit() {
|
||||||
String commit = BuildConstants.COMMIT;
|
String commit = BuildConstants.COMMIT;
|
||||||
return commit.length() > SHORT_COMMIT_LENGTH ? commit.substring(0, SHORT_COMMIT_LENGTH) : commit;
|
return commit.length() > SHORT_COMMIT_LENGTH ? commit.substring(0, SHORT_COMMIT_LENGTH) : commit;
|
||||||
@@ -69,15 +78,16 @@ public final class IrisSplashComposer {
|
|||||||
private static String[] composeHeader(String version, String serverLine, InfoStyle style) {
|
private static String[] composeHeader(String version, String serverLine, InfoStyle style) {
|
||||||
String releaseTrain = releaseTrain(version);
|
String releaseTrain = releaseTrain(version);
|
||||||
String prefix = style.linePrefix();
|
String prefix = style.linePrefix();
|
||||||
|
String java = javaVersion() < 0 ? "unknown" : String.valueOf(javaVersion());
|
||||||
return new String[]{
|
return new String[]{
|
||||||
"",
|
"",
|
||||||
prefix + style.title(" Iris, ") + style.subtitle("Dimension Engine ") + style.tag("[" + releaseTrain + "]"),
|
prefix + style.title(" Iris, ") + style.subtitle("Dimension Engine ") + style.tag("[" + releaseTrain + "]"),
|
||||||
prefix + style.label(" Version: ") + style.value(version),
|
prefix + styledRow(List.of(Detail.key("Version", version)), style),
|
||||||
prefix + style.quietLabel(" By: ") + style.quietValue("Volmit Software (Arcane Arts)"),
|
prefix + styledRow(List.of(new Detail("By", "Volmit Software (Arcane Arts)")), style),
|
||||||
prefix + style.quietLabel(" Web: ") + style.quietValue("VolmitSoftware.com"),
|
prefix + styledRow(List.of(new Detail("Web", "VolmitSoftware.com")), style),
|
||||||
prefix + style.label(" Server: ") + style.value(serverLine),
|
prefix + styledRow(List.of(Detail.key("Server", serverLine)), style),
|
||||||
prefix + style.quietLabel(" Java: ") + style.quietValue(javaVersion() < 0 ? "unknown" : String.valueOf(javaVersion())) + style.quietLabel(" | Date: ") + style.quietValue(startupDate()),
|
prefix + styledRow(List.of(new Detail("Java", java), new Detail("Date", startupDate())), style),
|
||||||
prefix + style.label(" Commit: ") + style.value(shortCommit()) + style.label("/") + style.value(BuildConstants.ENVIRONMENT),
|
prefix + styledRow(List.of(Detail.key("Commit", shortCommit() + "/" + BuildConstants.ENVIRONMENT)), style),
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
""
|
""
|
||||||
@@ -103,7 +113,9 @@ public final class IrisSplashComposer {
|
|||||||
for (IrisSplashPackScanner.SplashPackMetadata pack : packs) {
|
for (IrisSplashPackScanner.SplashPackMetadata pack : packs) {
|
||||||
BuiltInPackUpdates.Update update = updates.get(pack.name());
|
BuiltInPackUpdates.Update update = updates.get(pack.name());
|
||||||
if (update != null && update.newerThan(pack.version())) {
|
if (update != null && update.newerThan(pack.version())) {
|
||||||
lines.add("Update " + pack.name() + ": /iris download pack=" + pack.name() + " overwrite=true");
|
lines.add(ConsoleLayout.row("Pack " + pack.name() + " v" + update.version()
|
||||||
|
+ " is available. You have v" + pack.version() + "."));
|
||||||
|
lines.addAll(ConsoleLayout.nextStep("Update it", "/iris download pack=" + pack.name() + " overwrite=true"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public final class BukkitRuntimeMessages {
|
|||||||
);
|
);
|
||||||
public static final TextKey COMMAND_PACK_PACK_IS_BROKEN = TextKey.of(
|
public static final TextKey COMMAND_PACK_PACK_IS_BROKEN = TextKey.of(
|
||||||
"iris.bukkit.runtime.commandpack.pack_is_broken",
|
"iris.bukkit.runtime.commandpack.pack_is_broken",
|
||||||
C.RED + "Pack '" + "{packName}" + "' is BROKEN:"
|
C.RED + "Pack '" + "{packName}" + "' is broken"
|
||||||
);
|
);
|
||||||
public static final TextKey COMMAND_PACK_MESSAGE = TextKey.of(
|
public static final TextKey COMMAND_PACK_MESSAGE = TextKey.of(
|
||||||
"iris.bukkit.runtime.commandpack.message",
|
"iris.bukkit.runtime.commandpack.message",
|
||||||
|
|||||||
@@ -11,29 +11,38 @@ public final class ChatReport {
|
|||||||
public static final int DEFAULT_ITEM_LIMIT = 8;
|
public static final int DEFAULT_ITEM_LIMIT = 8;
|
||||||
private static final String ITEM_BULLET = " » ";
|
private static final String ITEM_BULLET = " » ";
|
||||||
private static final String CONTINUATION_INDENT = " ";
|
private static final String CONTINUATION_INDENT = " ";
|
||||||
private static final String TREE_CONTINUATION_INDENT = " ";
|
|
||||||
private static final Pattern LEGACY_COLOR = Pattern.compile("(?i)[§&][0-9A-FK-ORX]");
|
private static final Pattern LEGACY_COLOR = Pattern.compile("(?i)[§&][0-9A-FK-ORX]");
|
||||||
|
|
||||||
public enum Tone {
|
public enum Tone {
|
||||||
SUCCESS(C.IRIS, ConsoleGlyphs.CHECK),
|
SUCCESS(C.IRIS, ConsoleGlyphs.CHECK, C.GREEN),
|
||||||
INFO(C.AQUA, ""),
|
INFO(C.AQUA, "", C.RESET),
|
||||||
WARNING(C.GOLD, ConsoleGlyphs.CAUTION),
|
WARNING(C.GOLD, ConsoleGlyphs.WARNING, C.YELLOW),
|
||||||
ERROR(C.RED, ConsoleGlyphs.CROSS);
|
ERROR(C.RED, ConsoleGlyphs.CROSS, C.RED);
|
||||||
|
|
||||||
private final C color;
|
private final C color;
|
||||||
private final String mark;
|
private final String mark;
|
||||||
|
private final C markColor;
|
||||||
|
|
||||||
Tone(C color, String mark) {
|
Tone(C color, String mark, C markColor) {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.mark = mark;
|
this.mark = mark;
|
||||||
|
this.markColor = markColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Prefixes already styled console text with this tone's status mark; a tone without one leaves it as is. */
|
/** Puts already styled console text on the gutter behind this tone's status glyph, or a blank one for info. */
|
||||||
public String marked(String styledText) {
|
public String marked(String styledText) {
|
||||||
if (mark.isEmpty()) {
|
if (!hasMark()) {
|
||||||
return styledText;
|
return ConsoleLayout.row(styledText);
|
||||||
}
|
}
|
||||||
return color + mark + " " + styledText;
|
return markColor + mark + " " + C.RESET + styledText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasMark() {
|
||||||
|
return !mark.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String mark() {
|
||||||
|
return mark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public C color() {
|
public C color() {
|
||||||
@@ -54,12 +63,44 @@ public final class ChatReport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A suggested command and what running it gets the reader. */
|
||||||
|
private record NextStep(String instruction, String command) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One report entry. Chat shows its styled lines; the console shows the same words on the gutter in normal
|
||||||
|
* foreground, and a labelled entry as an aligned label row.
|
||||||
|
*/
|
||||||
|
private record Entry(List<String> styledLines, String label, String value) {
|
||||||
|
static Entry styled(List<String> styledLines) {
|
||||||
|
return new Entry(List.copyOf(styledLines), null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Entry labelled(String label, String value) {
|
||||||
|
return new Entry(List.of(ChatReport.label(label, value)), clean(label), clean(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> consoleLines() {
|
||||||
|
if (label != null) {
|
||||||
|
return ConsoleLayout.labelRows(label, value);
|
||||||
|
}
|
||||||
|
List<String> lines = new ArrayList<>(styledLines.size());
|
||||||
|
lines.add(ConsoleLayout.row(ConsoleLayout.withoutColors(styledLines.getFirst())));
|
||||||
|
for (int index = 1; index < styledLines.size(); index++) {
|
||||||
|
lines.add(ConsoleLayout.continuation(ConsoleLayout.withoutColors(styledLines.get(index)).stripLeading()));
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final Tone tone;
|
private final Tone tone;
|
||||||
private final String title;
|
private final String title;
|
||||||
private final List<List<String>> entries;
|
private final List<Entry> entries;
|
||||||
private final int itemLimit;
|
private final int itemLimit;
|
||||||
private final String hint;
|
private final String hint;
|
||||||
private final String hintCommand;
|
private final String hintShownCommand;
|
||||||
|
private final String hintClickCommand;
|
||||||
|
private final List<NextStep> nextSteps;
|
||||||
|
|
||||||
private ChatReport(Builder builder) {
|
private ChatReport(Builder builder) {
|
||||||
this.tone = builder.tone;
|
this.tone = builder.tone;
|
||||||
@@ -67,7 +108,9 @@ public final class ChatReport {
|
|||||||
this.entries = List.copyOf(builder.entries);
|
this.entries = List.copyOf(builder.entries);
|
||||||
this.itemLimit = builder.itemLimit;
|
this.itemLimit = builder.itemLimit;
|
||||||
this.hint = builder.hint;
|
this.hint = builder.hint;
|
||||||
this.hintCommand = builder.hintCommand;
|
this.hintShownCommand = builder.hintShownCommand;
|
||||||
|
this.hintClickCommand = builder.hintClickCommand;
|
||||||
|
this.nextSteps = List.copyOf(builder.nextSteps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder of(Tone tone, String title) {
|
public static Builder of(Tone tone, String title) {
|
||||||
@@ -111,61 +154,84 @@ public final class ChatReport {
|
|||||||
/** Every line after the title; {@code spaced} adds a blank line between the list and the hint, for chat. */
|
/** Every line after the title; {@code spaced} adds a blank line between the list and the hint, for chat. */
|
||||||
public List<Line> bodyLines(boolean spaced) {
|
public List<Line> bodyLines(boolean spaced) {
|
||||||
List<Line> lines = new ArrayList<>();
|
List<Line> lines = new ArrayList<>();
|
||||||
int shown = Math.min(itemLimit, entries.size());
|
for (Entry entry : shownEntries()) {
|
||||||
for (int index = 0; index < shown; index++) {
|
addChatEntryLines(lines, entry);
|
||||||
addEntryLines(lines, entries.get(index));
|
|
||||||
}
|
}
|
||||||
int hidden = entries.size() - shown;
|
int hidden = hiddenEntryCount();
|
||||||
if (hidden > 0) {
|
if (hidden > 0) {
|
||||||
lines.add(new Line(C.DARK_GRAY + CONTINUATION_INDENT + ReportText.moreLabel(hidden), null));
|
lines.add(new Line(C.DARK_GRAY + CONTINUATION_INDENT + ReportText.moreLabel(hidden), null));
|
||||||
}
|
}
|
||||||
|
if (hint == null && nextSteps.isEmpty()) {
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
if (spaced && !lines.isEmpty()) {
|
||||||
|
lines.add(SPACER);
|
||||||
|
}
|
||||||
if (hint != null) {
|
if (hint != null) {
|
||||||
if (spaced && !lines.isEmpty()) {
|
lines.add(new Line(C.GRAY + chatHint(), hintClickCommand));
|
||||||
lines.add(SPACER);
|
}
|
||||||
}
|
for (NextStep step : nextSteps) {
|
||||||
lines.add(new Line(C.GRAY + hint, hintCommand));
|
lines.add(new Line(C.GRAY + step.instruction() + ": " + highlight(step.command()), step.command()));
|
||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addEntryLines(List<Line> lines, List<String> entry) {
|
private String chatHint() {
|
||||||
lines.add(new Line(tone.color() + ITEM_BULLET + C.GRAY + entry.getFirst(), null));
|
return hintShownCommand == null ? hint : hint.replace(hintShownCommand, highlight(hintShownCommand));
|
||||||
for (int index = 1; index < entry.size(); index++) {
|
}
|
||||||
lines.add(new Line(entry.get(index), null));
|
|
||||||
|
private void addChatEntryLines(List<Line> lines, Entry entry) {
|
||||||
|
List<String> styled = entry.styledLines();
|
||||||
|
lines.add(new Line(tone.color() + ITEM_BULLET + C.GRAY + styled.getFirst(), null));
|
||||||
|
for (int index = 1; index < styled.size(); index++) {
|
||||||
|
lines.add(new Line(styled.get(index), null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The console layout: a status mark on the title and the body drawn as a tree under it. */
|
/** The console layout: the title behind the tone's status glyph, then the body, hint and next steps on the gutter. */
|
||||||
public List<String> consoleLines() {
|
public List<String> consoleLines() {
|
||||||
List<String> lines = new ArrayList<>();
|
List<String> lines = new ArrayList<>();
|
||||||
lines.add(tone.marked(ReportText.title(tone, clean(title))));
|
lines.add(tone.marked(consoleTitle()));
|
||||||
List<List<String>> branches = consoleBranches();
|
for (Entry entry : shownEntries()) {
|
||||||
for (int index = 0; index < branches.size(); index++) {
|
lines.addAll(entry.consoleLines());
|
||||||
addBranchLines(lines, branches.get(index), index == branches.size() - 1);
|
}
|
||||||
|
int hidden = hiddenEntryCount();
|
||||||
|
if (hidden > 0) {
|
||||||
|
lines.add(ConsoleLayout.row(ReportText.moreLabel(hidden)));
|
||||||
|
}
|
||||||
|
if (hint != null) {
|
||||||
|
lines.addAll(consoleHintLines());
|
||||||
|
}
|
||||||
|
for (NextStep step : nextSteps) {
|
||||||
|
lines.addAll(ConsoleLayout.nextStep(step.instruction(), step.command()));
|
||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<List<String>> consoleBranches() {
|
private String consoleTitle() {
|
||||||
int shown = Math.min(itemLimit, entries.size());
|
String plainTitle = clean(title);
|
||||||
List<List<String>> branches = new ArrayList<>(entries.subList(0, shown));
|
return tone == Tone.SUCCESS ? C.BOLD + plainTitle : plainTitle;
|
||||||
int hidden = entries.size() - shown;
|
|
||||||
if (hidden > 0) {
|
|
||||||
branches.add(List.of(C.DARK_GRAY + ReportText.moreLabel(hidden)));
|
|
||||||
}
|
|
||||||
if (hint != null) {
|
|
||||||
branches.add(List.of(C.GRAY + hint));
|
|
||||||
}
|
|
||||||
return branches;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBranchLines(List<String> lines, List<String> branch, boolean last) {
|
/**
|
||||||
String connector = last ? ConsoleGlyphs.LAST_BRANCH : ConsoleGlyphs.BRANCH;
|
* A hint that ends in its command reads as a next step; any other hint stays one sentence. The console can't
|
||||||
String trunk = last ? " " : ConsoleGlyphs.BAR;
|
* click, so the step shows the full command a click would run.
|
||||||
lines.add(tone.color() + connector + " " + C.GRAY + branch.getFirst());
|
*/
|
||||||
for (int index = 1; index < branch.size(); index++) {
|
private List<String> consoleHintLines() {
|
||||||
lines.add(tone.color() + trunk + TREE_CONTINUATION_INDENT + branch.get(index).stripLeading());
|
if (hintShownCommand != null && hint.endsWith(hintShownCommand)) {
|
||||||
|
String instruction = hint.substring(0, hint.length() - hintShownCommand.length());
|
||||||
|
String runnable = hintClickCommand == null ? hintShownCommand : clean(hintClickCommand);
|
||||||
|
return ConsoleLayout.nextStep(instruction, runnable);
|
||||||
}
|
}
|
||||||
|
return List.of(ConsoleLayout.row(hint));
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Entry> shownEntries() {
|
||||||
|
return entries.subList(0, Math.min(itemLimit, entries.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private int hiddenEntryCount() {
|
||||||
|
return entries.size() - shownEntries().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log() {
|
public void log() {
|
||||||
@@ -185,10 +251,12 @@ public final class ChatReport {
|
|||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
private final Tone tone;
|
private final Tone tone;
|
||||||
private final String title;
|
private final String title;
|
||||||
private final List<List<String>> entries = new ArrayList<>();
|
private final List<Entry> entries = new ArrayList<>();
|
||||||
|
private final List<NextStep> nextSteps = new ArrayList<>();
|
||||||
private int itemLimit = DEFAULT_ITEM_LIMIT;
|
private int itemLimit = DEFAULT_ITEM_LIMIT;
|
||||||
private String hint;
|
private String hint;
|
||||||
private String hintCommand;
|
private String hintShownCommand;
|
||||||
|
private String hintClickCommand;
|
||||||
|
|
||||||
private Builder(Tone tone, String title) {
|
private Builder(Tone tone, String title) {
|
||||||
this.tone = tone;
|
this.tone = tone;
|
||||||
@@ -198,14 +266,14 @@ public final class ChatReport {
|
|||||||
public Builder item(String text) {
|
public Builder item(String text) {
|
||||||
String cleaned = clean(text);
|
String cleaned = clean(text);
|
||||||
if (!cleaned.isEmpty()) {
|
if (!cleaned.isEmpty()) {
|
||||||
entries.add(List.of(ReportText.body(cleaned)));
|
entries.add(Entry.styled(List.of(ReportText.body(cleaned))));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder styledItem(String styledText) {
|
public Builder styledItem(String styledText) {
|
||||||
if (styledText != null && !styledText.isBlank()) {
|
if (styledText != null && !styledText.isBlank()) {
|
||||||
entries.add(List.of(styledText));
|
entries.add(Entry.styled(List.of(styledText)));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -219,12 +287,12 @@ public final class ChatReport {
|
|||||||
cleaned.add(reason);
|
cleaned.add(reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entries.addAll(ReportText.groupedBodies(cleaned, CONTINUATION_INDENT));
|
ReportText.groupedBodies(cleaned, CONTINUATION_INDENT).forEach(lines -> entries.add(Entry.styled(lines)));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder entry(String label, Object value) {
|
public Builder entry(String label, Object value) {
|
||||||
entries.add(List.of(label(label, String.valueOf(value))));
|
entries.add(Entry.labelled(label, String.valueOf(value)));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,9 +312,15 @@ public final class ChatReport {
|
|||||||
|
|
||||||
/** Shows {@code shownCommand} in the hint text while a click runs {@code clickCommand}. */
|
/** Shows {@code shownCommand} in the hint text while a click runs {@code clickCommand}. */
|
||||||
public Builder hint(String text, String shownCommand, String clickCommand) {
|
public Builder hint(String text, String shownCommand, String clickCommand) {
|
||||||
String cleaned = clean(text);
|
this.hint = clean(text);
|
||||||
this.hint = shownCommand == null ? cleaned : cleaned.replace(shownCommand, highlight(shownCommand));
|
this.hintShownCommand = shownCommand == null ? null : clean(shownCommand);
|
||||||
this.hintCommand = clickCommand;
|
this.hintClickCommand = clickCommand;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Suggests a command after the body; chat shows it as one clickable line, the console on its own line. */
|
||||||
|
public Builder nextStep(String instruction, String command) {
|
||||||
|
nextSteps.add(new NextStep(clean(instruction), clean(command)));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,10 @@ import java.util.Map;
|
|||||||
/** Swaps the non-ASCII glyphs Iris prints for ASCII ones when the console charset cannot encode them. */
|
/** Swaps the non-ASCII glyphs Iris prints for ASCII ones when the console charset cannot encode them. */
|
||||||
public final class ConsoleGlyphs {
|
public final class ConsoleGlyphs {
|
||||||
public static final String BAR = "\u2502";
|
public static final String BAR = "\u2502";
|
||||||
public static final String BRANCH = "\u251c";
|
public static final String CHECK = "\u2713";
|
||||||
public static final String LAST_BRANCH = "\u2514";
|
public static final String WARNING = "!";
|
||||||
public static final String CHECK = "\u2714";
|
public static final String CROSS = "\u2717";
|
||||||
public static final String CAUTION = "\u25b2";
|
public static final String ELLIPSIS = "\u2026";
|
||||||
public static final String CROSS = "\u2716";
|
|
||||||
|
|
||||||
private static final Map<String, String> ASCII_FALLBACKS = asciiFallbacks();
|
private static final Map<String, String> ASCII_FALLBACKS = asciiFallbacks();
|
||||||
private static final String[] CONSOLE_CHARSET_PROPERTIES = {"stdout.encoding", "native.encoding"};
|
private static final String[] CONSOLE_CHARSET_PROPERTIES = {"stdout.encoding", "native.encoding"};
|
||||||
@@ -53,11 +52,9 @@ public final class ConsoleGlyphs {
|
|||||||
Map<String, String> fallbacks = new LinkedHashMap<>();
|
Map<String, String> fallbacks = new LinkedHashMap<>();
|
||||||
fallbacks.put("\u00bb", ">");
|
fallbacks.put("\u00bb", ">");
|
||||||
fallbacks.put(BAR, "|");
|
fallbacks.put(BAR, "|");
|
||||||
fallbacks.put(BRANCH, "|-");
|
|
||||||
fallbacks.put(LAST_BRANCH, "`-");
|
|
||||||
fallbacks.put(CHECK, "+");
|
fallbacks.put(CHECK, "+");
|
||||||
fallbacks.put(CAUTION, "!");
|
|
||||||
fallbacks.put(CROSS, "x");
|
fallbacks.put(CROSS, "x");
|
||||||
|
fallbacks.put(ELLIPSIS, "...");
|
||||||
fallbacks.put("\u2039", "[");
|
fallbacks.put("\u2039", "[");
|
||||||
fallbacks.put("\u203a", "]");
|
fallbacks.put("\u203a", "]");
|
||||||
return fallbacks;
|
return fallbacks;
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package art.arcane.iris.localization;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console's shared row layout. Every line sits on a two-column gutter: column 0 holds a status glyph or a space
|
||||||
|
* and content starts at column 2. Label rows put the value at column 18, and a next step puts its command on its own
|
||||||
|
* line, indented 4, so it can be copied as is. Log records carry their own level, so the layout never emits blank lines.
|
||||||
|
*/
|
||||||
|
public final class ConsoleLayout {
|
||||||
|
public static final int GUTTER_WIDTH = 2;
|
||||||
|
public static final int LABEL_WIDTH = 16;
|
||||||
|
public static final int COMMAND_INDENT = 4;
|
||||||
|
public static final int CONTINUATION_INDENT = 2;
|
||||||
|
|
||||||
|
private static final String BLANK_GUTTER = " ".repeat(GUTTER_WIDTH);
|
||||||
|
private static final String LABEL_GAP = " ".repeat(LABEL_WIDTH);
|
||||||
|
private static final C COMMAND_COLOR = C.AQUA;
|
||||||
|
private static final Pattern STYLING = Pattern.compile("(?i)§[0-9A-FK-ORX]|<[/#!?]?[a-z0-9_:#-]+(?::[^>]*)?>");
|
||||||
|
private static final Pattern LEGACY_COLOR = Pattern.compile("(?i)§[0-9A-FK-ORX]");
|
||||||
|
|
||||||
|
private ConsoleLayout() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String row(String text) {
|
||||||
|
return BLANK_GUTTER + C.RESET + text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String continuation(String text) {
|
||||||
|
return row(" ".repeat(CONTINUATION_INDENT) + text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> labelRows(String label, String value) {
|
||||||
|
if (label.length() < LABEL_WIDTH) {
|
||||||
|
return List.of(row(padRight(label, LABEL_WIDTH) + value));
|
||||||
|
}
|
||||||
|
return List.of(row(label), row(LABEL_GAP + value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** An instruction ending in a colon, then the exact command on its own line; an empty instruction leaves only the command. */
|
||||||
|
public static List<String> nextStep(String instruction, String command) {
|
||||||
|
List<String> lines = new ArrayList<>(2);
|
||||||
|
String trimmed = instruction == null ? "" : instruction.strip();
|
||||||
|
if (!trimmed.isEmpty()) {
|
||||||
|
lines.add(row(trimmed.endsWith(":") ? trimmed : trimmed + ":"));
|
||||||
|
}
|
||||||
|
lines.add(row(" ".repeat(COMMAND_INDENT - GUTTER_WIDTH) + COMMAND_COLOR + command));
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Puts a log line on the gutter, marked for its tone, unless it already starts with a gutter of its own. */
|
||||||
|
public static String onGutter(ChatReport.Tone tone, String styledLine) {
|
||||||
|
if (styledLine == null || hasGutter(styledLine)) {
|
||||||
|
return styledLine;
|
||||||
|
}
|
||||||
|
return tone.marked(styledLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String withoutColors(String styledText) {
|
||||||
|
return styledText == null ? "" : LEGACY_COLOR.matcher(styledText).replaceAll("");
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean hasGutter(String styledLine) {
|
||||||
|
String plain = STYLING.matcher(styledLine).replaceAll("");
|
||||||
|
if (plain.isBlank() || plain.startsWith(BLANK_GUTTER)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (ChatReport.Tone tone : ChatReport.Tone.values()) {
|
||||||
|
if (tone.hasMark() && plain.startsWith(tone.mark() + " ")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String padRight(String text, int width) {
|
||||||
|
return text + " ".repeat(Math.max(0, width - text.length()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ public final class PackBootReporter {
|
|||||||
public static void logBroken(PackValidationResult result, String minecraftVersion) {
|
public static void logBroken(PackValidationResult result, String minecraftVersion) {
|
||||||
String pack = result.getPackName();
|
String pack = result.getPackName();
|
||||||
logReport(ChatReport.Tone.ERROR,
|
logReport(ChatReport.Tone.ERROR,
|
||||||
"Pack '" + pack + "' failed validation, worlds and Studio refuse it",
|
"Pack '" + pack + "' failed validation. Worlds and Studio won't load it.",
|
||||||
result, minecraftVersion, result.getBlockingErrors());
|
result, minecraftVersion, result.getBlockingErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,17 +28,17 @@ public final class PackBootReporter {
|
|||||||
int warnings = result.getWarnings().size();
|
int warnings = result.getWarnings().size();
|
||||||
if (warnings > 0) {
|
if (warnings > 0) {
|
||||||
logReport(ChatReport.Tone.WARNING,
|
logReport(ChatReport.Tone.WARNING,
|
||||||
"Pack '" + pack + "': " + warnings + (warnings == 1 ? " warning" : " warnings"),
|
"Pack '" + pack + "' has " + warnings + (warnings == 1 ? " warning" : " warnings"),
|
||||||
result, minecraftVersion, result.getWarnings());
|
result, minecraftVersion, result.getWarnings());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!result.getCompatFindings().isEmpty()) {
|
if (!result.getCompatFindings().isEmpty()) {
|
||||||
logReport(ChatReport.Tone.WARNING, "Pack '" + pack + "': content unavailable",
|
logReport(ChatReport.Tone.WARNING, "Pack '" + pack + "' uses content this version doesn't have",
|
||||||
result, minecraftVersion, List.of());
|
result, minecraftVersion, List.of());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (announceClean) {
|
if (announceClean) {
|
||||||
ChatReport.of(ChatReport.Tone.SUCCESS, "Pack '" + pack + "' validated").build().log();
|
ChatReport.of(ChatReport.Tone.SUCCESS, "Validated pack '" + pack + "'").build().log();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,13 +47,19 @@ public final class PackBootReporter {
|
|||||||
String pack = result.getPackName();
|
String pack = result.getPackName();
|
||||||
List<String> items = new ArrayList<>(reasons.size() + 1);
|
List<String> items = new ArrayList<>(reasons.size() + 1);
|
||||||
reasons.forEach(reason -> items.add(firstSentence(reason)));
|
reasons.forEach(reason -> items.add(firstSentence(reason)));
|
||||||
String details = "/iris pack validate " + pack;
|
boolean hasCompatFindings = !result.getCompatFindings().isEmpty();
|
||||||
if (!result.getCompatFindings().isEmpty()) {
|
if (hasCompatFindings) {
|
||||||
items.add(PackCompatReport.of(result.getCompatFindings())
|
items.add(PackCompatReport.of(result.getCompatFindings())
|
||||||
.bootItem(PackValidator.versionOf(result, minecraftVersion), COMPAT_KEYS_SHOWN));
|
.bootItem(PackValidator.versionOf(result, minecraftVersion), COMPAT_KEYS_SHOWN));
|
||||||
details += ", /iris pack compat " + pack;
|
|
||||||
}
|
}
|
||||||
ChatReport.of(tone, title).items(items).limit(BOOT_ITEM_LIMIT).hint("Details: " + details, null).build().log();
|
ChatReport.Builder report = ChatReport.of(tone, title).items(items).limit(BOOT_ITEM_LIMIT);
|
||||||
|
if (!reasons.isEmpty()) {
|
||||||
|
report.nextStep("See every issue", "/iris pack validate " + pack);
|
||||||
|
}
|
||||||
|
if (hasCompatFindings) {
|
||||||
|
report.nextStep("See the missing content", "/iris pack compat " + pack);
|
||||||
|
}
|
||||||
|
report.build().log();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String firstSentence(String reason) {
|
private static String firstSentence(String reason) {
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ final class UnknownFieldReport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ChatReport packReport(String pack, Map<String, List<UnknownField>> fields) {
|
private static ChatReport packReport(String pack, Map<String, List<UnknownField>> fields) {
|
||||||
String title = "Pack '" + pack + "': " + fields.size() + (fields.size() == 1 ? " unknown field" : " unknown fields") + ", ignored";
|
String title = "Pack '" + pack + "' has " + fields.size() + (fields.size() == 1 ? " unknown field" : " unknown fields")
|
||||||
|
+ ". Iris ignores " + (fields.size() == 1 ? "it." : "them.");
|
||||||
ChatReport.Builder report = ChatReport.of(ChatReport.Tone.WARNING, title);
|
ChatReport.Builder report = ChatReport.of(ChatReport.Tone.WARNING, title);
|
||||||
int labelWidth = fields.keySet().stream().mapToInt(String::length).max().orElse(0);
|
int labelWidth = fields.keySet().stream().mapToInt(String::length).max().orElse(0);
|
||||||
fields.forEach((typeAndField, occurrences) -> report.styledItem(describeField(typeAndField, occurrences, labelWidth)));
|
fields.forEach((typeAndField, occurrences) -> report.styledItem(describeField(typeAndField, occurrences, labelWidth)));
|
||||||
@@ -114,7 +115,7 @@ final class UnknownFieldReport {
|
|||||||
.append(" ").append(C.GRAY).append(count == 1 ? "" : "e.g. ")
|
.append(" ").append(C.GRAY).append(count == 1 ? "" : "e.g. ")
|
||||||
.append(C.AQUA).append(first.location());
|
.append(C.AQUA).append(first.location());
|
||||||
if (first.suggestion() != null) {
|
if (first.suggestion() != null) {
|
||||||
out.append(C.GRAY).append(" did you mean ").append(C.WHITE).append('\'').append(first.suggestion()).append('\'').append(C.GRAY).append('?');
|
out.append(C.GRAY).append(" Did you mean ").append(C.WHITE).append('\'').append(first.suggestion()).append('\'').append(C.GRAY).append('?');
|
||||||
}
|
}
|
||||||
return out.toString();
|
return out.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,10 +67,10 @@ public class Agent {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IrisLogging.info("Installing Java agent, the JVM warnings below are expected");
|
IrisLogging.info("Installing Java agent… The JVM warnings below are expected.");
|
||||||
ByteBuddyAgent.attach(AGENT_JAR, ByteBuddyAgent.ProcessProvider.ForCurrentVm.INSTANCE);
|
ByteBuddyAgent.attach(AGENT_JAR, ByteBuddyAgent.ProcessProvider.ForCurrentVm.INSTANCE);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
IrisLogging.error("Failed to install Java Agent: " + e.getMessage());
|
IrisLogging.error("Couldn't install the Java agent. " + e.getMessage());
|
||||||
IrisLogging.reportError(e);
|
IrisLogging.reportError(e);
|
||||||
}
|
}
|
||||||
return doGetInstrumentation() != null;
|
return doGetInstrumentation() != null;
|
||||||
|
|||||||
@@ -309,28 +309,33 @@ public class VolmitSender implements CommandSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendSuccess(String message) {
|
public void sendSuccess(String message) {
|
||||||
sendMessage(ChatReport.Tone.SUCCESS.paint(message));
|
sendToned(ChatReport.Tone.SUCCESS, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendInfo(String message) {
|
public void sendInfo(String message) {
|
||||||
sendMessage(ChatReport.Tone.INFO.paint(message));
|
sendToned(ChatReport.Tone.INFO, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendWarning(String message) {
|
public void sendWarning(String message) {
|
||||||
sendMessage(ChatReport.Tone.WARNING.paint(message));
|
sendToned(ChatReport.Tone.WARNING, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendError(String message) {
|
public void sendError(String message) {
|
||||||
sendMessage(ChatReport.Tone.ERROR.paint(message));
|
sendToned(ChatReport.Tone.ERROR, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendToned(ChatReport.Tone tone, String message) {
|
||||||
|
sendMessage(isPlayer() ? tone.paint(message) : tone.marked(ChatReport.clean(message)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendReport(ChatReport report) {
|
public void sendReport(ChatReport report) {
|
||||||
boolean spaced = isPlayer();
|
if (!isPlayer()) {
|
||||||
if (spaced) {
|
report.consoleLines().forEach(this::sendMessage);
|
||||||
sendUntagged(ChatReport.SPACER);
|
return;
|
||||||
}
|
}
|
||||||
|
sendUntagged(ChatReport.SPACER);
|
||||||
sendMessage(report.titleLine().text());
|
sendMessage(report.titleLine().text());
|
||||||
for (ChatReport.Line line : report.bodyLines(spaced)) {
|
for (ChatReport.Line line : report.bodyLines(true)) {
|
||||||
sendUntagged(line);
|
sendUntagged(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,8 +153,10 @@ public class StudioSVC implements IrisService {
|
|||||||
MultiBurst.ioBurst.completeValueAsync(() -> {
|
MultiBurst.ioBurst.completeValueAsync(() -> {
|
||||||
String configuredPack = IrisSettings.get().getGenerator().getDefaultWorldType();
|
String configuredPack = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||||
if (!PackDownloader.isPackPresent(getWorkspaceFolder(), configuredPack)) {
|
if (!PackDownloader.isPackPresent(getWorkspaceFolder(), configuredPack)) {
|
||||||
IrisLogging.warn("Default pack '" + configuredPack
|
ChatReport.of(ChatReport.Tone.WARNING, "Default pack '" + configuredPack + "' isn't installed")
|
||||||
+ "' is not installed: /iris download pack=overworld");
|
.nextStep("Download it", PackDownloader.downloadCommandFor(configuredPack))
|
||||||
|
.build()
|
||||||
|
.log();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@@ -1590,7 +1592,7 @@ public class StudioSVC implements IrisService {
|
|||||||
if (restartRequired) {
|
if (restartRequired) {
|
||||||
report.hint("Restart the server, then run " + openCommand, openCommand);
|
report.hint("Restart the server, then run " + openCommand, openCommand);
|
||||||
} else {
|
} else {
|
||||||
report.hint("Run " + openCommand, openCommand);
|
report.hint("Open it: " + openCommand, openCommand);
|
||||||
}
|
}
|
||||||
sender.sendReport(report.build());
|
sender.sendReport(report.build());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package art.arcane.iris.world.safeguard;
|
|||||||
|
|
||||||
import art.arcane.iris.world.IrisStartupValidation;
|
import art.arcane.iris.world.IrisStartupValidation;
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.iris.localization.C;
|
|
||||||
import art.arcane.iris.localization.ChatReport;
|
import art.arcane.iris.localization.ChatReport;
|
||||||
|
import art.arcane.iris.localization.ConsoleLayout;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -108,8 +108,8 @@ public final class IrisSafeguard {
|
|||||||
switch (mode) {
|
switch (mode) {
|
||||||
case STABLE -> {
|
case STABLE -> {
|
||||||
}
|
}
|
||||||
case WARNING -> IrisLogging.warn(C.GOLD + "%s Issues found", count);
|
case WARNING -> IrisLogging.warn(issueCountLine());
|
||||||
case UNSTABLE -> IrisLogging.error(C.DARK_RED + "%s Issues found", count);
|
case UNSTABLE -> IrisLogging.error(issueCountLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CheckResult value : results.values()) {
|
for (CheckResult value : results.values()) {
|
||||||
@@ -122,9 +122,13 @@ public final class IrisSafeguard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String issueCountLine() {
|
||||||
|
return count == 1 ? "1 startup issue" : count + " startup issues";
|
||||||
|
}
|
||||||
|
|
||||||
public static void printFooter() {
|
public static void printFooter() {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case STABLE -> IrisLogging.info(ChatReport.Tone.SUCCESS.marked(C.BLUE + "Stable, 0 conflicts"));
|
case STABLE -> IrisLogging.info(ChatReport.Tone.SUCCESS.marked("Stable, no conflicts"));
|
||||||
case WARNING -> warning();
|
case WARNING -> warning();
|
||||||
case UNSTABLE -> unstable();
|
case UNSTABLE -> unstable();
|
||||||
}
|
}
|
||||||
@@ -138,14 +142,14 @@ public final class IrisSafeguard {
|
|||||||
// A log record carries a level, so a blank record renders as an empty [WARN] line and a rule of
|
// A log record carries a level, so a blank record renders as an empty [WARN] line and a rule of
|
||||||
// dashes renders as a [SEVERE] one. Spacing belongs to a console, not to the server log.
|
// dashes renders as a [SEVERE] one. Spacing belongs to a console, not to the server log.
|
||||||
private static void warning() {
|
private static void warning() {
|
||||||
IrisLogging.warn(ChatReport.Tone.WARNING.marked(C.GOLD + "Iris is running in Warning Mode"));
|
IrisLogging.warn(ChatReport.Tone.WARNING.marked("Iris is running in Warning Mode"));
|
||||||
IrisLogging.warn(C.GRAY + "Some startup checks need attention. Review the messages above for tuning suggestions.");
|
IrisLogging.warn(ConsoleLayout.row("Some startup checks need attention. The warnings above suggest fixes."));
|
||||||
IrisLogging.warn(C.GRAY + "Iris will continue startup normally.");
|
IrisLogging.warn(ConsoleLayout.row("Startup continues."));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void unstable() {
|
private static void unstable() {
|
||||||
IrisLogging.error(ChatReport.Tone.ERROR.marked(C.DARK_RED + "Iris is running in Danger Mode"));
|
IrisLogging.error(ChatReport.Tone.ERROR.marked("Iris is running in Danger Mode"));
|
||||||
IrisLogging.error("Critical startup checks failed. Review and resolve the errors above as soon as possible.");
|
IrisLogging.error(ConsoleLayout.row("Critical startup checks failed. Fix the errors above."));
|
||||||
// No startup sleep: blocking the boot thread protected nothing — world creation and
|
// No startup sleep: blocking the boot thread protected nothing — world creation and
|
||||||
// player admission are already gated by IrisStartupValidation.
|
// player admission are already gated by IrisStartupValidation.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,15 @@ public class IrisSplashComposerTest {
|
|||||||
new IrisSplashPackScanner.SplashPackMetadata("custom", "7"),
|
new IrisSplashPackScanner.SplashPackMetadata("custom", "7"),
|
||||||
new IrisSplashPackScanner.SplashPackMetadata("overworld", "4009"),
|
new IrisSplashPackScanner.SplashPackMetadata("overworld", "4009"),
|
||||||
new IrisSplashPackScanner.SplashPackMetadata("underworld", "1012"));
|
new IrisSplashPackScanner.SplashPackMetadata("underworld", "1012"));
|
||||||
assertEquals(List.of("Update overworld: /iris download pack=overworld overwrite=true"),
|
assertEquals(List.of(
|
||||||
|
" Pack overworld v4010 is available. You have v4009.",
|
||||||
|
" Update it:",
|
||||||
|
" /iris download pack=overworld overwrite=true"),
|
||||||
IrisSplashComposer.composeUpdateLines(packs, Map.of(
|
IrisSplashComposer.composeUpdateLines(packs, Map.of(
|
||||||
"overworld", new BuiltInPackUpdates.Update("4010"),
|
"overworld", new BuiltInPackUpdates.Update("4010"),
|
||||||
"underworld", new BuiltInPackUpdates.Update("1012"))));
|
"underworld", new BuiltInPackUpdates.Update("1012"))).stream()
|
||||||
|
.map(line -> line.replaceAll("§.", ""))
|
||||||
|
.toList());
|
||||||
assertEquals("custom v7, overworld v4009, underworld v1012", IrisSplashComposer.packSummary(packs));
|
assertEquals("custom v7, overworld v4009, underworld v1012", IrisSplashComposer.packSummary(packs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +35,7 @@ public class IrisSplashComposerTest {
|
|||||||
new IrisSplashComposer.Detail("Injection", "deferred"))));
|
new IrisSplashComposer.Detail("Injection", "deferred"))));
|
||||||
|
|
||||||
assertEquals(11, info.length);
|
assertEquals(11, info.length);
|
||||||
assertEquals(" SIMD: 256-bit | Injection: deferred", info[8]);
|
assertEquals(" SIMD 256-bit Injection deferred", info[8]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -38,7 +43,7 @@ public class IrisSplashComposerTest {
|
|||||||
String[] info = IrisSplashComposer.composeInfo("4.0.0-26.2", "Paper 26.2", IrisSplashComposer.InfoStyle.PLAIN);
|
String[] info = IrisSplashComposer.composeInfo("4.0.0-26.2", "Paper 26.2", IrisSplashComposer.InfoStyle.PLAIN);
|
||||||
|
|
||||||
assertEquals(" Iris, Dimension Engine [4.0]", info[1]);
|
assertEquals(" Iris, Dimension Engine [4.0]", info[1]);
|
||||||
assertEquals(" Version: 4.0.0-26.2", info[2]);
|
assertEquals(" Version 4.0.0-26.2", info[2]);
|
||||||
assertFalse(String.join("\n", info).contains("RC.1.1.6"));
|
assertFalse(String.join("\n", info).contains("RC.1.1.6"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,8 +52,8 @@ public class IrisSplashComposerTest {
|
|||||||
String[] info = IrisSplashComposer.composeInfo("4.0.0-26.2", "Paper 26.2", IrisSplashComposer.InfoStyle.PLAIN);
|
String[] info = IrisSplashComposer.composeInfo("4.0.0-26.2", "Paper 26.2", IrisSplashComposer.InfoStyle.PLAIN);
|
||||||
|
|
||||||
assertEquals(11, info.length);
|
assertEquals(11, info.length);
|
||||||
assertEquals(" By: Volmit Software (Arcane Arts)", info[3]);
|
assertEquals(" By Volmit Software (Arcane Arts)", info[3]);
|
||||||
assertEquals(" Web: VolmitSoftware.com", info[4]);
|
assertEquals(" Web VolmitSoftware.com", info[4]);
|
||||||
assertEquals(" Server: Paper 26.2", info[5]);
|
assertEquals(" Server Paper 26.2", info[5]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,33 +105,109 @@ public class ChatReportTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void consoleLayoutMarksTheTitleAndDrawsTheBodyAsATree() {
|
public void chatShowsANextStepAsOneClickableLine() {
|
||||||
List<String> console = ChatReport.of(ChatReport.Tone.ERROR, "Pack 'uitest' failed validation")
|
ChatReport.Line step = ChatReport.of(ChatReport.Tone.ERROR, "t")
|
||||||
|
.nextStep("See every issue", "/iris pack validate p")
|
||||||
|
.build()
|
||||||
|
.lines()
|
||||||
|
.getLast();
|
||||||
|
|
||||||
|
assertEquals("See every issue: /iris pack validate p", step.text().replaceAll("§.", ""));
|
||||||
|
assertEquals("/iris pack validate p", step.command());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void consoleLayoutPutsTheReportOnTheGutterWithNextStepsOnTheirOwnLines() {
|
||||||
|
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.ERROR, "Pack 'uitest' failed validation")
|
||||||
.items(List.of(
|
.items(List.of(
|
||||||
"Biome 'dev'" + REMOVED_FIELD_TAIL,
|
"Biome 'dev'" + REMOVED_FIELD_TAIL,
|
||||||
"Biome 'vanilla/grove'" + REMOVED_FIELD_TAIL,
|
"Biome 'vanilla/grove'" + REMOVED_FIELD_TAIL,
|
||||||
"Missing dimensions/ folder."))
|
"Missing dimensions/ folder."))
|
||||||
.hint("Details: /iris pack validate uitest", null)
|
.nextStep("See every issue", "/iris pack validate uitest")
|
||||||
.build()
|
.build());
|
||||||
.consoleLines().stream().map(line -> line.replaceAll("§.", "")).toList();
|
|
||||||
|
|
||||||
assertEquals(List.of(
|
assertEquals(List.of(
|
||||||
"\u2716 Pack 'uitest' failed validation",
|
ConsoleGlyphs.CROSS + " Pack 'uitest' failed validation",
|
||||||
"\u251c 2 biomes: caveProfile.allowWater was removed; use caveProfile.allowFluid. Cave aquifers use the dimension fluidPalette.",
|
" 2 biomes: caveProfile.allowWater was removed; use caveProfile.allowFluid. Cave aquifers use the dimension fluidPalette.",
|
||||||
"\u2502 dev, vanilla/grove",
|
" dev, vanilla/grove",
|
||||||
"\u251c Missing dimensions/ folder.",
|
" Missing dimensions/ folder.",
|
||||||
"\u2514 Details: /iris pack validate uitest"), console);
|
" See every issue:",
|
||||||
|
" /iris pack validate uitest"), console);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void consoleLayoutLeavesInfoTitlesUnmarked() {
|
public void consoleLayoutGivesInfoTitlesABlankGutter() {
|
||||||
List<String> console = ChatReport.of(ChatReport.Tone.INFO, "Worlds").item("world").build().consoleLines();
|
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.INFO, "Worlds").item("world").build());
|
||||||
|
|
||||||
assertEquals("Worlds", console.get(0).replaceAll("§.", ""));
|
assertEquals(List.of(" Worlds", " world"), console);
|
||||||
assertEquals("\u2514 world", console.get(1).replaceAll("§.", ""));
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void consoleLayoutAlignsLabelledEntries() {
|
||||||
|
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.SUCCESS, "Exported pack 'uitest'")
|
||||||
|
.entry("Folder", "exports/uitest")
|
||||||
|
.entry("Datapack Folder Path", "world/datapacks/iris")
|
||||||
|
.build());
|
||||||
|
|
||||||
|
assertEquals(List.of(
|
||||||
|
ConsoleGlyphs.CHECK + " Exported pack 'uitest'",
|
||||||
|
" Folder exports/uitest",
|
||||||
|
" Datapack Folder Path",
|
||||||
|
" world/datapacks/iris"), console);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void consoleHintEndingInItsCommandBecomesANextStep() {
|
||||||
|
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.SUCCESS, "Created Studio project 'uitest'")
|
||||||
|
.hint("Restart the server, then run /iris studio open uitest", "/iris studio open uitest")
|
||||||
|
.build());
|
||||||
|
|
||||||
|
assertEquals(List.of(
|
||||||
|
ConsoleGlyphs.CHECK + " Created Studio project 'uitest'",
|
||||||
|
" Restart the server, then run:",
|
||||||
|
" /iris studio open uitest"), console);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void consoleNextStepShowsTheCommandAClickWouldRun() {
|
||||||
|
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.INFO, "Regen started")
|
||||||
|
.hint("Stop it with /iris std regen-stop", "/iris std regen-stop", "/iris std regen-stop world=w")
|
||||||
|
.build());
|
||||||
|
|
||||||
|
assertEquals(List.of(" Regen started", " Stop it with:", " /iris std regen-stop world=w"), console);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void consoleHintWithoutACommandStaysOneRow() {
|
||||||
|
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.WARNING, "Regen is running")
|
||||||
|
.hint("The console has the full refusal notice", null)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
assertEquals(List.of("! Regen is running", " The console has the full refusal notice"), console);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logLinesWithoutAGutterGetTheirTonesMark() {
|
||||||
|
assertEquals("! Default pack is missing",
|
||||||
|
ConsoleLayout.onGutter(ChatReport.Tone.WARNING, "Default pack is missing").replaceAll("§.", ""));
|
||||||
|
assertEquals(" Loading packs",
|
||||||
|
ConsoleLayout.onGutter(ChatReport.Tone.INFO, "Loading packs").replaceAll("§.", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logLinesAlreadyOnTheGutterStayAsTheyAre() {
|
||||||
|
String marked = ChatReport.Tone.ERROR.marked("Pack failed");
|
||||||
|
String row = ConsoleLayout.row("Fix the errors above.");
|
||||||
|
|
||||||
|
assertEquals(marked, ConsoleLayout.onGutter(ChatReport.Tone.ERROR, marked));
|
||||||
|
assertEquals(row, ConsoleLayout.onGutter(ChatReport.Tone.ERROR, row));
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<String> plainConsoleLines(ChatReport report) {
|
||||||
|
return report.consoleLines().stream().map(line -> line.replaceAll("§.", "")).toList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -20,10 +20,11 @@ public class ConsoleGlyphsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void asciiConsoleGetsAnAsciiTree() {
|
public void asciiConsoleGetsAsciiStatusGlyphs() {
|
||||||
String tree = ConsoleGlyphs.BAR + " " + ConsoleGlyphs.CROSS + " title\n" + ConsoleGlyphs.BRANCH + " item\n" + ConsoleGlyphs.LAST_BRANCH + " hint";
|
String gutter = ConsoleGlyphs.BAR + " " + ConsoleGlyphs.CHECK + " done\n" + ConsoleGlyphs.CROSS + " failed\n"
|
||||||
|
+ ConsoleGlyphs.WARNING + " Loading" + ConsoleGlyphs.ELLIPSIS;
|
||||||
|
|
||||||
assertEquals("| x title\n|- item\n`- hint", ConsoleGlyphs.forCharset(StandardCharsets.US_ASCII).fit(tree));
|
assertEquals("| + done\nx failed\n! Loading...", ConsoleGlyphs.forCharset(StandardCharsets.US_ASCII).fit(gutter));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ public class UnknownFieldReportTest {
|
|||||||
List<String> lines = plain(UnknownFieldReport.drainReports());
|
List<String> lines = plain(UnknownFieldReport.drainReports());
|
||||||
|
|
||||||
assertEquals(List.of(
|
assertEquals(List.of(
|
||||||
"Pack 'cavetest': 1 unknown field, ignored",
|
"! Pack 'cavetest' has 1 unknown field. Iris ignores it.",
|
||||||
" » Biome 'caves' 1 file biomes/carving/volcanic.json:144"
|
" Biome 'caves' 1 file biomes/carving/volcanic.json:144"
|
||||||
), lines);
|
), lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,9 +57,9 @@ public class UnknownFieldReportTest {
|
|||||||
List<String> lines = plain(UnknownFieldReport.drainReports());
|
List<String> lines = plain(UnknownFieldReport.drainReports());
|
||||||
|
|
||||||
assertEquals(List.of(
|
assertEquals(List.of(
|
||||||
"Pack 'cavetest': 2 unknown fields, ignored",
|
"! Pack 'cavetest' has 2 unknown fields. Iris ignores them.",
|
||||||
" » Biome 'caves' 3 files e.g. biomes/carving/deep-ravine.json:157",
|
" Biome 'caves' 3 files e.g. biomes/carving/deep-ravine.json:157",
|
||||||
" » Dimension 'caves' 1 file dimensions/cavetest.json:856"
|
" Dimension 'caves' 1 file dimensions/cavetest.json:856"
|
||||||
), lines);
|
), lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public class UnknownFieldReportTest {
|
|||||||
|
|
||||||
List<String> lines = plain(UnknownFieldReport.drainReports());
|
List<String> lines = plain(UnknownFieldReport.drainReports());
|
||||||
|
|
||||||
assertTrue(lines.get(1).endsWith("biomes/x.json:12 did you mean 'carving'?"));
|
assertTrue(lines.get(1).endsWith("biomes/x.json:12 Did you mean 'carving'?"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -102,8 +102,8 @@ public class UnknownFieldReportTest {
|
|||||||
|
|
||||||
private static List<String> plain(List<ChatReport> reports) {
|
private static List<String> plain(List<ChatReport> reports) {
|
||||||
return reports.stream()
|
return reports.stream()
|
||||||
.flatMap(report -> report.lines().stream())
|
.flatMap(report -> report.consoleLines().stream())
|
||||||
.map(line -> line.text().replaceAll("(?i)\u00a7[0-9a-fk-orx]|<[^>]+>", ""))
|
.map(line -> line.replaceAll("(?i)\u00a7[0-9a-fk-orx]|<[^>]+>", ""))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user