mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 17:23:59 +00:00
Themed chat reports for pack and studio
- Add ChatReport renderer with capped bullets and clickable hints - Group unknown content keys per registry and namespace - Drop unknown-key findings the compat gate already names
This commit is contained in:
1 parent
e0aeabd520
commit
8b98e2a61c
27 files changed
+535
-148
No files matched your search
@@ -442,7 +442,7 @@ public final class BukkitRuntimeMessages {
|
||||
);
|
||||
public static final TextKey STUDIO_S_V_C_CANNOT_OPEN_STUDIO_PACK_HAS_BLOCKING_ERRORS = TextKey.of(
|
||||
"iris.bukkit.runtime.studiosvc.cannot_open_studio_pack_has_blocking_errors",
|
||||
"Cannot open studio '" + "{dimm}" + "' - pack has blocking errors:"
|
||||
"Can't open Studio for " + "{dimm}" + ": the pack has blocking errors"
|
||||
);
|
||||
public static final TextKey STUDIO_S_V_C_MESSAGE = TextKey.of(
|
||||
"iris.bukkit.runtime.studiosvc.message",
|
||||
@@ -450,7 +450,7 @@ public final class BukkitRuntimeMessages {
|
||||
);
|
||||
public static final TextKey STUDIO_S_V_C_FIX_PACK_RUN_IRIS_PACK_VALIDATE_REVALIDATE = TextKey.of(
|
||||
"iris.bukkit.runtime.studiosvc.fix_pack_run_iris_pack_validate_revalidate",
|
||||
"Fix the pack and run /iris pack validate " + "{dimm}" + " to revalidate."
|
||||
"Fix the pack, then run /iris pack validate " + "{dimm}"
|
||||
);
|
||||
public static final TextKey STUDIO_S_V_C_FAILED_CLOSE_EXISTING_STUDIO_PROJECT = TextKey.of(
|
||||
"iris.bukkit.runtime.studiosvc.failed_close_existing_studio_project",
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
package art.arcane.iris.localization;
|
||||
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class ChatReport {
|
||||
public static final int DEFAULT_ITEM_LIMIT = 8;
|
||||
private static final String ITEM_BULLET = " » ";
|
||||
private static final String CONTINUATION_INDENT = " ";
|
||||
private static final Pattern LEGACY_COLOR = Pattern.compile("(?i)[§&][0-9A-FK-ORX]");
|
||||
|
||||
public enum Tone {
|
||||
SUCCESS(C.IRIS),
|
||||
INFO(C.AQUA),
|
||||
WARNING(C.GOLD),
|
||||
ERROR(C.RED);
|
||||
|
||||
private final C color;
|
||||
|
||||
Tone(C color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public C color() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public String paint(String text) {
|
||||
return color + clean(text);
|
||||
}
|
||||
}
|
||||
|
||||
public record Line(String text, String command) {
|
||||
public boolean clickable() {
|
||||
return command != null && !command.isBlank();
|
||||
}
|
||||
}
|
||||
|
||||
private final Tone tone;
|
||||
private final String title;
|
||||
private final List<String> items;
|
||||
private final int itemLimit;
|
||||
private final String hint;
|
||||
private final String hintCommand;
|
||||
|
||||
private ChatReport(Builder builder) {
|
||||
this.tone = builder.tone;
|
||||
this.title = builder.title;
|
||||
this.items = List.copyOf(builder.items);
|
||||
this.itemLimit = builder.itemLimit;
|
||||
this.hint = builder.hint;
|
||||
this.hintCommand = builder.hintCommand;
|
||||
}
|
||||
|
||||
public static Builder of(Tone tone, String title) {
|
||||
return new Builder(tone, title);
|
||||
}
|
||||
|
||||
public static String clean(String text) {
|
||||
if (text == null) {
|
||||
return "";
|
||||
}
|
||||
return LEGACY_COLOR.matcher(text).replaceAll("")
|
||||
.replace("<", "‹")
|
||||
.replace(">", "›")
|
||||
.strip();
|
||||
}
|
||||
|
||||
public static String label(String label, String value) {
|
||||
return C.GRAY + clean(label) + C.DARK_GRAY + ": " + C.IRIS + clean(value);
|
||||
}
|
||||
|
||||
public static String highlight(String text) {
|
||||
return C.IRIS + clean(text) + C.GRAY;
|
||||
}
|
||||
|
||||
public Tone tone() {
|
||||
return tone;
|
||||
}
|
||||
|
||||
public List<Line> lines() {
|
||||
List<Line> lines = new ArrayList<>();
|
||||
lines.add(new Line(tone.paint(title), null));
|
||||
int shown = Math.min(itemLimit, items.size());
|
||||
for (int index = 0; index < shown; index++) {
|
||||
lines.add(new Line(C.DARK_GRAY + ITEM_BULLET + C.GRAY + items.get(index), null));
|
||||
}
|
||||
int hidden = items.size() - shown;
|
||||
if (hidden > 0) {
|
||||
lines.add(new Line(C.DARK_GRAY + CONTINUATION_INDENT
|
||||
+ clean(IrisLanguage.plain(RuntimeUiMessages.REPORT_MORE, MessageArgument.trusted("count", hidden))), null));
|
||||
}
|
||||
if (hint != null) {
|
||||
lines.add(new Line(C.GRAY + hint, hintCommand));
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
public void log() {
|
||||
for (Line line : lines()) {
|
||||
logLine(line.text());
|
||||
}
|
||||
}
|
||||
|
||||
private void logLine(String text) {
|
||||
switch (tone) {
|
||||
case ERROR -> IrisLogging.error(text);
|
||||
case WARNING -> IrisLogging.warn(text);
|
||||
default -> IrisLogging.info(text);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
private final Tone tone;
|
||||
private final String title;
|
||||
private final List<String> items = new ArrayList<>();
|
||||
private int itemLimit = DEFAULT_ITEM_LIMIT;
|
||||
private String hint;
|
||||
private String hintCommand;
|
||||
|
||||
private Builder(Tone tone, String title) {
|
||||
this.tone = tone;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Builder item(String text) {
|
||||
String cleaned = clean(text);
|
||||
if (!cleaned.isEmpty()) {
|
||||
items.add(cleaned);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder styledItem(String styledText) {
|
||||
if (styledText != null && !styledText.isBlank()) {
|
||||
items.add(styledText);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder items(Collection<String> texts) {
|
||||
for (String text : texts) {
|
||||
item(text);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder entry(String label, Object value) {
|
||||
items.add(label(label, String.valueOf(value)));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder limit(int maxItems) {
|
||||
this.itemLimit = Math.max(0, maxItems);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder unlimited() {
|
||||
this.itemLimit = Integer.MAX_VALUE;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder hint(String text, String command) {
|
||||
String cleaned = clean(text);
|
||||
this.hint = command == null ? cleaned : cleaned.replace(command, highlight(command));
|
||||
this.hintCommand = command;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChatReport build() {
|
||||
return new ChatReport(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,8 @@ public final class RuntimeUiMessages {
|
||||
public static final TextKey PREGEN_PAUSE_HOVER = TextKey.of("iris.runtime.pregen.button.pause.hover", "Toggle pregeneration pause state");
|
||||
public static final TextKey PREGEN_STOP_BUTTON = TextKey.of("iris.runtime.pregen.button.stop", "Stop");
|
||||
public static final TextKey PREGEN_STOP_HOVER = TextKey.of("iris.runtime.pregen.button.stop.hover", "Finish the current region and stop pregeneration");
|
||||
public static final TextKey REPORT_MORE = TextKey.of("iris.runtime.report.more", "+{count} more");
|
||||
public static final TextKey REPORT_CLICK_TO_INSERT = TextKey.of("iris.runtime.report.click_to_insert", "Click to insert {command}");
|
||||
|
||||
private static final List<MessageKey> KEYS = List.of(
|
||||
FINDING_REGIONS,
|
||||
@@ -239,7 +241,9 @@ public final class RuntimeUiMessages {
|
||||
PREGEN_PAUSE_BUTTON,
|
||||
PREGEN_PAUSE_HOVER,
|
||||
PREGEN_STOP_BUTTON,
|
||||
PREGEN_STOP_HOVER
|
||||
PREGEN_STOP_HOVER,
|
||||
REPORT_MORE,
|
||||
REPORT_CLICK_TO_INSERT
|
||||
);
|
||||
|
||||
private RuntimeUiMessages() {
|
||||
|
||||
@@ -46,6 +46,7 @@ import java.util.stream.Stream;
|
||||
|
||||
public final class ContentKeyValidator {
|
||||
private static final int MAX_SUGGESTION_SCANS = 4096;
|
||||
private static final int GROUPED_KEYS_SHOWN = 5;
|
||||
private static final int MAX_OBJECT_PALETTE_SCANS = 20_000;
|
||||
private static final String DEFAULT_NAMESPACE = "minecraft";
|
||||
private static final String STRICT_PROPERTY = "iris.strictContent";
|
||||
@@ -403,10 +404,67 @@ public final class ContentKeyValidator {
|
||||
* @param strict issues the caller may promote to blocking errors under {@link #strictContent()}
|
||||
* @param advisory issues that stay warnings whatever the mode - see {@link #collectContentKeyIssues(File)}
|
||||
*/
|
||||
record ContentKeyIssues(List<String> strict, List<String> advisory) {
|
||||
record ContentKeyIssues(List<ContentKeyError> strictKeys, List<String> propertyIssues, List<ContentKeyError> advisoryKeys) {
|
||||
static ContentKeyIssues none() {
|
||||
return new ContentKeyIssues(List.of(), List.of());
|
||||
return new ContentKeyIssues(List.of(), List.of(), List.of());
|
||||
}
|
||||
|
||||
List<String> strict(Set<String> alreadyReportedKeys) {
|
||||
List<String> messages = new ArrayList<>(groupedMessages(withoutKeys(strictKeys, alreadyReportedKeys)));
|
||||
messages.addAll(propertyIssues);
|
||||
return messages;
|
||||
}
|
||||
|
||||
List<String> advisory(Set<String> alreadyReportedKeys) {
|
||||
return groupedMessages(withoutKeys(advisoryKeys, alreadyReportedKeys));
|
||||
}
|
||||
|
||||
private static List<ContentKeyError> withoutKeys(List<ContentKeyError> errors, Set<String> excluded) {
|
||||
return errors.stream().filter(error -> !excluded.contains(error.key())).toList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* One message per registry and namespace instead of one per key, so a pack that references a missing plugin's
|
||||
* blocks reports a single line rather than one line per block.
|
||||
*/
|
||||
static List<String> groupedMessages(List<ContentKeyError> errors) {
|
||||
Map<String, List<ContentKeyError>> groups = new LinkedHashMap<>();
|
||||
for (ContentKeyError error : errors) {
|
||||
String group = error.registry().name() + '|' + (error.namespaceLoaded() ? "" : namespaceOf(error.key()));
|
||||
groups.computeIfAbsent(group, ignored -> new ArrayList<>()).add(error);
|
||||
}
|
||||
List<String> messages = new ArrayList<>(groups.size());
|
||||
for (List<ContentKeyError> group : groups.values()) {
|
||||
messages.add(group.size() == 1 ? group.getFirst().message() : groupMessage(group));
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
|
||||
private static String groupMessage(List<ContentKeyError> group) {
|
||||
ContentKeyError first = group.getFirst();
|
||||
String registry = first.registry().label();
|
||||
StringBuilder sb = new StringBuilder(96);
|
||||
sb.append(group.size()).append(" unknown ").append(registry).append(" keys");
|
||||
if (!first.namespaceLoaded()) {
|
||||
sb.append(" (namespace '").append(namespaceOf(first.key())).append("' is not loaded on this server)");
|
||||
}
|
||||
sb.append(": ");
|
||||
int shown = Math.min(GROUPED_KEYS_SHOWN, group.size());
|
||||
for (int index = 0; index < shown; index++) {
|
||||
if (index > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
ContentKeyError error = group.get(index);
|
||||
sb.append(error.key());
|
||||
if (error.suggestion() != null) {
|
||||
sb.append(" (did you mean '").append(error.suggestion()).append("'?)");
|
||||
}
|
||||
}
|
||||
if (group.size() > shown) {
|
||||
sb.append(" +").append(group.size() - shown).append(" more");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,8 +480,9 @@ public final class ContentKeyValidator {
|
||||
* library over keys the author cannot edit and the engine handles.
|
||||
*/
|
||||
static ContentKeyIssues collectContentKeyIssues(File packFolder) {
|
||||
List<String> strict = new ArrayList<>();
|
||||
List<String> advisory = new ArrayList<>();
|
||||
List<ContentKeyError> strict = new ArrayList<>();
|
||||
List<ContentKeyError> advisory = new ArrayList<>();
|
||||
List<String> propertyIssues = new ArrayList<>();
|
||||
try {
|
||||
if (!IrisPlatforms.isBound()) {
|
||||
return ContentKeyIssues.none();
|
||||
@@ -448,16 +507,16 @@ public final class ContentKeyValidator {
|
||||
registries, referenced.blocks(), referenced.items(), referenced.entities());
|
||||
for (ContentKeyValidator.ContentKeyError error : errors) {
|
||||
if (referenced.paletteOnlyBlocks().contains(error.key())) {
|
||||
advisory.add(error.message());
|
||||
advisory.add(error);
|
||||
} else {
|
||||
strict.add(error.message());
|
||||
strict.add(error);
|
||||
}
|
||||
}
|
||||
strict.addAll(validateBlockStateProperties(registries, referenced.blockStates()));
|
||||
propertyIssues.addAll(validateBlockStateProperties(registries, referenced.blockStates()));
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError("PackValidator content-key validation failed for pack '" + packFolder.getName() + "'", e);
|
||||
}
|
||||
return new ContentKeyIssues(List.copyOf(strict), List.copyOf(advisory));
|
||||
return new ContentKeyIssues(List.copyOf(strict), List.copyOf(propertyIssues), List.copyOf(advisory));
|
||||
}
|
||||
|
||||
private static int size(List<String> keys) {
|
||||
|
||||
@@ -45,6 +45,7 @@ import java.util.Objects;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class PackValidator {
|
||||
static final String TRASH_ROOT = ".iris-trash";
|
||||
@@ -164,8 +165,6 @@ public final class PackValidator {
|
||||
// Strict content mode promotes unresolved keys and bad block properties from advisory to blocking. Palette
|
||||
// -sourced findings are exempt and stay warnings - see ContentKeyValidator.collectContentKeyIssues.
|
||||
ContentKeyValidator.ContentKeyIssues contentKeys = ContentKeyValidator.collectContentKeyIssues(packFolder);
|
||||
addDistinct(ContentKeyValidator.strictContent() ? blockingErrors : warnings, contentKeys.strict());
|
||||
addDistinct(warnings, contentKeys.advisory());
|
||||
|
||||
String minecraftVersion = validateLiveRegistries && IrisPlatforms.isBound()
|
||||
? IrisPlatforms.get().minecraftVersion()
|
||||
@@ -174,6 +173,11 @@ public final class PackValidator {
|
||||
? gateContent(packFolder, dimensionFiles, minecraftVersion, blockingErrors, warnings)
|
||||
: List.of();
|
||||
|
||||
// Keys the version gate already names in its own line are not repeated as unknown-key findings.
|
||||
Set<String> gatedKeys = compatFindings.stream().map(CompatFinding::key).collect(Collectors.toSet());
|
||||
addDistinct(ContentKeyValidator.strictContent() ? blockingErrors : warnings, contentKeys.strict(gatedKeys));
|
||||
addDistinct(warnings, contentKeys.advisory(gatedKeys));
|
||||
|
||||
return new PackValidationResult(
|
||||
packName, blockingErrors, warnings, validatedAt, compatFindings, minecraftVersion);
|
||||
}
|
||||
@@ -321,14 +325,16 @@ public final class PackValidator {
|
||||
Set<String> reasons = new LinkedHashSet<>();
|
||||
if (findings != null) {
|
||||
for (CompatFinding finding : findings) {
|
||||
if (reasons.size() == BLOCKING_REASON_LIMIT) {
|
||||
break;
|
||||
}
|
||||
reasons.add(finding.key() + " (" + finding.registry().label() + ")");
|
||||
}
|
||||
}
|
||||
sb.append(reasons.isEmpty() ? "the dimension composes content this server does not have"
|
||||
: String.join(", ", reasons));
|
||||
if (reasons.isEmpty()) {
|
||||
return sb.append("the dimension composes content this server does not have").toString();
|
||||
}
|
||||
sb.append(String.join(", ", reasons.stream().limit(BLOCKING_REASON_LIMIT).toList()));
|
||||
if (reasons.size() > BLOCKING_REASON_LIMIT) {
|
||||
sb.append(" +").append(reasons.size() - BLOCKING_REASON_LIMIT).append(" more");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,10 @@ import art.arcane.volmlib.util.hud.HudSlot;
|
||||
import art.arcane.volmlib.util.plugin.ComponentMessenger;
|
||||
import art.arcane.volmlib.util.plugin.ComponentText;
|
||||
import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.localization.RuntimeUiMessages;
|
||||
import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
import art.arcane.volmlib.util.format.Form;
|
||||
import art.arcane.volmlib.util.math.M;
|
||||
import lombok.Getter;
|
||||
@@ -304,6 +308,52 @@ public class VolmitSender implements CommandSender {
|
||||
deliver(createComponent(message));
|
||||
}
|
||||
|
||||
public void sendSuccess(String message) {
|
||||
sendMessage(ChatReport.Tone.SUCCESS.paint(message));
|
||||
}
|
||||
|
||||
public void sendInfo(String message) {
|
||||
sendMessage(ChatReport.Tone.INFO.paint(message));
|
||||
}
|
||||
|
||||
public void sendWarning(String message) {
|
||||
sendMessage(ChatReport.Tone.WARNING.paint(message));
|
||||
}
|
||||
|
||||
public void sendError(String message) {
|
||||
sendMessage(ChatReport.Tone.ERROR.paint(message));
|
||||
}
|
||||
|
||||
public void sendReport(ChatReport report) {
|
||||
java.util.List<ChatReport.Line> lines = report.lines();
|
||||
sendMessage(lines.getFirst().text());
|
||||
for (int index = 1; index < lines.size(); index++) {
|
||||
sendUntagged(lines.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
private void sendUntagged(ChatReport.Line line) {
|
||||
if (!rendersMarkup()) {
|
||||
ComponentMessenger.sendSection(s, line.text());
|
||||
return;
|
||||
}
|
||||
String text = line.clickable() && isPlayer() ? clickable(line) : line.text();
|
||||
deliver(createNoPrefixComponent(text));
|
||||
}
|
||||
|
||||
private String clickable(ChatReport.Line line) {
|
||||
String command = line.command().replace("'", "\\'");
|
||||
String hover = ChatReport.clean(IrisLanguage.plain(RuntimeUiMessages.REPORT_CLICK_TO_INSERT,
|
||||
MessageArgument.untrusted("command", line.command()))).replace("'", "\\'");
|
||||
return "<click:suggest_command:'" + command + "'><hover:show_text:'" + hover + "'>"
|
||||
+ line.text() + "</hover></click>";
|
||||
}
|
||||
|
||||
private boolean rendersMarkup() {
|
||||
boolean playerWithoutColors = !IrisSettings.get().getGeneral().isUseCustomColorsIngame() && s instanceof Player;
|
||||
return !playerWithoutColors && IrisSettings.get().getGeneral().isUseConsoleCustomColors();
|
||||
}
|
||||
|
||||
public void sendMessageBasic(String message) {
|
||||
ComponentMessenger.sendSection(s, C.translateAlternateColorCodes('&', getTag() + message));
|
||||
}
|
||||
|
||||
@@ -103,7 +103,9 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import art.arcane.iris.localization.BukkitCommandMessagesExtended;
|
||||
import art.arcane.iris.localization.BukkitRuntimeMessages;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.localization.PackDownloadMessages;
|
||||
import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
@@ -659,14 +661,14 @@ public class StudioSVC implements IrisService {
|
||||
|
||||
public IrisDimension installInto(VolmitSender sender, String type, File folder) {
|
||||
if (J.isPrimaryThread()) {
|
||||
sender.sendMessage("Iris refused to download or copy a pack on the Bukkit primary thread.");
|
||||
sender.sendMessage(ChatReport.Tone.ERROR.paint("Iris refused to download or copy a pack on the Bukkit primary thread."));
|
||||
return null;
|
||||
}
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_LOOKING_PACKAGE, MessageArgument.untrusted("type", String.valueOf(type))));
|
||||
sender.sendInfo(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_LOOKING_PACKAGE,MessageArgument.untrusted("type", String.valueOf(type))));
|
||||
IrisDimension dimension = IrisData.loadAnyDimension(type, null);
|
||||
if (dimension == null) {
|
||||
sender.sendMessage("Iris cannot repair world pack '" + type
|
||||
+ "' because no installed source contains it.");
|
||||
sender.sendMessage(ChatReport.Tone.ERROR.paint("Iris cannot repair world pack '" + type
|
||||
+ "' because no installed source contains it."));
|
||||
return null;
|
||||
}
|
||||
return replaceIntoPackDirectory(sender, dimension, folder);
|
||||
@@ -778,7 +780,7 @@ public class StudioSVC implements IrisService {
|
||||
});
|
||||
} catch (Exception e) {
|
||||
IrisLogging.reportError("Failed to open studio world \"" + dimm + "\".", e);
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_FAILED_OPEN_STUDIO_WORLD, MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
sender.sendError(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_FAILED_OPEN_STUDIO_WORLD,MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -799,22 +801,32 @@ public class StudioSVC implements IrisService {
|
||||
packName, startupDenial, validation);
|
||||
if (failure == null) {
|
||||
if (force && unforcedStartupDenial.isPresent()) {
|
||||
sender.sendMessage("Force-opening Studio with the currently loaded registry state. The open may fail; restart remains required.");
|
||||
sender.sendMessage(ChatReport.Tone.WARNING.paint("Force-opening Studio with the currently loaded registry state. The open may fail; restart remains required."));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
String title = IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_CANNOT_OPEN_STUDIO_PACK_HAS_BLOCKING_ERRORS,
|
||||
MessageArgument.untrusted("dimm", packName));
|
||||
if (startupDenial.isPresent()) {
|
||||
sender.sendMessage(startupDenial.get());
|
||||
sender.sendReport(ChatReport.of(ChatReport.Tone.ERROR, title).item(startupDenial.get()).build());
|
||||
return failure;
|
||||
}
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_CANNOT_OPEN_STUDIO_PACK_HAS_BLOCKING_ERRORS, MessageArgument.untrusted("dimm", String.valueOf(dimm))));
|
||||
for (String reason : failure.getReasons()) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_MESSAGE, MessageArgument.untrusted("reason", String.valueOf(reason))));
|
||||
}
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_FIX_PACK_RUN_IRIS_PACK_VALIDATE_REVALIDATE, MessageArgument.untrusted("dimm", String.valueOf(packName))));
|
||||
String validateCommand = "/iris pack validate " + packName;
|
||||
sender.sendReport(ChatReport.of(ChatReport.Tone.ERROR, title)
|
||||
.items(failure.getReasons())
|
||||
.hint(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_FIX_PACK_RUN_IRIS_PACK_VALIDATE_REVALIDATE,
|
||||
MessageArgument.untrusted("dimm", packName)), validateCommand)
|
||||
.build());
|
||||
return failure;
|
||||
}
|
||||
|
||||
private static void announceOpen(VolmitSender sender, String dimm, long seed) {
|
||||
IrisDimension dimension = IrisToolbelt.getDimension(dimm);
|
||||
String displayName = dimension == null ? dimm : dimension.getName();
|
||||
sender.sendInfo(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_OPENING_STUDIO_PACK_SEED,
|
||||
MessageArgument.untrusted("value", displayName), MessageArgument.untrusted("seed", seed)));
|
||||
}
|
||||
|
||||
static void retainPackRestartRequirement(PackDownloader.PackInstallResult result) {
|
||||
if (result != null && result.restartRequired()) {
|
||||
ServerConfigurator.requireWorldCreationRestart();
|
||||
@@ -853,6 +865,7 @@ public class StudioSVC implements IrisService {
|
||||
if (reportPackAdmissionFailure(sender, dimm, openKind) != null) {
|
||||
return;
|
||||
}
|
||||
announceOpen(sender, dimm, seed);
|
||||
StudioOpenCoordinator.StudioOpenKind requiredOpenKind = Objects.requireNonNull(
|
||||
openKind,
|
||||
"Studio open kind");
|
||||
@@ -868,7 +881,7 @@ public class StudioSVC implements IrisService {
|
||||
return;
|
||||
}
|
||||
IrisLogging.reportError("Failed to replace the active studio project with \"" + dimm + "\".", throwable);
|
||||
J.s(() -> sender.sendMessage(IrisLanguage.text(
|
||||
J.s(() -> sender.sendError(IrisLanguage.text(
|
||||
BukkitRuntimeMessages.STUDIO_S_V_C_FAILED_OPEN_STUDIO_WORLD_2,
|
||||
MessageArgument.untrusted("error", String.valueOf(errorDetail(throwable))))));
|
||||
});
|
||||
@@ -970,7 +983,7 @@ public class StudioSVC implements IrisService {
|
||||
return closeActiveProjectForReplacement(sender).handle((closeResult, closeThrowable) -> {
|
||||
if (closeThrowable != null) {
|
||||
IrisLogging.reportError("Failed while closing an existing studio project before opening \"" + dimension + "\".", closeThrowable);
|
||||
J.s(() -> sender.sendMessage(IrisLanguage.text(
|
||||
J.s(() -> sender.sendError(IrisLanguage.text(
|
||||
BukkitRuntimeMessages.STUDIO_S_V_C_FAILED_CLOSE_EXISTING_STUDIO_PROJECT,
|
||||
MessageArgument.untrusted("error", String.valueOf(errorDetail(closeThrowable))))));
|
||||
return false;
|
||||
@@ -978,7 +991,7 @@ public class StudioSVC implements IrisService {
|
||||
if (closeResult == null) {
|
||||
IllegalStateException failure = new IllegalStateException("Studio close completed without a result.");
|
||||
IrisLogging.reportError("Failed while closing an existing studio project before opening \"" + dimension + "\".", failure);
|
||||
J.s(() -> sender.sendMessage(IrisLanguage.text(
|
||||
J.s(() -> sender.sendError(IrisLanguage.text(
|
||||
BukkitRuntimeMessages.STUDIO_S_V_C_FAILED_CLOSE_EXISTING_STUDIO_PROJECT_2,
|
||||
MessageArgument.untrusted("error", String.valueOf(errorDetail(failure))))));
|
||||
return false;
|
||||
@@ -986,7 +999,7 @@ public class StudioSVC implements IrisService {
|
||||
if (closeResult.failureCause() != null) {
|
||||
Throwable failure = closeResult.failureCause();
|
||||
IrisLogging.reportError("Failed while closing an existing studio project before opening \"" + dimension + "\".", failure);
|
||||
J.s(() -> sender.sendMessage(IrisLanguage.text(
|
||||
J.s(() -> sender.sendError(IrisLanguage.text(
|
||||
BukkitRuntimeMessages.STUDIO_S_V_C_FAILED_CLOSE_EXISTING_STUDIO_PROJECT_2,
|
||||
MessageArgument.untrusted("error", String.valueOf(errorDetail(failure))))));
|
||||
return false;
|
||||
@@ -1025,7 +1038,7 @@ public class StudioSVC implements IrisService {
|
||||
if (activeProject == project) {
|
||||
activeProject = null;
|
||||
}
|
||||
J.s(() -> sender.sendMessage(IrisLanguage.text(
|
||||
J.s(() -> sender.sendError(IrisLanguage.text(
|
||||
BukkitRuntimeMessages.STUDIO_S_V_C_FAILED_OPEN_STUDIO_WORLD_2,
|
||||
MessageArgument.untrusted("error", String.valueOf(errorDetail(e))))));
|
||||
return CompletableFuture.completedFuture(null);
|
||||
@@ -1229,7 +1242,7 @@ public class StudioSVC implements IrisService {
|
||||
private void createProject(VolmitSender sender, String requestedName, String requestedTemplate, File selectedTemplatePack) {
|
||||
Optional<String> startupDenial = IrisStartupValidation.denialReason();
|
||||
if (startupDenial.isPresent()) {
|
||||
sender.sendMessage("Studio project creation refused: " + startupDenial.get());
|
||||
sender.sendMessage(ChatReport.Tone.ERROR.paint("Studio project creation refused: " + startupDenial.get()));
|
||||
return;
|
||||
}
|
||||
String normalizedName;
|
||||
@@ -1240,7 +1253,7 @@ public class StudioSVC implements IrisService {
|
||||
templateName = requestedTemplate == null ? null : normalizeProjectName(requestedTemplate);
|
||||
workspace = requireSafeWorkspace(getWorkspaceFolder());
|
||||
} catch (IOException e) {
|
||||
sender.sendMessage("Studio project creation refused: " + errorDetail(e));
|
||||
sender.sendMessage(ChatReport.Tone.ERROR.paint("Studio project creation refused: " + errorDetail(e)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1268,7 +1281,7 @@ public class StudioSVC implements IrisService {
|
||||
File newPack = new File(workspace, projectName);
|
||||
createdPack = newPack;
|
||||
if (Files.exists(newPack.toPath(), LinkOption.NOFOLLOW_LINKS) || Files.isSymbolicLink(newPack.toPath())) {
|
||||
sender.sendMessage("Studio project '" + projectName + "' already exists; nothing was changed.");
|
||||
sender.sendMessage(ChatReport.Tone.WARNING.paint("Studio project '" + projectName + "' already exists; nothing was changed."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1277,13 +1290,15 @@ public class StudioSVC implements IrisService {
|
||||
} else {
|
||||
File importPack = selectedTemplatePack == null ? new File(workspace, templateName) : selectedTemplatePack;
|
||||
if (!hasLoadableDimensionFile(importPack, templateName)) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_COULDN_T_FIND_PACK_CREATE_NEW_DIMENSION_FROM));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_MISSING_IMPORTED_DIMENSION_FILE));
|
||||
sender.sendReport(ChatReport.of(ChatReport.Tone.ERROR,
|
||||
IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_COULDN_T_FIND_PACK_CREATE_NEW_DIMENSION_FROM))
|
||||
.item(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_MISSING_IMPORTED_DIMENSION_FILE))
|
||||
.build());
|
||||
return;
|
||||
}
|
||||
PackValidationRegistry.requireLoadable(importPack.getName());
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_IMPORTING_INTO_NEW_PROJECT, MessageArgument.untrusted("downloadable", String.valueOf(templateName)), MessageArgument.untrusted("s", String.valueOf(projectName))));
|
||||
sender.sendInfo(IrisLanguage.text(BukkitRuntimeMessages.STUDIO_S_V_C_IMPORTING_INTO_NEW_PROJECT,MessageArgument.untrusted("downloadable", String.valueOf(templateName)), MessageArgument.untrusted("s", String.valueOf(projectName))));
|
||||
createFrom(importPack, templateName, projectName);
|
||||
}
|
||||
projectPublished = true;
|
||||
@@ -1292,10 +1307,8 @@ public class StudioSVC implements IrisService {
|
||||
PackValidationRegistry.publish(createdValidation);
|
||||
if (!createdValidation.isLoadable()) {
|
||||
rollbackCreatedProject(sender, newPack,
|
||||
"Studio project validation failed; the new project was rolled back.");
|
||||
for (String reason : createdValidation.getBlockingErrors()) {
|
||||
sender.sendMessage(reason);
|
||||
}
|
||||
"Studio project validation failed; the new project was rolled back",
|
||||
createdValidation.getBlockingErrors());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1310,17 +1323,14 @@ public class StudioSVC implements IrisService {
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage("Created studio project '" + projectName + "' at " + newPack.getAbsolutePath() + ".");
|
||||
if (installOutcome == CreationOutcome.RESTART) {
|
||||
sender.sendMessage("The project is complete, but Iris must restart before opening it. After restart, run /iris studio open " + projectName + ".");
|
||||
}
|
||||
sendCreated(sender, projectName, newPack, installOutcome == CreationOutcome.RESTART);
|
||||
outcome = installOutcome;
|
||||
} catch (Throwable e) {
|
||||
if (projectPublished && createdPack != null) {
|
||||
rollbackCreatedProject(sender, createdPack, "Studio project creation failed; the new project was rolled back.");
|
||||
}
|
||||
IrisLogging.reportError("Failed to create studio project '" + projectName + "'.", e);
|
||||
sender.sendMessage("Studio project creation failed: " + errorDetail(e));
|
||||
sender.sendMessage(ChatReport.Tone.ERROR.paint("Studio project creation failed: " + errorDetail(e)));
|
||||
} finally {
|
||||
closeLease(lease);
|
||||
}
|
||||
@@ -1573,15 +1583,30 @@ public class StudioSVC implements IrisService {
|
||||
&& Files.isRegularFile(dimension, LinkOption.NOFOLLOW_LINKS);
|
||||
}
|
||||
|
||||
private static void rollbackCreatedProject(VolmitSender sender, File project, String message) {
|
||||
Throwable cleanupFailure = rollbackCreatedProjectFiles(project);
|
||||
if (cleanupFailure == null) {
|
||||
sender.sendMessage(message);
|
||||
return;
|
||||
private static void sendCreated(VolmitSender sender, String projectName, File pack, boolean restartRequired) {
|
||||
String openCommand = "/iris studio open " + projectName;
|
||||
ChatReport.Builder report = ChatReport.of(ChatReport.Tone.SUCCESS, "Created Studio project " + projectName)
|
||||
.entry("Folder", pack.getAbsolutePath());
|
||||
if (restartRequired) {
|
||||
report.hint("Restart the server, then run " + openCommand, openCommand);
|
||||
} else {
|
||||
report.hint("Run " + openCommand, openCommand);
|
||||
}
|
||||
IrisLogging.reportError("Failed to fully roll back studio project " + project.getPath(), cleanupFailure);
|
||||
sender.sendMessage(message + " Cleanup was incomplete; check the console and "
|
||||
+ project.getAbsolutePath() + ".");
|
||||
sender.sendReport(report.build());
|
||||
}
|
||||
|
||||
private static void rollbackCreatedProject(VolmitSender sender, File project, String message) {
|
||||
rollbackCreatedProject(sender, project, message, List.of());
|
||||
}
|
||||
|
||||
private static void rollbackCreatedProject(VolmitSender sender, File project, String message, List<String> reasons) {
|
||||
ChatReport.Builder report = ChatReport.of(ChatReport.Tone.ERROR, message).items(reasons);
|
||||
Throwable cleanupFailure = rollbackCreatedProjectFiles(project);
|
||||
if (cleanupFailure != null) {
|
||||
IrisLogging.reportError("Failed to fully roll back studio project " + project.getPath(), cleanupFailure);
|
||||
report.hint("Cleanup was incomplete; check the console and " + project.getAbsolutePath(), null);
|
||||
}
|
||||
sender.sendReport(report.build());
|
||||
}
|
||||
|
||||
static Throwable rollbackCreatedProjectFiles(File project) {
|
||||
@@ -1608,7 +1633,7 @@ public class StudioSVC implements IrisService {
|
||||
}
|
||||
|
||||
private static void sendBusy(VolmitSender sender, LifecycleOperationCoordinator.BusyException busy) {
|
||||
sender.sendMessage(packMutationBusyMessage(busy.currentOperation()));
|
||||
sender.sendMessage(ChatReport.Tone.WARNING.paint(packMutationBusyMessage(busy.currentOperation())));
|
||||
}
|
||||
|
||||
static String packMutationBusyMessage(LifecycleOperationCoordinator.ActiveOperation operation) {
|
||||
|
||||
@@ -2126,3 +2126,7 @@ open = "Öffnen: {url}"
|
||||
open-description = "Den hochgeladenen Diagnosebericht öffnen."
|
||||
copy-path = "Lokalen Pfad kopieren"
|
||||
copy-path-description = "Den Pfad des lokalen Berichts kopieren."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "+{count} weitere"
|
||||
click_to_insert = "Klicken, um {command} einzufügen"
|
||||
@@ -2126,3 +2126,7 @@ open = "Abrir: {url}"
|
||||
open-description = "Abrir el informe de diagnóstico subido."
|
||||
copy-path = "Copiar ruta local"
|
||||
copy-path-description = "Copiar la ruta del informe local."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "+{count} más"
|
||||
click_to_insert = "Haz clic para insertar {command}"
|
||||
@@ -2131,3 +2131,7 @@ open = "Avaa: {url}"
|
||||
open-description = "Avaa lähetetty vianmääritysraportti."
|
||||
copy-path = "Kopioi paikallinen polku"
|
||||
copy-path-description = "Kopioi paikallisen raportin polku."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "+{count} lisää"
|
||||
click_to_insert = "Napsauta lisätäksesi {command}"
|
||||
@@ -2126,3 +2126,7 @@ open = "Ouvrir : {url}"
|
||||
open-description = "Ouvrir le rapport de diagnostic envoyé."
|
||||
copy-path = "Copier le chemin local"
|
||||
copy-path-description = "Copier le chemin du rapport local."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "+{count} de plus"
|
||||
click_to_insert = "Cliquez pour insérer {command}"
|
||||
@@ -2131,3 +2131,7 @@ open = "פתיחה: {url}"
|
||||
open-description = "פתיחת דוח האבחון שהועלה."
|
||||
copy-path = "העתקת הנתיב המקומי"
|
||||
copy-path-description = "העתקת הנתיב של הדוח המקומי."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "+{count} נוספים"
|
||||
click_to_insert = "לחצו כדי להוסיף את {command}"
|
||||
@@ -2126,3 +2126,7 @@ open = "Apri: {url}"
|
||||
open-description = "Apri il rapporto diagnostico caricato."
|
||||
copy-path = "Copia percorso locale"
|
||||
copy-path-description = "Copia il percorso del rapporto locale."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "+{count} altri"
|
||||
click_to_insert = "Clicca per inserire {command}"
|
||||
@@ -2129,3 +2129,7 @@ open = "開く: {url}"
|
||||
open-description = "アップロードした診断レポートを開きます。"
|
||||
copy-path = "ローカルパスをコピー"
|
||||
copy-path-description = "ローカルのレポートのパスをコピーします。"
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "他 {count} 件"
|
||||
click_to_insert = "クリックして {command} を入力"
|
||||
@@ -2129,3 +2129,7 @@ open = "열기: {url}"
|
||||
open-description = "업로드한 진단 보고서를 엽니다."
|
||||
copy-path = "로컬 경로 복사"
|
||||
copy-path-description = "로컬 보고서 경로를 복사합니다."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "외 {count}개"
|
||||
click_to_insert = "클릭하여 {command} 입력"
|
||||
@@ -2131,3 +2131,7 @@ open = "Atidaryti: {url}"
|
||||
open-description = "Atidaryti įkeltą diagnostikos ataskaitą."
|
||||
copy-path = "Kopijuoti vietinį kelią"
|
||||
copy-path-description = "Kopijuoti vietinės ataskaitos kelią."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "dar {count}"
|
||||
click_to_insert = "Spustelėkite, kad įterptumėte {command}"
|
||||
@@ -2126,3 +2126,7 @@ open = "Openen: {url}"
|
||||
open-description = "Open het geüploade diagnoserapport."
|
||||
copy-path = "Lokaal pad kopiëren"
|
||||
copy-path-description = "Kopieer het pad van het lokale rapport."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "+{count} meer"
|
||||
click_to_insert = "Klik om {command} in te voegen"
|
||||
@@ -2131,3 +2131,7 @@ open = "Otwórz: {url}"
|
||||
open-description = "Otwórz przesłany raport diagnostyczny."
|
||||
copy-path = "Kopiuj lokalną ścieżkę"
|
||||
copy-path-description = "Skopiuj ścieżkę raportu lokalnego."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "+{count} więcej"
|
||||
click_to_insert = "Kliknij, aby wstawić {command}"
|
||||
@@ -2126,3 +2126,7 @@ open = "Abrir: {url}"
|
||||
open-description = "Abrir o relatório de diagnóstico enviado."
|
||||
copy-path = "Copiar caminho local"
|
||||
copy-path-description = "Copiar o caminho do relatório local."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "+{count} mais"
|
||||
click_to_insert = "Clica para inserir {command}"
|
||||
@@ -2131,3 +2131,7 @@ open = "Открыть: {url}"
|
||||
open-description = "Открыть загруженный диагностический отчёт."
|
||||
copy-path = "Скопировать локальный путь"
|
||||
copy-path-description = "Скопировать путь к локальному отчёту."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "ещё {count}"
|
||||
click_to_insert = "Нажмите, чтобы вставить {command}"
|
||||
@@ -2131,3 +2131,7 @@ open = "Aç: {url}"
|
||||
open-description = "Yüklenen tanılama raporunu açın."
|
||||
copy-path = "Yerel yolu kopyala"
|
||||
copy-path-description = "Yerel raporun yolunu kopyalayın."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "+{count} tane daha"
|
||||
click_to_insert = "{command} eklemek için tıklayın"
|
||||
@@ -2129,3 +2129,7 @@ open = "Mở: {url}"
|
||||
open-description = "Mở báo cáo chẩn đoán đã tải lên."
|
||||
copy-path = "Sao chép đường dẫn cục bộ"
|
||||
copy-path-description = "Sao chép đường dẫn của báo cáo cục bộ."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "+{count} mục khác"
|
||||
click_to_insert = "Nhấp để chèn {command}"
|
||||
@@ -2129,3 +2129,7 @@ open = "打开:{url}"
|
||||
open-description = "打开已上传的诊断报告。"
|
||||
copy-path = "复制本地路径"
|
||||
copy-path-description = "复制本地报告的路径。"
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "另有 {count} 项"
|
||||
click_to_insert = "点击插入 {command}"
|
||||
@@ -2129,3 +2129,7 @@ open = "開啟:{url}"
|
||||
open-description = "開啟已上傳的診斷報告。"
|
||||
copy-path = "複製本機路徑"
|
||||
copy-path-description = "複製本機報告的路徑。"
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "另有 {count} 項"
|
||||
click_to_insert = "點擊插入 {command}"
|
||||
Reference in new issue
Block a user