Themed command and progress output

- Restyle structure verify, regions, metrics, worlds and engine status
- Fold datapack export diagnostics into one report
- Share one progress bar and slow per-tick action bar updates
- Tag permission, jigsaw and auto-studio messages
This commit is contained in:
piexel committed 2026-11-18 13:32:44 +01:00
1 parent 6b1e1e55cb
commit ebf3ca85cc
14 files changed
+264 -176

No files matched your search

@@ -930,7 +930,7 @@ public final class IrisRuntime implements IrisPluginRuntime {
Iris.debug("Starting up auto Studio!"); Iris.debug("Starting up auto Studio!");
try { try {
Player r = new KList<>(plugin.getServer().getOnlinePlayers()).getRandom(); Player r = new KList<>(plugin.getServer().getOnlinePlayers()).getRandom();
Iris.service(StudioSVC.class).open(r != null ? new VolmitSender(r) : getSender(), 1337, IrisSettings.get().getGenerator().getDefaultWorldType(), (w) -> { Iris.service(StudioSVC.class).open(r != null ? new VolmitSender(r, plugin.getTag()) : getSender(), 1337, IrisSettings.get().getGenerator().getDefaultWorldType(), (w) -> {
J.s(() -> { J.s(() -> {
final Location spawn = w.getSpawnLocation(); final Location spawn = w.getSpawnLocation();
for (Player i : plugin.getServer().getOnlinePlayers()) { for (Player i : plugin.getServer().getOnlinePlayers()) {
@@ -23,6 +23,7 @@ import art.arcane.iris.command.handlers.DimensionHandler;
import art.arcane.iris.generation.terrain.IrisDimension; import art.arcane.iris.generation.terrain.IrisDimension;
import art.arcane.iris.localization.BukkitCommandMessages; import art.arcane.iris.localization.BukkitCommandMessages;
import art.arcane.iris.localization.C; import art.arcane.iris.localization.C;
import art.arcane.iris.localization.ChatReport;
import art.arcane.iris.localization.DirectorCommandMessages; import art.arcane.iris.localization.DirectorCommandMessages;
import art.arcane.iris.localization.IrisLanguage; import art.arcane.iris.localization.IrisLanguage;
import art.arcane.iris.pack.datapack.DataVersion; import art.arcane.iris.pack.datapack.DataVersion;
@@ -46,12 +47,14 @@ import art.arcane.volmlib.util.localization.LanguageAudience;
import art.arcane.volmlib.util.localization.MessageArgument; import art.arcane.volmlib.util.localization.MessageArgument;
import art.arcane.volmlib.util.localization.TextKey; import art.arcane.volmlib.util.localization.TextKey;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@Director(name = "datapack", aliases = {"datapacks", "dp"}, description = "Download & manage external datapack imports", descriptionKey = "iris.director.commanddatapack.director.download_manage_external_datapack_imports_modrinth") @Director(name = "datapack", aliases = {"datapacks", "dp"}, description = "Download & manage external datapack imports", descriptionKey = "iris.director.commanddatapack.director.download_manage_external_datapack_imports_modrinth")
public class CommandDatapack implements DirectorExecutor { public class CommandDatapack implements DirectorExecutor {
private static final int RESOURCE_REPORTS = 4; private static final int RESOURCE_REPORTS = 4;
private static final int EXPORT_DIAGNOSTIC_LIMIT = 10;
@Director(description = "Download/update every datapack listed in a pack dimension's 'datapackImports' and install it into the world so its structures register like vanilla", descriptionKey = "iris.director.commanddatapack.director.download_update_every_datapack_listed_pack_dimension_s_datapackimports_install_it_into", aliases = {"pull"}) @Director(description = "Download/update every datapack listed in a pack dimension's 'datapackImports' and install it into the world so its structures register like vanilla", descriptionKey = "iris.director.commanddatapack.director.download_update_every_datapack_listed_pack_dimension_s_datapackimports_install_it_into", aliases = {"pull"})
public void ingest( public void ingest(
@@ -69,19 +72,22 @@ public class CommandDatapack implements DirectorExecutor {
KList<String> configured = DatapackIngestService.collectConfiguredImports(); KList<String> configured = DatapackIngestService.collectConfiguredImports();
List<DatapackIngestService.Entry> installed = DatapackIngestService.installed(); List<DatapackIngestService.Entry> installed = DatapackIngestService.installed();
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_CONFIGURED_DATAPACK_IMPORTS, MessageArgument.untrusted("value", configured.size()))); ChatReport.Builder imports = ChatReport.of(ChatReport.Tone.INFO,
for (String url : configured) { IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_CONFIGURED_DATAPACK_IMPORTS, MessageArgument.untrusted("value", configured.size())))
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_MESSAGE, MessageArgument.untrusted("url", url))); .unlimited()
} .items(configured);
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_INSTALLED_DATAPACKS, MessageArgument.untrusted("value", installed.size())));
for (DatapackIngestService.Entry entry : installed) {
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_MESSAGE_2, MessageArgument.untrusted("value", entry.id), MessageArgument.untrusted("value2", (entry.versionNumber == null ? "?" : entry.versionNumber))));
}
if (configured.isEmpty()) { if (configured.isEmpty()) {
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_ADD_MODRINTH_URLS_DIMENSION_S_DATAPACKIMPORTS_LIST_THEN_RUN_IRIS)); imports.hint(IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_ADD_MODRINTH_URLS_DIMENSION_S_DATAPACKIMPORTS_LIST_THEN_RUN_IRIS), null);
} }
sender.sendReport(imports.build());
ChatReport.Builder installedReport = ChatReport.of(ChatReport.Tone.INFO,
IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_INSTALLED_DATAPACKS, MessageArgument.untrusted("value", installed.size())))
.unlimited();
for (DatapackIngestService.Entry entry : installed) {
installedReport.entry(entry.id, entry.versionNumber == null ? "?" : entry.versionNumber);
}
sender.sendReport(installedReport.build());
} }
@Director(description = "Remove an installed datapack by id (also delete its URL from datapackImports to keep it gone)", descriptionKey = "iris.director.commanddatapack.director.remove_installed_datapack_by_id_also_delete_its_url_from_datapackimports_keep", aliases = {"rm"}) @Director(description = "Remove an installed datapack by id (also delete its URL from datapackImports to keep it gone)", descriptionKey = "iris.director.commanddatapack.director.remove_installed_datapack_by_id_also_delete_its_url_from_datapackimports_keep", aliases = {"rm"})
@@ -158,17 +164,33 @@ public class CommandDatapack implements DirectorExecutor {
} }
private static void reportExport(ExportFeedback feedback, WorldgenExportResult result) { private static void reportExport(ExportFeedback feedback, WorldgenExportResult result) {
for (ExportDiagnostic diagnostic : result.diagnostics()) { ChatReport.Builder report = ChatReport.of(exportTone(result), exportTitle(result)).limit(EXPORT_DIAGNOSTIC_LIMIT);
feedback.send(diagnosticColor(diagnostic.severity()), IrisLanguage.text(DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_DIAGNOSTIC, MessageArgument.untrusted("key", diagnosticLabel(diagnostic)), MessageArgument.untrusted("message", diagnostic.message()))); result.diagnostics().stream()
.sorted(Comparator.comparingInt((ExportDiagnostic diagnostic) -> diagnostic.severity().ordinal()).reversed())
.forEach(diagnostic -> report.styledItem(diagnosticColor(diagnostic.severity())
+ ChatReport.clean(IrisLanguage.text(DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_DIAGNOSTIC,
MessageArgument.untrusted("key", diagnosticLabel(diagnostic)),
MessageArgument.untrusted("message", diagnostic.message())))));
feedback.report(report.build());
}
private static ChatReport.Tone exportTone(WorldgenExportResult result) {
if (!result.isSuccess()) {
return ChatReport.Tone.ERROR;
} }
boolean warned = result.diagnostics().stream()
.anyMatch(diagnostic -> diagnostic.severity() != ExportDiagnostic.Severity.INFO);
return warned ? ChatReport.Tone.WARNING : ChatReport.Tone.SUCCESS;
}
private static String exportTitle(WorldgenExportResult result) {
if (result.isSuccess()) { if (result.isSuccess()) {
feedback.send(C.GREEN, IrisLanguage.text(DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_EXPORTED, MessageArgument.untrusted("path", result.output()))); return IrisLanguage.text(DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_EXPORTED, MessageArgument.untrusted("path", result.output()));
return;
} }
TextKey outcome = result.status() == WorldgenExportResult.Status.REJECTED TextKey outcome = result.status() == WorldgenExportResult.Status.REJECTED
? DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_REJECTED ? DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_REJECTED
: DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_FAILED; : DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_FAILED;
feedback.send(C.RED, IrisLanguage.text(outcome, MessageArgument.untrusted("reason", result.message()))); return IrisLanguage.text(outcome, MessageArgument.untrusted("reason", result.message()));
} }
private static C diagnosticColor(ExportDiagnostic.Severity severity) { private static C diagnosticColor(ExportDiagnostic.Severity severity) {
@@ -208,11 +230,19 @@ public class CommandDatapack implements DirectorExecutor {
private void send(C color, String message) { private void send(C color, String message) {
String line = color + message; String line = color + message;
deliver(() -> sender.sendMessage(line));
}
private void report(ChatReport report) {
deliver(() -> sender.sendReport(report));
}
private void deliver(Runnable delivery) {
if (sender.isPlayer()) { if (sender.isPlayer()) {
J.runEntity(sender.player(), () -> sender.sendMessage(line)); J.runEntity(sender.player(), delivery);
return; return;
} }
sender.sendMessage(line); delivery.run();
} }
} }
} }
@@ -47,6 +47,8 @@ import art.arcane.volmlib.util.director.annotations.Param;
import art.arcane.volmlib.util.director.exceptions.DirectorParsingException; import art.arcane.volmlib.util.director.exceptions.DirectorParsingException;
import art.arcane.iris.command.specialhandlers.NullablePlayerHandler; import art.arcane.iris.command.specialhandlers.NullablePlayerHandler;
import art.arcane.iris.localization.C; import art.arcane.iris.localization.C;
import art.arcane.iris.localization.BukkitRuntimeMessages;
import art.arcane.iris.localization.ChatReport;
import art.arcane.iris.platform.bukkit.plugin.VolmitSender; import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
import art.arcane.iris.world.task.J; import art.arcane.iris.world.task.J;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -58,6 +60,7 @@ import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.ArrayList;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@@ -82,6 +85,7 @@ public class CommandIris implements DirectorExecutor {
private static final String NO_DOWNLOAD_SOURCE = "__none__"; private static final String NO_DOWNLOAD_SOURCE = "__none__";
private static final String PRESERVE_REPLACEMENT_SEED = "preserve"; private static final String PRESERVE_REPLACEMENT_SEED = "preserve";
private static final long WORLD_UNLOAD_TIMEOUT_SECONDS = 150L; private static final long WORLD_UNLOAD_TIMEOUT_SECONDS = 150L;
private static final int METRICS_DETAIL_LIMIT = 12;
private CommandStudio studio; private CommandStudio studio;
private CommandPregen pregen; private CommandPregen pregen;
@@ -340,26 +344,18 @@ public class CommandIris implements DirectorExecutor {
} }
} }
if (sender().isPlayer()) { sender().sendReport(worldListReport(ChatReport.Tone.SUCCESS,
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_IRIS_WORLDS)); IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_IRIS_WORLDS), IrisWorlds));
for (World IrisWorld : IrisWorlds.copy()) { sender().sendReport(worldListReport(ChatReport.Tone.INFO,
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_MESSAGE, MessageArgument.untrusted("value", IrisWorld.getName()))); IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_BUKKIT_WORLDS), BukkitWorlds));
} }
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_BUKKIT_WORLDS));
for (World BukkitWorld : BukkitWorlds.copy()) { private static ChatReport worldListReport(ChatReport.Tone tone, String title, List<World> worlds) {
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_MESSAGE_2, MessageArgument.untrusted("value", BukkitWorld.getName()))); ChatReport.Builder report = ChatReport.of(tone, title).unlimited();
} for (World world : worlds) {
} else { report.item(world.getName());
Iris.info(C.BLUE + "Iris Worlds: ");
for (World IrisWorld : IrisWorlds.copy()) {
Iris.info(C.IRIS + "- " +IrisWorld.getName());
}
Iris.info(C.GOLD + "Bukkit Worlds: ");
for (World BukkitWorld : BukkitWorlds.copy()) {
Iris.info(C.GRAY + "- " +BukkitWorld.getName());
}
} }
return report.build();
} }
@Director(description = "Remove an Iris world", descriptionKey = "iris.director.commandiris.director.remove_iris_world", aliases = {"rm"}, sync = true) @Director(description = "Remove an Iris world", descriptionKey = "iris.director.commandiris.director.remove_iris_world", aliases = {"rm"}, sync = true)
@@ -465,8 +461,22 @@ public class CommandIris implements DirectorExecutor {
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_YOU_MUST_BE_IRIS_WORLD)); sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_YOU_MUST_BE_IRIS_WORLD));
return; return;
} }
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_SENDING_METRICS)); List<String> lines = new ArrayList<>();
engine().printMetrics(sender()::sendMessage); engine().printMetrics(lines::add);
String detailsHeader = IrisLanguage.text(BukkitRuntimeMessages.IRIS_ENGINE_DETAILS);
int detailsIndex = lines.indexOf(detailsHeader);
List<String> totals = detailsIndex < 0 ? lines : lines.subList(0, detailsIndex);
sender().sendReport(ChatReport.of(ChatReport.Tone.SUCCESS,
IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_SENDING_METRICS))
.items(totals)
.unlimited()
.build());
if (detailsIndex >= 0) {
sender().sendReport(ChatReport.of(ChatReport.Tone.INFO, detailsHeader)
.items(lines.subList(detailsIndex + 1, lines.size()))
.limit(METRICS_DETAIL_LIMIT)
.build());
}
} }
@Director(description = "Reload configuration file (this is also done automatically)", descriptionKey = "iris.director.commandiris.director.reload_configuration_file_this_is_also_done_automatically") @Director(description = "Reload configuration file (this is also done automatically)", descriptionKey = "iris.director.commandiris.director.reload_configuration_file_this_is_also_done_automatically")
@@ -26,6 +26,7 @@ import art.arcane.iris.world.IrisToolbelt;
import art.arcane.volmlib.util.director.annotations.Director; import art.arcane.volmlib.util.director.annotations.Director;
import art.arcane.volmlib.util.director.annotations.Param; import art.arcane.volmlib.util.director.annotations.Param;
import art.arcane.iris.localization.C; import art.arcane.iris.localization.C;
import art.arcane.iris.localization.ChatReport;
import art.arcane.volmlib.util.format.Form; import art.arcane.volmlib.util.format.Form;
import art.arcane.volmlib.util.math.Position2; import art.arcane.volmlib.util.math.Position2;
import org.bukkit.World; import org.bukkit.World;
@@ -82,9 +83,13 @@ public class CommandPregen implements DirectorExecutor {
} else { } else {
IrisToolbelt.pregenerate(task, world); IrisToolbelt.pregenerate(task, world);
} }
String msg = C.GREEN + "Pregen started in " + C.GOLD + world.getName() + C.GREEN + " of " + C.GOLD + (radius * 2) + C.GREEN + " by " + C.GOLD + (radius * 2) + C.GREEN + " blocks from " + C.GOLD + center.getX() + "," + center.getZ(); String msg = C.GRAY + "Pregen started in " + ChatReport.highlight(world.getName())
+ " over " + ChatReport.highlight((radius * 2) + "×" + (radius * 2)) + " blocks around "
+ ChatReport.highlight(center.getBlockX() + ", " + center.getBlockZ());
sender().sendMessage(msg); sender().sendMessage(msg);
Iris.info(msg); if (sender().isPlayer()) {
Iris.info(msg);
}
} catch (Throwable e) { } catch (Throwable e) {
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_PREGEN_FAILED_START_PREGENERATION_SEE_CONSOLE_DETAILS)); sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_PREGEN_FAILED_START_PREGENERATION_SEE_CONSOLE_DETAILS));
Iris.reportError(e); Iris.reportError(e);
@@ -94,9 +99,11 @@ public class CommandPregen implements DirectorExecutor {
@Director(description = "Stop the active pregeneration task", descriptionKey = "iris.director.commandpregen.director.stop_active_pregeneration_task", aliases = "x") @Director(description = "Stop the active pregeneration task", descriptionKey = "iris.director.commandpregen.director.stop_active_pregeneration_task", aliases = "x")
public void stop() { public void stop() {
if (PregeneratorJob.shutdownInstance()) { if (PregeneratorJob.shutdownInstance()) {
String message = C.BLUE + "Pregen stop requested; finishing active work before cancellation."; String message = "Pregen stop requested; finishing active work before cancellation.";
sender().sendMessage(message); sender().sendInfo(message);
Iris.info(message); if (sender().isPlayer()) {
Iris.info(message);
}
} else { } else {
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_PREGEN_NO_ACTIVE_PREGENERATION_TASKS_STOP)); sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_PREGEN_NO_ACTIVE_PREGENERATION_TASKS_STOP));
} }
@@ -120,8 +127,10 @@ public class CommandPregen implements DirectorExecutor {
} }
String world = progress.worldName() == null ? "?" : progress.worldName(); String world = progress.worldName() == null ? "?" : progress.worldName();
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_PREGEN_PREGEN, MessageArgument.untrusted("world", world), MessageArgument.untrusted("value", Form.f(progress.generated())), MessageArgument.untrusted("value2", Form.f(progress.totalChunks())), MessageArgument.untrusted("value3", String.format("%.1f", progress.percent())), MessageArgument.untrusted("value4", (progress.paused() ? C.YELLOW + " PAUSED" : "")))); ChatReport.Tone tone = progress.failed() > 0 ? ChatReport.Tone.WARNING
sender().sendMessage(IrisLanguage.text( : progress.paused() ? ChatReport.Tone.INFO : ChatReport.Tone.SUCCESS;
String headline = IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_PREGEN_PREGEN, MessageArgument.untrusted("world", world), MessageArgument.untrusted("value", Form.f(progress.generated())), MessageArgument.untrusted("value2", Form.f(progress.totalChunks())), MessageArgument.untrusted("value3", String.format("%.1f", progress.percent())), MessageArgument.untrusted("value4", (progress.paused() ? " PAUSED" : "")));
sender().sendReport(ChatReport.of(tone, headline).item(IrisLanguage.text(
BukkitCommandMessagesExtended.COMMAND_PREGEN_SPEED_S_ETA_ELAPSED_METHOD, BukkitCommandMessagesExtended.COMMAND_PREGEN_SPEED_S_ETA_ELAPSED_METHOD,
MessageArgument.untrusted("overall", Form.f(progress.overallChunksPerSecond(), 1)), MessageArgument.untrusted("overall", Form.f(progress.overallChunksPerSecond(), 1)),
MessageArgument.untrusted("tenSecond", Form.f(progress.chunksPerSecond(), 1)), MessageArgument.untrusted("tenSecond", Form.f(progress.chunksPerSecond(), 1)),
@@ -130,6 +139,6 @@ public class CommandPregen implements DirectorExecutor {
MessageArgument.untrusted("eta", Form.duration(progress.eta(), 2)), MessageArgument.untrusted("eta", Form.duration(progress.eta(), 2)),
MessageArgument.untrusted("elapsed", Form.duration(progress.elapsed(), 2)), MessageArgument.untrusted("elapsed", Form.duration(progress.elapsed(), 2)),
MessageArgument.untrusted("method", progress.method()), MessageArgument.untrusted("method", progress.method()),
MessageArgument.untrusted("failures", progress.failed() > 0 ? C.RED + " Failed: " + Form.f(progress.failed()) : ""))); MessageArgument.untrusted("failures", progress.failed() > 0 ? " Failed: " + Form.f(progress.failed()) : ""))).build());
} }
} }
@@ -22,6 +22,7 @@ import art.arcane.iris.Iris;
import art.arcane.iris.configuration.IrisSettings; import art.arcane.iris.configuration.IrisSettings;
import art.arcane.volmlib.util.cache.AtomicCache; import art.arcane.volmlib.util.cache.AtomicCache;
import art.arcane.iris.localization.C; import art.arcane.iris.localization.C;
import art.arcane.iris.localization.ChatReport;
import art.arcane.iris.platform.bukkit.plugin.IrisService; import art.arcane.iris.platform.bukkit.plugin.IrisService;
import art.arcane.iris.platform.bukkit.plugin.VolmitSender; import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
import art.arcane.iris.world.task.J; import art.arcane.iris.world.task.J;
@@ -190,10 +191,11 @@ public class CommandSVC implements IrisService, CommandExecutor, TabCompleter, D
} }
if (!(args.length > 1 && args[0].equalsIgnoreCase("debug") && args[1].equalsIgnoreCase("dump")) if (!(args.length > 1 && args[0].equalsIgnoreCase("debug") && args[1].equalsIgnoreCase("dump"))
&& !sender.hasPermission(ROOT_PERMISSION)) { && !sender.hasPermission(ROOT_PERMISSION)) {
ComponentMessenger.sendSection(sender, IrisLanguage.text( String tag = Iris.instance == null ? "" : Iris.instance.getTag();
ComponentMessenger.sendSection(sender, tag + ChatReport.Tone.ERROR.paint(IrisLanguage.text(
IrisMessages.COMMAND_PERMISSION_DENIED, IrisMessages.COMMAND_PERMISSION_DENIED,
MessageArgument.trusted("permission", ROOT_PERMISSION) MessageArgument.trusted("permission", ROOT_PERMISSION)
)); )));
return; return;
} }
@@ -42,6 +42,7 @@ import art.arcane.iris.structure.nativegen.NativeStructureGenerationStatus;
import art.arcane.iris.structure.object.ObjectPlaceMode; import art.arcane.iris.structure.object.ObjectPlaceMode;
import art.arcane.volmlib.util.collection.KList; import art.arcane.volmlib.util.collection.KList;
import art.arcane.iris.localization.C; import art.arcane.iris.localization.C;
import art.arcane.iris.localization.ChatReport;
import art.arcane.volmlib.util.director.DirectorOrigin; import art.arcane.volmlib.util.director.DirectorOrigin;
import art.arcane.volmlib.util.director.annotations.Director; import art.arcane.volmlib.util.director.annotations.Director;
import art.arcane.volmlib.util.director.annotations.Param; import art.arcane.volmlib.util.director.annotations.Param;
@@ -61,6 +62,7 @@ import org.bukkit.entity.Player;
import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.Structure;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@@ -73,6 +75,7 @@ import art.arcane.volmlib.util.localization.MessageArgument;
import art.arcane.iris.localization.BukkitCommandMessagesExtended; import art.arcane.iris.localization.BukkitCommandMessagesExtended;
@Director(name = "structure", aliases = {"struct", "str"}, description = "Iris structure tools (index, import, info)", descriptionKey = "iris.director.commandstructure.director.iris_structure_tools_index_import_info") @Director(name = "structure", aliases = {"struct", "str"}, description = "Iris structure tools (index, import, info)", descriptionKey = "iris.director.commandstructure.director.iris_structure_tools_index_import_info")
public class CommandStructure implements DirectorExecutor { public class CommandStructure implements DirectorExecutor {
private static final int VERIFY_ITEM_LIMIT = 15;
@Director(description = "Regenerate structure-index.json listing all vanilla, datapack & iris structures", descriptionKey = "iris.director.commandstructure.director.regenerate_structure_index_json_listing_all_vanilla_datapack_iris_structures", aliases = {"ls"}, origin = DirectorOrigin.BOTH) @Director(description = "Regenerate structure-index.json listing all vanilla, datapack & iris structures", descriptionKey = "iris.director.commandstructure.director.regenerate_structure_index_json_listing_all_vanilla_datapack_iris_structures", aliases = {"ls"}, origin = DirectorOrigin.BOTH)
public void list( public void list(
@Param(description = "The dimension whose pack to index", descriptionKey = "iris.director.commandstructure.param.dimension_whose_pack_index", aliases = "dim") @Param(description = "The dimension whose pack to index", descriptionKey = "iris.director.commandstructure.param.dimension_whose_pack_index", aliases = "dim")
@@ -171,7 +174,6 @@ public class CommandStructure implements DirectorExecutor {
private void runVerification(Engine engine, KList<String> structureKeys, int centerX, int centerZ, private void runVerification(Engine engine, KList<String> structureKeys, int centerX, int centerZ,
int searchRadius, VolmitSender commandSender, Player target) { int searchRadius, VolmitSender commandSender, Player target) {
KList<String> messages = new KList<>();
Map<String, IrisNativeStructureDecision> decisions = new HashMap<>(structureKeys.size()); Map<String, IrisNativeStructureDecision> decisions = new HashMap<>(structureKeys.size());
boolean requiresNativeReachability = false; boolean requiresNativeReachability = false;
for (String keyName : structureKeys) { for (String keyName : structureKeys) {
@@ -185,8 +187,8 @@ public class CommandStructure implements DirectorExecutor {
try { try {
reachable = StructureReachability.reachableKeys(engine); reachable = StructureReachability.reachableKeys(engine);
} catch (Throwable error) { } catch (Throwable error) {
messages.add(C.RED + "Structure verification could not resolve native biome reachability."); sendVerificationReport(commandSender, target, ChatReport.of(ChatReport.Tone.ERROR,
sendVerificationMessages(commandSender, target, messages); "Structure verification could not resolve native biome reachability").build());
Iris.reportError("Could not resolve native structure biome reachability for verification.", error); Iris.reportError("Could not resolve native structure biome reachability for verification.", error);
return; return;
} }
@@ -197,6 +199,8 @@ public class CommandStructure implements DirectorExecutor {
int unreachable = 0; int unreachable = 0;
int searchLimited = 0; int searchLimited = 0;
int errors = 0; int errors = 0;
List<String> problems = new ArrayList<>();
List<String> planned = new ArrayList<>();
for (String keyName : structureKeys) { for (String keyName : structureKeys) {
IrisNativeStructureDecision decision = decisions.get(keyName); IrisNativeStructureDecision decision = decisions.get(keyName);
if (IrisStructureLocator.isPlaced(engine, keyName)) { if (IrisStructureLocator.isPlaced(engine, keyName)) {
@@ -205,56 +209,54 @@ public class CommandStructure implements DirectorExecutor {
IrisStructureLocator.locate(engine, keyName, centerX, centerZ, searchRadius); IrisStructureLocator.locate(engine, keyName, centerX, centerZ, searchRadius);
if (result.status() == IrisStructureLocator.LocateStatus.SEARCH_LIMIT_REACHED) { if (result.status() == IrisStructureLocator.LocateStatus.SEARCH_LIMIT_REACHED) {
searchLimited++; searchLimited++;
messages.add(C.YELLOW + "[iris-search-limit] " + C.WHITE + keyName + C.YELLOW problems.add(verifyLine(C.GOLD, keyName, "density search hit its safety limit"));
+ ": unable to complete the density search before its safety limit was reached");
continue; continue;
} }
if (!result.found()) { if (!result.found()) {
messages.add(C.YELLOW + "[iris-not-found] " + C.WHITE + keyName); problems.add(verifyLine(C.GOLD, keyName, "not found in range"));
continue; continue;
} }
located++; located++;
messages.add(C.AQUA + "[iris-planned] " + C.WHITE + keyName + C.GREEN + " @ " planned.add(verifyLine(C.IRIS, keyName,
+ result.originX() + "," + result.baseY() + "," + result.originZ()); result.originX() + ", " + result.baseY() + ", " + result.originZ()));
} catch (Throwable error) { } catch (Throwable error) {
errors++; errors++;
messages.add(C.RED + "[error] " + C.WHITE + keyName + C.RED + ": " problems.add(verifyLine(C.RED, keyName, error.getClass().getSimpleName()));
+ error.getClass().getSimpleName());
Iris.reportError("Could not verify Iris-placed structure '" + keyName + "'.", error); Iris.reportError("Could not verify Iris-placed structure '" + keyName + "'.", error);
} }
continue; continue;
} }
if (!decision.generate()) { if (!decision.generate()) {
disabled++; disabled++;
messages.add(C.GRAY + "[disabled] " + C.WHITE + keyName);
continue; continue;
} }
if (!reachable.contains(keyName.toLowerCase(Locale.ROOT))) { if (!reachable.contains(keyName.toLowerCase(Locale.ROOT))) {
unreachable++; unreachable++;
KList<String> missing = StructureReachability.missingBiomeKeys(engine, keyName); KList<String> missing = StructureReachability.missingBiomeKeys(engine, keyName);
messages.add(C.YELLOW + "[unreachable] " + C.WHITE + keyName problems.add(verifyLine(C.GOLD, keyName,
+ (missing.isEmpty() ? "" : C.YELLOW + " needs " + String.join("/", missing))); missing.isEmpty() ? "no biome can place it" : "needs " + String.join("/", missing)));
continue; continue;
} }
nativeEligible++; nativeEligible++;
messages.add(C.GREEN + "[native-eligible] " + C.WHITE + keyName);
} }
messages.add(C.GREEN + "Structure verify: " + C.WHITE + located + C.GREEN + " Iris placement plans found, " String summary = "Structure verify: " + located + " planned, " + nativeEligible + " native, "
+ C.WHITE + nativeEligible + C.GREEN + " native structures eligible, " + disabled + " disabled, " + unreachable + " unreachable, " + searchLimited + " search-limited, "
+ C.WHITE + disabled + C.GREEN + " disabled by policy, " + errors + " errors";
+ C.WHITE + unreachable + C.GREEN + " biome-unreachable, " ChatReport.Tone tone = errors > 0 ? ChatReport.Tone.ERROR
+ C.WHITE + searchLimited + C.GREEN + " density searches safety-limited, " : problems.isEmpty() ? ChatReport.Tone.SUCCESS : ChatReport.Tone.WARNING;
+ C.WHITE + errors + C.GREEN + " errors. Native eligibility is checked without running blocking live locates."); ChatReport.Builder report = ChatReport.of(tone, summary).limit(VERIFY_ITEM_LIMIT);
sendVerificationMessages(commandSender, target, messages); problems.forEach(report::styledItem);
planned.forEach(report::styledItem);
report.hint("Native eligibility is checked without running blocking live locates", null);
sendVerificationReport(commandSender, target, report.build());
} }
private void sendVerificationMessages(VolmitSender commandSender, Player target, private static String verifyLine(C accent, String keyName, String detail) {
KList<String> messages) { return C.WHITE + ChatReport.clean(keyName) + C.DARK_GRAY + ": " + accent + ChatReport.clean(detail);
Runnable send = () -> { }
for (String message : messages) {
commandSender.sendMessage(message); private void sendVerificationReport(VolmitSender commandSender, Player target, ChatReport report) {
} Runnable send = () -> commandSender.sendReport(report);
};
if (target != null) { if (target != null) {
J.runEntity(target, send); J.runEntity(target, send);
} else { } else {
@@ -60,6 +60,7 @@ import art.arcane.volmlib.util.director.DirectorOrigin;
import art.arcane.volmlib.util.director.annotations.Director; import art.arcane.volmlib.util.director.annotations.Director;
import art.arcane.volmlib.util.director.annotations.Param; import art.arcane.volmlib.util.director.annotations.Param;
import art.arcane.iris.localization.C; import art.arcane.iris.localization.C;
import art.arcane.iris.localization.ChatReport;
import art.arcane.volmlib.util.format.Form; import art.arcane.volmlib.util.format.Form;
import art.arcane.volmlib.util.function.NoiseProvider; import art.arcane.volmlib.util.function.NoiseProvider;
import art.arcane.volmlib.util.interpolation.InterpolationMethod; import art.arcane.volmlib.util.interpolation.InterpolationMethod;
@@ -113,6 +114,11 @@ public class CommandStudio implements DirectorExecutor {
private CommandEdit edit; private CommandEdit edit;
//private CommandDeepSearch deepSearch; //private CommandDeepSearch deepSearch;
private static String regionShareLine(String region, int rarity, double share) {
return C.WHITE + ChatReport.clean(region) + C.DARK_GRAY + ": " + C.IRIS + Form.pc(share, 1)
+ C.DARK_GRAY + " · " + C.GRAY + "rarity " + rarity;
}
public static String hrf(Duration duration) { public static String hrf(Duration duration) {
return duration.toString().substring(2).replaceAll("(\\d[HMS])(?!$)", "$1 ").toLowerCase(); return duration.toString().substring(2).replaceAll("(\\d[HMS])(?!$)", "$1 ").toLowerCase();
} }
@@ -441,9 +447,15 @@ public class CommandStudio implements DirectorExecutor {
})).setOffset(loc.getBlockX(), loc.getBlockZ()).drain(); })).setOffset(loc.getBlockX(), loc.getBlockZ()).drain();
executor.complete(); executor.complete();
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_STUDIO_DONE));
var loader = engine.getData().getRegionLoader(); var loader = engine.getData().getRegionLoader();
data.forEach((k, v) -> sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_STUDIO_MESSAGE, MessageArgument.untrusted("k", k), MessageArgument.untrusted("value", loader.load(k).getRarity()), MessageArgument.untrusted("value2", Form.f((double) v.get() / totalTasks * 100, 2))))); ChatReport.Builder report = ChatReport.of(ChatReport.Tone.SUCCESS,
IrisLanguage.text(BukkitCommandMessages.COMMAND_STUDIO_DONE)).unlimited();
data.entrySet().stream()
.sorted((a, b) -> Integer.compare(b.getValue().get(), a.getValue().get()))
.forEach(entry -> report.styledItem(regionShareLine(entry.getKey(),
loader.load(entry.getKey()).getRarity(),
(double) entry.getValue().get() / totalTasks)));
sender.sendReport(report.build());
} catch (Throwable e) { } catch (Throwable e) {
Iris.reportError(e); Iris.reportError(e);
sender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_REGIONS_SCAN_FAILED, sender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_REGIONS_SCAN_FAILED,
@@ -10,8 +10,10 @@ import art.arcane.volmlib.util.format.Form;
import java.util.List; import java.util.List;
import art.arcane.iris.localization.ChatReport;
import art.arcane.iris.localization.IrisLanguage; import art.arcane.iris.localization.IrisLanguage;
import art.arcane.iris.localization.BukkitCommandMessages; import art.arcane.iris.localization.BukkitCommandMessages;
import art.arcane.volmlib.util.localization.TextKey;
import art.arcane.iris.localization.RuntimeUiMessages; import art.arcane.iris.localization.RuntimeUiMessages;
import art.arcane.volmlib.util.localization.MessageArgument; import art.arcane.volmlib.util.localization.MessageArgument;
final class IrisEngineStatus { final class IrisEngineStatus {
@@ -22,36 +24,52 @@ final class IrisEngineStatus {
CacheSummary caches = summarizeCaches(); CacheSummary caches = summarizeCaches();
MaintenanceMetrics metrics = snapshot.metrics(); MaintenanceMetrics metrics = snapshot.metrics();
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MESSAGE)); sender.sendReport(section(BukkitCommandMessages.IRIS_ENGINE_STATUS_STATUS,
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_STATUS)); IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_SERVICE, MessageArgument.trusted("value", status(snapshot.serviceRunning()))),
sender.sendMessage(IrisLanguage.text( IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_METRICS, MessageArgument.trusted("value", status(snapshot.metricsRunning()))),
BukkitCommandMessages.IRIS_ENGINE_STATUS_SERVICE, IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MAINTENANCE_PERIOD, MessageArgument.untrusted("value", Form.duration(snapshot.maintenancePeriodMillis()))),
MessageArgument.trusted("value", status(snapshot.serviceRunning())) IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_WORKER_PARALLELISM, MessageArgument.untrusted("value", snapshot.workerParallelism())),
)); IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_ACTIVE_WORLD_TASKS, MessageArgument.untrusted("value", metrics.activeTasks()))));
sender.sendMessage(IrisLanguage.text( sender.sendReport(section(BukkitCommandMessages.IRIS_ENGINE_STATUS_TECTONIC_PLATES,
BukkitCommandMessages.IRIS_ENGINE_STATUS_METRICS, IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_CONFIGURED_RETENTION, MessageArgument.untrusted("value", Form.duration(snapshot.retentionMillis()))),
MessageArgument.trusted("value", status(snapshot.metricsRunning())) IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_HEAP_USAGE, MessageArgument.untrusted("value", Form.pc(snapshot.heapUsage()))),
)); IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_RESIDENT, MessageArgument.untrusted("value", metrics.residentTectonicPlates())),
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MAINTENANCE_PERIOD, MessageArgument.untrusted("value", Form.duration(snapshot.maintenancePeriodMillis())))); IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_QUEUED, MessageArgument.untrusted("value", metrics.queuedTectonicPlates())),
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_WORKER_PARALLELISM, MessageArgument.untrusted("value", snapshot.workerParallelism()))); IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_AVERAGE_IDLE_DURATION, MessageArgument.untrusted("value", Form.duration(metrics.averageIdleDuration(), 2))),
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_ACTIVE_WORLD_TASKS, MessageArgument.untrusted("value", metrics.activeTasks()))); IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MAX_IDLE_DURATION, MessageArgument.untrusted("value", Form.duration(metrics.maxIdleDuration(), 2))),
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_TECTONIC_PLATES)); IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MIN_IDLE_DURATION, MessageArgument.untrusted("value", Form.duration(metrics.minIdleDuration(), 2)))));
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_CONFIGURED_RETENTION, MessageArgument.untrusted("value", Form.duration(snapshot.retentionMillis())))); sender.sendReport(section(BukkitCommandMessages.IRIS_ENGINE_STATUS_CACHES,
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_HEAP_USAGE, MessageArgument.untrusted("value", Form.pc(snapshot.heapUsage())))); IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_RESOURCE, MessageArgument.untrusted("value", caches.sizes()[0]), MessageArgument.untrusted("value2", caches.counts()[0])),
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_RESIDENT, MessageArgument.untrusted("value", metrics.residentTectonicPlates()))); IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_2D_STREAM, MessageArgument.untrusted("value", caches.sizes()[1]), MessageArgument.untrusted("value2", caches.counts()[1])),
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_QUEUED, MessageArgument.untrusted("value", metrics.queuedTectonicPlates()))); IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_3D_STREAM, MessageArgument.untrusted("value", caches.sizes()[2]), MessageArgument.untrusted("value2", caches.counts()[2])),
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_AVERAGE_IDLE_DURATION, MessageArgument.untrusted("value", Form.duration(metrics.averageIdleDuration(), 2)))); IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_OTHER, MessageArgument.untrusted("value", caches.sizes()[3]), MessageArgument.untrusted("value2", caches.counts()[3]))));
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MAX_IDLE_DURATION, MessageArgument.untrusted("value", Form.duration(metrics.maxIdleDuration(), 2)))); sender.sendReport(section(BukkitCommandMessages.IRIS_ENGINE_STATUS_OTHER_2,
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MIN_IDLE_DURATION, MessageArgument.untrusted("value", Form.duration(metrics.minIdleDuration(), 2)))); IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_IRIS_WORLDS, MessageArgument.untrusted("value", metrics.worlds())),
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_CACHES)); IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_LOADED_CHUNKS, MessageArgument.untrusted("value", metrics.loadedChunks()))));
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_RESOURCE, MessageArgument.untrusted("value", caches.sizes()[0]), MessageArgument.untrusted("value2", caches.counts()[0]))); }
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_2D_STREAM, MessageArgument.untrusted("value", caches.sizes()[1]), MessageArgument.untrusted("value2", caches.counts()[1])));
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_3D_STREAM, MessageArgument.untrusted("value", caches.sizes()[2]), MessageArgument.untrusted("value2", caches.counts()[2]))); private static ChatReport section(TextKey header, String... statLines) {
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_OTHER, MessageArgument.untrusted("value", caches.sizes()[3]), MessageArgument.untrusted("value2", caches.counts()[3]))); ChatReport.Builder report = ChatReport.of(ChatReport.Tone.INFO, stripTrailingColon(IrisLanguage.text(header))).unlimited();
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_OTHER_2)); for (String statLine : statLines) {
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_IRIS_WORLDS, MessageArgument.untrusted("value", metrics.worlds()))); report.styledItem(themedStat(statLine));
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_LOADED_CHUNKS, MessageArgument.untrusted("value", metrics.loadedChunks()))); }
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MESSAGE_2)); return report.build();
}
/** Status keys render as {@code - Label: value}; the label and value are recoloured to the Iris theme. */
private static String themedStat(String statLine) {
String cleaned = ChatReport.clean(statLine);
String withoutDash = cleaned.startsWith("-") ? cleaned.substring(1).strip() : cleaned;
int separator = withoutDash.indexOf(": ");
if (separator < 0) {
return withoutDash;
}
return ChatReport.label(withoutDash.substring(0, separator), withoutDash.substring(separator + 2));
}
private static String stripTrailingColon(String header) {
String cleaned = ChatReport.clean(header);
return cleaned.endsWith(":") ? cleaned.substring(0, cleaned.length() - 1) : cleaned;
} }
private static String status(boolean running) { private static String status(boolean running) {
@@ -0,0 +1,34 @@
package art.arcane.iris.localization;
/** The one progress bar Iris draws: a themed bar for action bars and a plain one for the console. */
public final class ProgressBar {
public static final int PLAYER_WIDTH = 44;
public static final int CONSOLE_WIDTH = 20;
private ProgressBar() {
}
public static String player(double progress) {
int filled = filledCells(progress, PLAYER_WIDTH);
StringBuilder bar = new StringBuilder(PLAYER_WIDTH * 3 + 8);
bar.append(C.DARK_GRAY).append("[");
for (int cell = 0; cell < PLAYER_WIDTH; cell++) {
bar.append(cell < filled ? C.IRIS : C.DARK_GRAY).append("|");
}
return bar.append(C.DARK_GRAY).append("]").toString();
}
public static String console(double progress) {
int filled = filledCells(progress, CONSOLE_WIDTH);
StringBuilder bar = new StringBuilder(CONSOLE_WIDTH + 2).append("[");
for (int cell = 0; cell < CONSOLE_WIDTH; cell++) {
bar.append(cell < filled ? "#" : "-");
}
return bar.append("]").toString();
}
private static int filledCells(double progress, int width) {
double clamped = Double.isNaN(progress) ? 0.0D : Math.max(0.0D, Math.min(1.0D, progress));
return (int) Math.round(clamped * width);
}
}
@@ -10,6 +10,8 @@ import art.arcane.iris.structure.graph.StructureAssemblyResult;
import art.arcane.iris.pack.value.IrisPosition; import art.arcane.iris.pack.value.IrisPosition;
import art.arcane.iris.structure.placement.IrisStructure; import art.arcane.iris.structure.placement.IrisStructure;
import art.arcane.iris.studio.generation.JigsawStudioGenerator; import art.arcane.iris.studio.generation.JigsawStudioGenerator;
import art.arcane.iris.localization.C;
import art.arcane.iris.localization.ChatReport;
import art.arcane.iris.platform.bukkit.BukkitPlatform; import art.arcane.iris.platform.bukkit.BukkitPlatform;
import art.arcane.iris.spi.IrisLogging; import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.IrisServices; import art.arcane.iris.spi.IrisServices;
@@ -389,7 +391,16 @@ public final class JigsawStudioService implements IrisService, JigsawStudioMenuA
static void message(Player player, String text) { static void message(Player player, String text) {
if (player != null) { if (player != null) {
J.runEntity(player, () -> ComponentMessenger.sendLiteral(player, "[Iris Jigsaw Studio] " + text)); String line = jigsawTag() + C.GRAY + ChatReport.clean(text);
J.runEntity(player, () -> ComponentMessenger.sendSection(player, line));
}
}
private static String jigsawTag() {
try {
return BukkitPlatform.volmitPlugin().getTag("Jigsaw");
} catch (IllegalStateException unhosted) {
return "";
} }
} }
@@ -22,7 +22,7 @@ import art.arcane.iris.localization.BukkitRuntimeMessages;
import art.arcane.iris.configuration.IrisSettings; import art.arcane.iris.configuration.IrisSettings;
import art.arcane.iris.localization.IrisLanguage; import art.arcane.iris.localization.IrisLanguage;
import art.arcane.iris.localization.RuntimeProgressMessages; import art.arcane.iris.localization.RuntimeProgressMessages;
import art.arcane.iris.localization.C; import art.arcane.iris.localization.ProgressBar;
import art.arcane.iris.platform.bukkit.plugin.VolmitSender; import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
import art.arcane.iris.world.task.J; import art.arcane.iris.world.task.J;
import art.arcane.volmlib.util.format.Form; import art.arcane.volmlib.util.format.Form;
@@ -36,13 +36,14 @@ import java.util.concurrent.atomic.AtomicReference;
@SuppressWarnings("ALL") @SuppressWarnings("ALL")
final class StudioOpenProgressReporter { final class StudioOpenProgressReporter {
private static final int STUDIO_PROGRESS_BAR_WIDTH = 44; private static final long CONSOLE_HEARTBEAT_MILLIS = 10_000L;
private StudioOpenProgressReporter() { private StudioOpenProgressReporter() {
} }
static void startStudioOpenReporter(VolmitSender sender, AtomicReference<String> stage, AtomicReference<Double> progress, AtomicBoolean complete, AtomicBoolean failed) { static void startStudioOpenReporter(VolmitSender sender, AtomicReference<String> stage, AtomicReference<Double> progress, AtomicBoolean complete, AtomicBoolean failed) {
AtomicLong nextConsoleUpdate = new AtomicLong(0L); AtomicLong nextConsoleUpdate = new AtomicLong(0L);
AtomicReference<String> lastConsoleStage = new AtomicReference<>("");
AtomicLong startMs = new AtomicLong(System.currentTimeMillis()); AtomicLong startMs = new AtomicLong(System.currentTimeMillis());
AtomicInteger taskId = new AtomicInteger(-1); AtomicInteger taskId = new AtomicInteger(-1);
org.bukkit.boss.BossBar bossBar; org.bukkit.boss.BossBar bossBar;
@@ -133,17 +134,17 @@ final class StudioOpenProgressReporter {
)); ));
} else { } else {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
long nextUpdate = nextConsoleUpdate.get(); boolean stageChanged = !currentStage.equals(lastConsoleStage.get());
if (now >= nextUpdate) { if (stageChanged || now >= nextConsoleUpdate.get()) {
String bar = buildStudioConsoleBar(currentProgress);
sender.sendMessage(IrisLanguage.text( sender.sendMessage(IrisLanguage.text(
RuntimeProgressMessages.STUDIO_CONSOLE_PROGRESS, RuntimeProgressMessages.STUDIO_CONSOLE_PROGRESS,
MessageArgument.trusted("bar", bar), MessageArgument.trusted("bar", ProgressBar.console(currentProgress)),
MessageArgument.trusted("percent", percent), MessageArgument.trusted("percent", percent),
MessageArgument.trusted("stage", currentStage), MessageArgument.trusted("stage", currentStage),
MessageArgument.trusted("elapsed", Form.duration(elapsed, 0)) MessageArgument.trusted("elapsed", Form.duration(elapsed, 0))
)); ));
nextConsoleUpdate.set(now + 1500L); lastConsoleStage.set(currentStage);
nextConsoleUpdate.set(now + CONSOLE_HEARTBEAT_MILLIS);
} }
} }
}, 3); }, 3);
@@ -155,26 +156,7 @@ final class StudioOpenProgressReporter {
} }
private static String buildStudioProgressBar(double progress) { private static String buildStudioProgressBar(double progress) {
int filled = (int) Math.round(Math.max(0.0D, Math.min(1.0D, progress)) * STUDIO_PROGRESS_BAR_WIDTH); return ProgressBar.player(progress);
StringBuilder bar = new StringBuilder(STUDIO_PROGRESS_BAR_WIDTH * 3 + 4);
bar.append(C.DARK_GRAY).append("[");
for (int i = 0; i < STUDIO_PROGRESS_BAR_WIDTH; i++) {
bar.append(i < filled ? C.GREEN : C.DARK_GRAY).append("|");
}
bar.append(C.DARK_GRAY).append("]");
return bar.toString();
}
private static String buildStudioConsoleBar(double progress) {
int width = 20;
int filled = (int) Math.round(Math.max(0.0D, Math.min(1.0D, progress)) * width);
StringBuilder bar = new StringBuilder();
bar.append("[");
for (int i = 0; i < width; i++) {
bar.append(i < filled ? "#" : "-");
}
bar.append("]");
return bar.toString();
} }
private static String describeStage(String stage) { private static String describeStage(String stage) {
@@ -37,6 +37,7 @@ import art.arcane.iris.world.lifecycle.WorldLifecycleCaller;
import art.arcane.iris.world.lifecycle.WorldLifecycleRequest; import art.arcane.iris.world.lifecycle.WorldLifecycleRequest;
import art.arcane.iris.world.lifecycle.WorldLifecycleService; import art.arcane.iris.world.lifecycle.WorldLifecycleService;
import art.arcane.iris.localization.IrisLanguage; import art.arcane.iris.localization.IrisLanguage;
import art.arcane.iris.localization.ProgressBar;
import art.arcane.iris.localization.RuntimeProgressMessages; import art.arcane.iris.localization.RuntimeProgressMessages;
import art.arcane.iris.platform.bukkit.nms.INMS; import art.arcane.iris.platform.bukkit.nms.INMS;
import art.arcane.iris.world.pregen.PregenTask; import art.arcane.iris.world.pregen.PregenTask;
@@ -96,6 +97,8 @@ public class IrisCreator {
private static final long INITIAL_SPAWN_TIMEOUT_SECONDS = 600L; private static final long INITIAL_SPAWN_TIMEOUT_SECONDS = 600L;
private static final long WORLD_ENTRY_TELEPORT_TIMEOUT_SECONDS = 60L; private static final long WORLD_ENTRY_TELEPORT_TIMEOUT_SECONDS = 60L;
private static final long ROLLBACK_PHASE_TIMEOUT_SECONDS = 120L; private static final long ROLLBACK_PHASE_TIMEOUT_SECONDS = 120L;
private static final int PLAYER_PROGRESS_INTERVAL_TICKS = 4;
private static final int CONSOLE_PROGRESS_INTERVAL_TICKS = 20;
/** /**
* Specify an area to pregenerate during creation * Specify an area to pregenerate during creation
@@ -639,7 +642,9 @@ public class IrisCreator {
return; return;
} }
int interval = studioProgressConsumer != null || creationReporter != null && sender.isPlayer() ? 1 : 20; int interval = studioProgressConsumer != null || creationReporter != null && sender.isPlayer()
? PLAYER_PROGRESS_INTERVAL_TICKS
: CONSOLE_PROGRESS_INTERVAL_TICKS;
taskId.set(J.ar(() -> { taskId.set(J.ar(() -> {
if (done.get()) { if (done.get()) {
cancelRepeatingTask(taskId); cancelRepeatingTask(taskId);
@@ -691,7 +696,7 @@ public class IrisCreator {
WorldCreationProgressReporter creationReporter WorldCreationProgressReporter creationReporter
) { ) {
AtomicInteger taskId = new AtomicInteger(-1); AtomicInteger taskId = new AtomicInteger(-1);
int interval = sender.isPlayer() ? 1 : 20; int interval = sender.isPlayer() ? PLAYER_PROGRESS_INTERVAL_TICKS : CONSOLE_PROGRESS_INTERVAL_TICKS;
taskId.set(J.ar(() -> { taskId.set(J.ar(() -> {
if (done.get()) { if (done.get()) {
cancelRepeatingTask(taskId); cancelRepeatingTask(taskId);
@@ -712,17 +717,9 @@ public class IrisCreator {
MessageArgument.trusted("percent", percent) MessageArgument.trusted("percent", percent)
), p, BarColor.GREEN, BarStyle.SOLID, 4000L); ), p, BarColor.GREEN, BarStyle.SOLID, 4000L);
} }
int barWidth = 44;
int filled = (int) Math.round(Math.max(0.0D, Math.min(1.0D, p)) * barWidth);
StringBuilder bar = new StringBuilder(barWidth * 3 + 4);
bar.append(C.DARK_GRAY).append("[");
for (int bi = 0; bi < barWidth; bi++) {
bar.append(bi < filled ? C.GREEN : C.DARK_GRAY).append("|");
}
bar.append(C.DARK_GRAY).append("]");
sender.sendAction(IrisLanguage.text( sender.sendAction(IrisLanguage.text(
RuntimeProgressMessages.WORLD_PREGEN_ACTION, RuntimeProgressMessages.WORLD_PREGEN_ACTION,
MessageArgument.trusted("bar", bar.toString()), MessageArgument.trusted("bar", ProgressBar.player(p)),
MessageArgument.trusted("percent", percent) MessageArgument.trusted("percent", percent)
)); ));
return; return;
@@ -20,7 +20,7 @@ package art.arcane.iris.world;
import art.arcane.iris.localization.IrisLanguage; import art.arcane.iris.localization.IrisLanguage;
import art.arcane.iris.localization.RuntimeProgressMessages; import art.arcane.iris.localization.RuntimeProgressMessages;
import art.arcane.iris.localization.C; import art.arcane.iris.localization.ProgressBar;
import art.arcane.iris.platform.bukkit.plugin.VolmitSender; import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
import art.arcane.iris.world.task.J; import art.arcane.iris.world.task.J;
import art.arcane.volmlib.util.format.Form; import art.arcane.volmlib.util.format.Form;
@@ -33,8 +33,6 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
final class WorldCreationProgressReporter { final class WorldCreationProgressReporter {
private static final int PLAYER_BAR_WIDTH = 44;
private static final int CONSOLE_BAR_WIDTH = 20;
private static final long CONSOLE_UPDATE_INTERVAL_MILLIS = 1500L; private static final long CONSOLE_UPDATE_INTERVAL_MILLIS = 1500L;
private final VolmitSender sender; private final VolmitSender sender;
@@ -207,11 +205,11 @@ final class WorldCreationProgressReporter {
} }
static String buildPlayerBar(double progress) { static String buildPlayerBar(double progress) {
return buildBar(progress, PLAYER_BAR_WIDTH, true); return ProgressBar.player(progress);
} }
static String buildConsoleBar(double progress) { static String buildConsoleBar(double progress) {
return buildBar(progress, CONSOLE_BAR_WIDTH, false); return ProgressBar.console(progress);
} }
static String terminalPlayerMessage( static String terminalPlayerMessage(
@@ -237,25 +235,6 @@ final class WorldCreationProgressReporter {
); );
} }
private static String buildBar(double progress, int width, boolean colored) {
int filled = (int) Math.round(clampProgress(progress) * width);
StringBuilder bar = new StringBuilder(colored ? width * 3 + 4 : width + 2);
if (colored) {
bar.append(C.DARK_GRAY);
}
bar.append("[");
for (int index = 0; index < width; index++) {
if (colored) {
bar.append(index < filled ? C.GREEN : C.DARK_GRAY).append("|");
} else {
bar.append(index < filled ? "#" : "-");
}
}
if (colored) {
bar.append(C.DARK_GRAY);
}
return bar.append("]").toString();
}
static TextKey stageKey(String stage) { static TextKey stageKey(String stage) {
if (stage == null || stage.isBlank()) { if (stage == null || stage.isBlank()) {
@@ -21,7 +21,6 @@ package art.arcane.iris.world.task.jobs;
import art.arcane.iris.localization.IrisLanguage; import art.arcane.iris.localization.IrisLanguage;
import art.arcane.iris.localization.RuntimeUiMessages; import art.arcane.iris.localization.RuntimeUiMessages;
import art.arcane.iris.platform.bukkit.BukkitPlatform; import art.arcane.iris.platform.bukkit.BukkitPlatform;
import art.arcane.iris.localization.C;
import art.arcane.volmlib.util.format.Form; import art.arcane.volmlib.util.format.Form;
import art.arcane.volmlib.util.localization.MessageArgument; import art.arcane.volmlib.util.localization.MessageArgument;
import art.arcane.iris.platform.bukkit.plugin.VolmitSender; import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
@@ -31,6 +30,9 @@ import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public interface Job { public interface Job {
int PLAYER_PROGRESS_INTERVAL_TICKS = 4;
int CONSOLE_PROGRESS_INTERVAL_TICKS = 100;
String getName(); String getName();
void execute(); void execute();
@@ -74,7 +76,7 @@ public interface Job {
} else { } else {
sender.sendMessage(getName() + ": " + getProgressString()); sender.sendMessage(getName() + ": " + getProgressString());
} }
}, sender.isPlayer() ? 0 : 20); }, sender.isPlayer() ? PLAYER_PROGRESS_INTERVAL_TICKS : CONSOLE_PROGRESS_INTERVAL_TICKS);
f.whenComplete((fs, ff) -> { f.whenComplete((fs, ff) -> {
J.car(c); J.car(c);
if (sender.isPlayer()) { if (sender.isPlayer()) {
@@ -82,7 +84,7 @@ public interface Job {
BukkitPlatform.hudLanes().hide(sender.player(), "iris:job"); BukkitPlatform.hudLanes().hide(sender.player(), "iris:job");
} }
if (!silentMsg) { if (!silentMsg) {
sender.sendMessage(C.AQUA + IrisLanguage.text( sender.sendSuccess(IrisLanguage.text(
RuntimeUiMessages.JOB_COMPLETED, RuntimeUiMessages.JOB_COMPLETED,
MessageArgument.untrusted("job", getName()), MessageArgument.untrusted("job", getName()),
MessageArgument.trusted("duration", Form.duration(p.getMilliseconds(), 1)) MessageArgument.trusted("duration", Form.duration(p.getMilliseconds(), 1))