mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Themed boot validation output
- Share pack boot reporting between Bukkit and modded - Cap boot warnings and errors with a pointer to pack validate - Merge refused-world join notices into one report
This commit is contained in:
1 parent
8b98e2a61c
commit
4d0063dd7d
8 files changed
+121
-59
No files matched your search
@@ -107,7 +107,8 @@ public final class ChatReport {
|
||||
}
|
||||
}
|
||||
|
||||
private void logLine(String text) {
|
||||
private void logLine(String styledText) {
|
||||
String text = IrisLogging.clean(styledText);
|
||||
switch (tone) {
|
||||
case ERROR -> IrisLogging.error(text);
|
||||
case WARNING -> IrisLogging.warn(text);
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package art.arcane.iris.pack;
|
||||
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.pack.validation.PackCompatReport;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
|
||||
/** Console output for pack validation at startup, shared by every platform so the boot log reads the same. */
|
||||
public final class PackBootReporter {
|
||||
private static final int BOOT_ITEM_LIMIT = 5;
|
||||
private static final int COMPAT_SUBJECTS_PER_KEY = 3;
|
||||
|
||||
private PackBootReporter() {
|
||||
}
|
||||
|
||||
public static void logBroken(PackValidationResult result) {
|
||||
String pack = result.getPackName();
|
||||
ChatReport.of(ChatReport.Tone.ERROR,
|
||||
"Pack '" + pack + "' failed validation; world and Studio creation with it are refused")
|
||||
.items(result.getBlockingErrors())
|
||||
.limit(BOOT_ITEM_LIMIT)
|
||||
.hint(listEverythingHint(pack), null)
|
||||
.build()
|
||||
.log();
|
||||
}
|
||||
|
||||
public static void logValidated(PackValidationResult result, String minecraftVersion, boolean announceClean) {
|
||||
String pack = result.getPackName();
|
||||
String compatSummary = PackValidator.compatSummary(result, minecraftVersion);
|
||||
String compatSuffix = compatSummary.isEmpty() ? "" : " " + compatSummary;
|
||||
if (!result.getWarnings().isEmpty()) {
|
||||
ChatReport.of(ChatReport.Tone.WARNING,
|
||||
"Pack '" + pack + "' validated with " + result.getWarnings().size() + " warning(s)." + compatSuffix)
|
||||
.items(result.getWarnings())
|
||||
.limit(BOOT_ITEM_LIMIT)
|
||||
.hint(listEverythingHint(pack), null)
|
||||
.build()
|
||||
.log();
|
||||
return;
|
||||
}
|
||||
if (announceClean || !compatSummary.isEmpty()) {
|
||||
IrisLogging.info("Pack '" + pack + "' validated." + compatSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
public static void logCompat(PackValidationResult result, String minecraftVersion) {
|
||||
if (result == null || result.getCompatFindings().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
PackCompatReport.of(result.getCompatFindings())
|
||||
.bootReport(result.getPackName(), PackValidator.versionOf(result, minecraftVersion),
|
||||
COMPAT_SUBJECTS_PER_KEY, BOOT_ITEM_LIMIT)
|
||||
.log();
|
||||
}
|
||||
|
||||
private static String listEverythingHint(String pack) {
|
||||
return "/iris pack validate " + pack + " lists everything";
|
||||
}
|
||||
}
|
||||
@@ -356,7 +356,7 @@ public final class PackValidator {
|
||||
.summaryLine(versionOf(result, minecraftVersion));
|
||||
}
|
||||
|
||||
private static String versionOf(PackValidationResult result, String minecraftVersion) {
|
||||
static String versionOf(PackValidationResult result, String minecraftVersion) {
|
||||
if (minecraftVersion != null && !minecraftVersion.isBlank()) {
|
||||
return minecraftVersion;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ import java.util.function.BiConsumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import art.arcane.iris.localization.BukkitRuntimeMessages;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
public class ServerConfigurator {
|
||||
private static final Object DATAPACK_INSTALL_LOCK = new Object();
|
||||
@@ -815,9 +816,11 @@ public class ServerConfigurator {
|
||||
|
||||
for (Player i : Bukkit.getOnlinePlayers()) {
|
||||
if (i.isOp() || i.hasPermission("iris.all")) {
|
||||
VolmitSender sender = new VolmitSender(i, BukkitPlatform.volmitPlugin().getTag("WARNING"));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.SERVER_CONFIGURATOR_THERE_ARE_SOME_IRIS_PACKS_THAT_HAVE_CUSTOM_BIOMES_THEM));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.SERVER_CONFIGURATOR_YOU_NEED_RESTART_YOUR_SERVER_USE_THESE_PACKS));
|
||||
VolmitSender sender = new VolmitSender(i, BukkitPlatform.volmitPlugin().getTag());
|
||||
sender.sendReport(ChatReport.of(ChatReport.Tone.WARNING,
|
||||
IrisLanguage.text(BukkitRuntimeMessages.SERVER_CONFIGURATOR_THERE_ARE_SOME_IRIS_PACKS_THAT_HAVE_CUSTOM_BIOMES_THEM))
|
||||
.hint(IrisLanguage.text(BukkitRuntimeMessages.SERVER_CONFIGURATOR_YOU_NEED_RESTART_YOUR_SERVER_USE_THESE_PACKS), null)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package art.arcane.iris.pack.validation;
|
||||
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumMap;
|
||||
@@ -157,15 +159,35 @@ public final class PackCompatReport {
|
||||
if (findings.isEmpty()) {
|
||||
return lines;
|
||||
}
|
||||
lines.add("Pack '" + packName + "': content unavailable on Minecraft " + versionOrUnknown(minecraftVersion));
|
||||
lines.add(bootHeader(packName, minecraftVersion));
|
||||
for (String line : keyLines(perKeyCap)) {
|
||||
lines.add(" " + line);
|
||||
}
|
||||
lines.add(" Update the server to a newer Minecraft to restore this content, or declare fallbacks"
|
||||
+ " (dimension blockFallbacks, block backup). /iris pack compat " + packName + " lists everything.");
|
||||
lines.add(" " + bootRemedy(packName));
|
||||
return lines;
|
||||
}
|
||||
|
||||
/** The boot listing as a themed report, capped to {@code maxKeys} keys; null when there are no findings. */
|
||||
public synchronized ChatReport bootReport(String packName, String minecraftVersion, int perKeyCap, int maxKeys) {
|
||||
if (findings.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return ChatReport.of(ChatReport.Tone.WARNING, bootHeader(packName, minecraftVersion))
|
||||
.items(keyLines(perKeyCap))
|
||||
.limit(maxKeys)
|
||||
.hint(bootRemedy(packName), null)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static String bootHeader(String packName, String minecraftVersion) {
|
||||
return "Pack '" + packName + "': content unavailable on Minecraft " + versionOrUnknown(minecraftVersion);
|
||||
}
|
||||
|
||||
private static String bootRemedy(String packName) {
|
||||
return "Update the server to a newer Minecraft to restore this content, or declare fallbacks"
|
||||
+ " (dimension blockFallbacks, block backup). /iris pack compat " + packName + " lists everything.";
|
||||
}
|
||||
|
||||
/**
|
||||
* One line per key, with up to {@code perKeyCap} subjects each and a {@code +N more} tail beyond that; pass 0 for
|
||||
* every subject. No header and no remediation hint - the command wraps these in localized text.
|
||||
|
||||
Reference in new issue
Block a user