mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 01:34:04 +00:00
Merge qol changes into studio hotload time
This commit is contained in:
commit
2689c7cb56
146 files changed
+4614
-879
No files matched your search
+64
@@ -28,6 +28,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -35,6 +36,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.junit.Test;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -196,6 +198,68 @@ public class CraftEngineDataProviderTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decayingCustomLeavesAreMadePersistentAndKeepTheirCustomIdentity() {
|
||||
BooleanProperty persistent = BooleanProperty.create("persistent", false);
|
||||
BlockDefinition definition = mock(BlockDefinition.class);
|
||||
ImmutableBlockState decaying = blockState(definition, "test:leaves[persistent=false]");
|
||||
ImmutableBlockState kept = blockState(definition, "test:leaves[persistent=true]");
|
||||
BlockData base = mock(BlockData.class);
|
||||
BlockData keptBase = mock(BlockData.class);
|
||||
doReturn(persistent).when(decaying).getProperty("persistent");
|
||||
doReturn(false).when(decaying).get(persistent);
|
||||
when(decaying.with(persistent, true)).thenReturn(kept);
|
||||
try (MockedStatic<CraftEngineBlocks> blocks = mockStatic(CraftEngineBlocks.class)) {
|
||||
blocks.when(() -> CraftEngineBlocks.getCustomBlockState(base)).thenReturn(decaying);
|
||||
blocks.when(() -> CraftEngineBlocks.getBukkitBlockData(kept)).thenReturn(keptBase);
|
||||
|
||||
IrisCustomData result = (IrisCustomData) new CraftEngineDataProvider()
|
||||
.withoutDecay(IrisCustomData.of(base, new Identifier("craftengine", "test/leaves[persistent=false]")));
|
||||
|
||||
assertSame(keptBase, result.getBase());
|
||||
assertEquals(new Identifier("test", "leaves[persistent=true]"), result.getCustom());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistentOrDecaylessCustomBlocksAreKeptAsTheyAre() {
|
||||
BooleanProperty persistent = BooleanProperty.create("persistent", false);
|
||||
BlockDefinition definition = mock(BlockDefinition.class);
|
||||
ImmutableBlockState alreadyPersistent = blockState(definition, "test:leaves[persistent=true]");
|
||||
ImmutableBlockState withoutProperty = blockState(definition, "test:log");
|
||||
BlockData persistentData = mock(BlockData.class);
|
||||
BlockData logData = mock(BlockData.class);
|
||||
BlockData vanilla = mock(BlockData.class);
|
||||
doReturn(persistent).when(alreadyPersistent).getProperty("persistent");
|
||||
doReturn(true).when(alreadyPersistent).get(persistent);
|
||||
try (MockedStatic<CraftEngineBlocks> blocks = mockStatic(CraftEngineBlocks.class)) {
|
||||
blocks.when(() -> CraftEngineBlocks.getCustomBlockState(persistentData)).thenReturn(alreadyPersistent);
|
||||
blocks.when(() -> CraftEngineBlocks.getCustomBlockState(logData)).thenReturn(withoutProperty);
|
||||
CraftEngineDataProvider provider = new CraftEngineDataProvider();
|
||||
|
||||
assertSame(persistentData, provider.withoutDecay(persistentData));
|
||||
assertSame(logData, provider.withoutDecay(logData));
|
||||
assertSame(vanilla, provider.withoutDecay(vanilla));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customBlocksCarryTheTagsTheirSettingsListEvenWhenWrapped() {
|
||||
ImmutableBlockState state = mock(ImmutableBlockState.class, Mockito.RETURNS_DEEP_STUBS);
|
||||
BlockData base = mock(BlockData.class);
|
||||
BlockData vanilla = mock(BlockData.class);
|
||||
when(state.settings().tags()).thenReturn(Set.of(Key.of("minecraft:logs")));
|
||||
try (MockedStatic<CraftEngineBlocks> blocks = mockStatic(CraftEngineBlocks.class)) {
|
||||
blocks.when(() -> CraftEngineBlocks.getCustomBlockState(base)).thenReturn(state);
|
||||
CraftEngineDataProvider provider = new CraftEngineDataProvider();
|
||||
BlockData wrapped = IrisCustomData.of(base, new Identifier("craftengine", "test/log"));
|
||||
|
||||
assertTrue(provider.hasBlockTag(wrapped, NamespacedKey.minecraft("logs")));
|
||||
assertFalse(provider.hasBlockTag(wrapped, NamespacedKey.minecraft("leaves")));
|
||||
assertFalse(provider.hasBlockTag(vanilla, NamespacedKey.minecraft("logs")));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknownOrInvalidBlockPropertiesFailBeforeNativeConversion() {
|
||||
Identifier id = new Identifier("test", "lamp");
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.pack.datapack.export.DatapackExportDestinations;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public final class ExportFormatHandler extends FixedChoiceHandler {
|
||||
public ExportFormatHandler() {
|
||||
super("zip", "directory");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String canonicalize(String input) {
|
||||
return DatapackExportDestinations.parseFormat(input).name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.pack.datapack.export.WorldgenExportMode;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public final class ExportModeHandler extends FixedChoiceHandler {
|
||||
public ExportModeHandler() {
|
||||
super("preset", "dimension", "overworld");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String canonicalize(String input) {
|
||||
return WorldgenExportMode.parse(input).name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.pack.datapack.DataVersion;
|
||||
import art.arcane.iris.pack.datapack.export.WorldgenExportTargets;
|
||||
|
||||
public final class ExportVersionHandler extends FixedChoiceHandler {
|
||||
public ExportVersionHandler() {
|
||||
super(WorldgenExportTargets.SUPPORTED.stream().map(DataVersion::getVersion).toArray(String[]::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String canonicalize(String input) {
|
||||
if (input == null || input.isBlank()) {
|
||||
return "";
|
||||
}
|
||||
return WorldgenExportTargets.resolve(input).getVersion();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.command.DirectorParameterHandler;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.director.exceptions.DirectorParsingException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FixedChoiceHandler implements DirectorParameterHandler<String> {
|
||||
private final List<String> choices;
|
||||
|
||||
protected FixedChoiceHandler(String... choices) {
|
||||
this.choices = List.of(choices);
|
||||
}
|
||||
|
||||
protected abstract String canonicalize(String input);
|
||||
|
||||
@Override
|
||||
public KList<String> getPossibilities() {
|
||||
return new KList<>(choices);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(String value) {
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parse(String input, boolean force) throws DirectorParsingException {
|
||||
try {
|
||||
return canonicalize(input);
|
||||
} catch (IllegalArgumentException error) {
|
||||
throw new DirectorParsingException(error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type == String.class;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.pack.datapack.DatapackIngestService;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public final class InstalledDatapackHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
return DatapackIngestService.installed().stream().map(entry -> entry.id).toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public final class MarkerHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
Engine activeEngine = engine();
|
||||
if (activeEngine == null || activeEngine.getData() == null) {
|
||||
return List.of();
|
||||
}
|
||||
return Arrays.stream(activeEngine.getData().getMarkerLoader().getPossibleKeys()).sorted().toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.command.DirectorParameterHandler;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class OpenSuggestionHandler implements DirectorParameterHandler<String> {
|
||||
protected abstract Collection<String> suggestions();
|
||||
|
||||
@Override
|
||||
public KList<String> getPossibilities() {
|
||||
return new KList<>(suggestions());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(String value) {
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parse(String input, boolean force) {
|
||||
return input == null ? "" : input.trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type == String.class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.pack.PackDirectoryResolver;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
public final class PackFolderHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
return PackDirectoryResolver.listVisiblePackDirectories(IrisPlatforms.get().packsFolder())
|
||||
.stream()
|
||||
.map(File::getName)
|
||||
.sorted()
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public final class PreviewApplyModeHandler extends FixedChoiceHandler {
|
||||
public PreviewApplyModeHandler() {
|
||||
super("preview", "apply");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String canonicalize(String input) {
|
||||
String mode = input.trim().toLowerCase(Locale.ROOT);
|
||||
if (!mode.equals("preview") && !mode.equals("apply")) {
|
||||
throw new IllegalArgumentException("Mode must be preview or apply.");
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public final class RegisteredStructureKeyHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
return IrisPlatforms.get().structureHooks().structureKeys().stream().sorted().toList();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.generation.subterrain.IrisSubterrainFamily;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
||||
public final class SubterrainFeatureHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
return Arrays.stream(IrisSubterrainFamily.values())
|
||||
.map(family -> family.name().toLowerCase(Locale.ROOT))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,93 @@
|
||||
package art.arcane.iris.diagnostics.splash;
|
||||
|
||||
import art.arcane.iris.BuildConstants;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.pack.BuiltInPackUpdates;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class IrisSplashComposer {
|
||||
private static final String SPLASH_PADDING = " ".repeat(4);
|
||||
private static final int FIRST_SPARE_INFO_ROW = 7;
|
||||
private static final int SPARE_INFO_ROWS = 3;
|
||||
private static final int PACKS_SHOWN = 6;
|
||||
private static final int SHORT_COMMIT_LENGTH = 7;
|
||||
private static final int LABEL_WIDTH = 14;
|
||||
private static final String FACT_GAP = " ";
|
||||
|
||||
private IrisSplashComposer() {
|
||||
}
|
||||
|
||||
public static String[] composeInfo(String version, String serverLine, InfoStyle style) {
|
||||
return composeInfo(version, serverLine, style, List.of());
|
||||
}
|
||||
|
||||
public static String[] composeInfo(String version, String serverLine, InfoStyle style, List<List<Detail>> detailRows) {
|
||||
String[] info = composeHeader(version, serverLine, style);
|
||||
int rows = Math.min(detailRows.size(), SPARE_INFO_ROWS);
|
||||
for (int row = 0; row < rows; row++) {
|
||||
info[FIRST_SPARE_INFO_ROW + row] = style.linePrefix() + styledRow(detailRows.get(row), style);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
public static String plainRow(List<Detail> row) {
|
||||
return styledRow(row, InfoStyle.PLAIN).strip();
|
||||
}
|
||||
|
||||
public static String packSummary(List<IrisSplashPackScanner.SplashPackMetadata> packs) {
|
||||
if (packs.isEmpty()) {
|
||||
return "none";
|
||||
}
|
||||
String shown = packs.stream()
|
||||
.limit(PACKS_SHOWN)
|
||||
.map(pack -> pack.name() + " v" + pack.version())
|
||||
.collect(Collectors.joining(", "));
|
||||
int hidden = packs.size() - PACKS_SHOWN;
|
||||
return hidden > 0 ? shown + " +" + hidden + " more" : shown;
|
||||
}
|
||||
|
||||
/** The first fact's value starts in the shared value column; further facts on the row follow after a gap. */
|
||||
private static String styledRow(List<Detail> row, InfoStyle style) {
|
||||
StringBuilder styled = new StringBuilder();
|
||||
for (Detail detail : row) {
|
||||
String label = styled.isEmpty()
|
||||
? " " + padRight(detail.label(), LABEL_WIDTH)
|
||||
: FACT_GAP + detail.label() + " ";
|
||||
styled.append(style.label(label))
|
||||
.append(detail.headline() ? style.headlineValue(detail.value()) : style.value(detail.value()));
|
||||
}
|
||||
return styled.toString();
|
||||
}
|
||||
|
||||
private static String padRight(String text, int width) {
|
||||
return text + " ".repeat(Math.max(1, width - text.length()));
|
||||
}
|
||||
|
||||
private static String shortCommit() {
|
||||
String commit = BuildConstants.COMMIT;
|
||||
return commit.length() > SHORT_COMMIT_LENGTH ? commit.substring(0, SHORT_COMMIT_LENGTH) : commit;
|
||||
}
|
||||
|
||||
private static String[] composeHeader(String version, String serverLine, InfoStyle style) {
|
||||
String releaseTrain = releaseTrain(version);
|
||||
String prefix = style.linePrefix();
|
||||
String java = javaVersion() < 0 ? "unknown" : String.valueOf(javaVersion());
|
||||
return new String[]{
|
||||
"",
|
||||
prefix + style.title(" Iris, ") + style.subtitle("Dimension Engine ") + style.tag("[" + releaseTrain + "]"),
|
||||
prefix + style.label(" Version: ") + style.value(version),
|
||||
prefix + style.label(" By: ") + style.value("Volmit Software (Arcane Arts)"),
|
||||
prefix + style.label(" Web: ") + style.value("VolmitSoftware.com"),
|
||||
prefix + style.label(" Server: ") + style.value(serverLine),
|
||||
prefix + style.label(" Java: ") + style.value(javaVersion() < 0 ? "unknown" : String.valueOf(javaVersion())) + style.label(" | Date: ") + style.value(startupDate()),
|
||||
prefix + style.label(" Commit: ") + style.value(BuildConstants.COMMIT) + style.label("/") + style.value(BuildConstants.ENVIRONMENT),
|
||||
prefix + styledRow(List.of(Detail.headline("Version", version)), style),
|
||||
prefix + styledRow(List.of(new Detail("By", "Volmit Software (Arcane Arts)")), style),
|
||||
prefix + styledRow(List.of(new Detail("Web", "volmitsoftware.com")), style),
|
||||
prefix + styledRow(List.of(Detail.headline("Server", serverLine)), style),
|
||||
prefix + styledRow(List.of(new Detail("Java", java), new Detail("Date", startupDate())), style),
|
||||
prefix + styledRow(List.of(new Detail("Commit", shortCommit() + "/" + BuildConstants.ENVIRONMENT)), style),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
@@ -43,29 +102,22 @@ public final class IrisSplashComposer {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static CompletableFuture<List<String>> composePackLines(File packFolder, IrisSplashPackScanner.SplashPackErrorReporter reporter) {
|
||||
List<IrisSplashPackScanner.SplashPackMetadata> packs = IrisSplashPackScanner.collect(packFolder, reporter);
|
||||
public static CompletableFuture<List<String>> composeUpdateLines(List<IrisSplashPackScanner.SplashPackMetadata> packs) {
|
||||
return BuiltInPackUpdates.check(packs.stream().map(IrisSplashPackScanner.SplashPackMetadata::name).toList())
|
||||
.thenApply(updates -> composePackLines(packs, updates));
|
||||
.thenApply(updates -> composeUpdateLines(packs, updates));
|
||||
}
|
||||
|
||||
static List<String> composePackLines(List<IrisSplashPackScanner.SplashPackMetadata> packs,
|
||||
Map<String, BuiltInPackUpdates.Update> updates) {
|
||||
if (packs.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
List<String> lines = new ArrayList<>(packs.size() + 1);
|
||||
lines.add("Custom Dimensions: " + packs.size());
|
||||
for (IrisSplashPackScanner.SplashPackMetadata pack : packs) {
|
||||
BuiltInPackUpdates.Update update = updates.get(pack.name());
|
||||
lines.add(" " + pack.name() + " v" + pack.version()
|
||||
+ (update == null ? "" : update.suffix(pack.version())));
|
||||
}
|
||||
static List<String> composeUpdateLines(List<IrisSplashPackScanner.SplashPackMetadata> packs,
|
||||
Map<String, BuiltInPackUpdates.Update> updates) {
|
||||
List<String> lines = new ArrayList<>();
|
||||
for (IrisSplashPackScanner.SplashPackMetadata pack : packs) {
|
||||
BuiltInPackUpdates.Update update = updates.get(pack.name());
|
||||
if (update != null && update.newerThan(pack.version())) {
|
||||
lines.add("Update " + pack.name() + ": /iris download pack=" + pack.name() + " overwrite=true");
|
||||
lines.addAll(ChatReport.of(ChatReport.Tone.INFO, "Pack " + pack.name() + " v" + update.version()
|
||||
+ " is available. You have v" + pack.version() + ".")
|
||||
.nextStep("Update it", "/iris download pack=" + pack.name() + " overwrite=true")
|
||||
.build()
|
||||
.consoleLines());
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
@@ -106,6 +158,17 @@ public final class IrisSplashComposer {
|
||||
return LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
}
|
||||
|
||||
/** A headline fact is what support asks for first, so its value stands out from the rest. */
|
||||
public record Detail(String label, String value, boolean headline) {
|
||||
public Detail(String label, String value) {
|
||||
this(label, value, false);
|
||||
}
|
||||
|
||||
public static Detail headline(String label, String value) {
|
||||
return new Detail(label, value, true);
|
||||
}
|
||||
}
|
||||
|
||||
public interface InfoStyle {
|
||||
InfoStyle PLAIN = new InfoStyle() {
|
||||
};
|
||||
@@ -133,5 +196,9 @@ public final class IrisSplashComposer {
|
||||
default String value(String text) {
|
||||
return text;
|
||||
}
|
||||
|
||||
default String headlineValue(String text) {
|
||||
return value(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,14 @@ public class B {
|
||||
return state != null && state.isTreeBlock();
|
||||
}
|
||||
|
||||
public static boolean isLog(NativeBlockState state) {
|
||||
return state != null && state.isLog();
|
||||
}
|
||||
|
||||
public static boolean isLeaves(NativeBlockState state) {
|
||||
return state != null && state.isLeaves();
|
||||
}
|
||||
|
||||
public static boolean isFoliagePlantable(NativeBlockState state) {
|
||||
return state != null && state.isFoliagePlantable();
|
||||
}
|
||||
|
||||
@@ -747,6 +747,10 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
|
||||
|
||||
boolean isStudio();
|
||||
|
||||
default StudioRestartRequirement getStudioRestartRequirement() {
|
||||
return StudioRestartRequirement.none();
|
||||
}
|
||||
|
||||
default IrisBiome getBiome(int x, int y, int z) {
|
||||
IrisBiome featureBiome = getSubterrainBiome(x, y, z);
|
||||
if (featureBiome != null) {
|
||||
|
||||
@@ -32,6 +32,10 @@ import art.arcane.iris.world.history.GenerationHistory;
|
||||
import art.arcane.iris.world.history.IrisBoundarySignatureSampler;
|
||||
import art.arcane.iris.world.history.GenerationHistoryRuntimeRouter;
|
||||
import art.arcane.iris.world.history.GenerationManifest;
|
||||
import art.arcane.iris.world.history.RegistryRestartRequiredException;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.localization.RuntimeUiMessages;
|
||||
import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.IrisServices;
|
||||
import art.arcane.iris.generation.context.IrisContext;
|
||||
@@ -284,8 +288,17 @@ final class EngineHotloader {
|
||||
elapsedMillis(startedAt, preparedAt), elapsedMillis(preparedAt, drainedAt),
|
||||
elapsedMillis(drainedAt, checkpointedAt), elapsedMillis(checkpointedAt, stagedAt),
|
||||
elapsedMillis(stagedAt, promotedAt), elapsedMillis(promotedAt, completedAt));
|
||||
broadcastStudioHotload(false, "");
|
||||
StudioRestartRequirement requirement = StudioRestartRequirement.deferring(update.deferredBiomes());
|
||||
publishRestartRequirement(requirement);
|
||||
broadcastStudioHotload(false, restartNote(requirement));
|
||||
followUpActivation(history, update, activated);
|
||||
} catch (RegistryRestartRequiredException restart) {
|
||||
StudioRestartRequirement requirement = StudioRestartRequirement.blockedBy(restart);
|
||||
publishRestartRequirement(requirement);
|
||||
IrisLogging.warn("Studio update for '%s' needs a restart: %s",
|
||||
engine.getWorld().name(), restart.getMessage());
|
||||
broadcastStudioHotload(true, restartNote(requirement));
|
||||
throw EngineShutdownSequence.propagate(restart);
|
||||
} catch (Throwable failure) {
|
||||
if (previous != null) {
|
||||
synchronized (engine.lifecycleLock) {
|
||||
@@ -347,6 +360,21 @@ final class EngineHotloader {
|
||||
}
|
||||
}
|
||||
|
||||
private void publishRestartRequirement(StudioRestartRequirement requirement) {
|
||||
engine.studioRestartRequirement = requirement;
|
||||
if (requirement.isPending()) {
|
||||
engine.getPlatformHooks().announceStudioRestartRequirement(engine, requirement);
|
||||
}
|
||||
}
|
||||
|
||||
private static String restartNote(StudioRestartRequirement requirement) {
|
||||
if (!requirement.isPending()) {
|
||||
return "";
|
||||
}
|
||||
return IrisLanguage.plain(RuntimeUiMessages.STUDIO_RESTART_NEEDED,
|
||||
MessageArgument.untrusted("biomes", requirement.biomeSummary()));
|
||||
}
|
||||
|
||||
private static long elapsedMillis(long startedAt, long completedAt) {
|
||||
return TimeUnit.NANOSECONDS.toMillis(completedAt - startedAt);
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ final class EngineMetricsReport {
|
||||
totalWeight += j;
|
||||
}
|
||||
|
||||
for (String j : timings.k()) {
|
||||
weights.put(engine.getName() + "." + j, (wallClock / totalWeight) * timings.get(j));
|
||||
for (String metric : timings.k()) {
|
||||
weights.put(metric, (wallClock / totalWeight) * timings.get(metric));
|
||||
}
|
||||
|
||||
totals.put(engine.getName(), wallClock);
|
||||
@@ -84,15 +84,19 @@ final class EngineMetricsReport {
|
||||
|
||||
output.accept(IrisLanguage.text(BukkitRuntimeMessages.IRIS_ENGINE_DETAILS));
|
||||
|
||||
for (String i : weights.sortKNumber().reverse()) {
|
||||
String befb = C.UNDERLINE + "" + C.GREEN + "" + i.split("\\Q[\\E")[0] + C.RESET + C.GRAY + "[";
|
||||
String num = C.GOLD + i.split("\\Q[\\E")[1].split("]")[0] + C.RESET + C.GRAY + "].";
|
||||
String afb = C.ITALIC + "" + C.AQUA + i.split("\\Q]\\E")[1].substring(1) + C.RESET + C.GRAY;
|
||||
|
||||
output.accept(IrisLanguage.text(BukkitRuntimeMessages.IRIS_ENGINE_MESSAGE, MessageArgument.untrusted("befb", String.valueOf(befb)), MessageArgument.untrusted("num", String.valueOf(num)), MessageArgument.untrusted("afb", String.valueOf(afb)), MessageArgument.untrusted("value", String.valueOf(Form.pc(weights.get(i), 0)))));
|
||||
for (String metric : weights.sortKNumber().reverse()) {
|
||||
output.accept(timingLine(metric, weights.get(metric)));
|
||||
}
|
||||
}
|
||||
|
||||
private static String timingLine(String metric, double share) {
|
||||
return IrisLanguage.text(BukkitRuntimeMessages.IRIS_ENGINE_MESSAGE,
|
||||
MessageArgument.untrusted("befb", C.AQUA + metric + C.GRAY),
|
||||
MessageArgument.untrusted("num", ""),
|
||||
MessageArgument.untrusted("afb", ""),
|
||||
MessageArgument.untrusted("value", Form.pc(share, 0)));
|
||||
}
|
||||
|
||||
double getGeneratedPerSecond() {
|
||||
if (engine.getPerSecondLatch().flip()) {
|
||||
double g = engine.getGenerated() - engine.getGeneratedLast().get();
|
||||
|
||||
@@ -64,6 +64,9 @@ public interface EnginePlatformHooks {
|
||||
default void fireHotloadEvent(Engine engine) {
|
||||
}
|
||||
|
||||
default void announceStudioRestartRequirement(Engine engine, StudioRestartRequirement requirement) {
|
||||
}
|
||||
|
||||
default void validateDimensionHotload(Engine engine, IrisDimension replacement) {
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,8 @@ public class IrisEngine implements Engine {
|
||||
private final boolean studio;
|
||||
@Setter(AccessLevel.NONE)
|
||||
private volatile Path studioGenerationSource;
|
||||
@Setter(AccessLevel.NONE)
|
||||
volatile StudioRestartRequirement studioRestartRequirement = StudioRestartRequirement.none();
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
boolean studioGenerationTransition;
|
||||
|
||||
@@ -9,6 +9,7 @@ import art.arcane.iris.world.history.GenerationPackRepository;
|
||||
import art.arcane.iris.world.history.GenerationRegistryContract;
|
||||
import art.arcane.iris.world.history.GenerationRegistryContractFactory;
|
||||
import art.arcane.iris.world.history.PackTreeState;
|
||||
import art.arcane.iris.world.history.StudioRegistryCapture;
|
||||
import art.arcane.iris.world.history.VerifiedPackTree;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
|
||||
@@ -26,7 +27,8 @@ record StudioGenerationUpdate(
|
||||
VerifiedPackTree pack,
|
||||
PackTreeState sourceState,
|
||||
GenerationEpoch.DimensionContract dimensionContract,
|
||||
GenerationRegistryContract registryContract
|
||||
GenerationRegistryContract registryContract,
|
||||
List<String> deferredBiomes
|
||||
) implements AutoCloseable {
|
||||
private static final String TRIAL_MANTLE_DIRECTORY = ".trial-mantle";
|
||||
|
||||
@@ -102,10 +104,15 @@ record StudioGenerationUpdate(
|
||||
if (!active.dimensionContract().hasSameLayout(contract)) {
|
||||
throw new IOException("Studio pack update changes the world's immutable dimension layout.");
|
||||
}
|
||||
GenerationRegistryContract registry = GenerationRegistryContractFactory.create(data, replacement, pack.fingerprint());
|
||||
registry.requireDefinitionsAvailableIn(GenerationRegistryContractFactory.captureRequiredDefinitions(List.of(registry)));
|
||||
requireBuildableRuntime(engine, data, replacement, registry, stagingRoot.resolve(TRIAL_MANTLE_DIRECTORY));
|
||||
return new StudioGenerationUpdate(stagingRoot, pack, sourceState, contract, registry);
|
||||
StudioRegistryCapture registry = GenerationRegistryContractFactory.createRetainingLoadedBiomes(
|
||||
data, replacement, pack.fingerprint(), active.registryContract());
|
||||
GenerationRegistryContract registryContract = registry.contract();
|
||||
registryContract.requireDefinitionsAvailableIn(
|
||||
GenerationRegistryContractFactory.captureRequiredDefinitions(List.of(registryContract)));
|
||||
requireBuildableRuntime(engine, data, replacement, registryContract,
|
||||
stagingRoot.resolve(TRIAL_MANTLE_DIRECTORY));
|
||||
return new StudioGenerationUpdate(stagingRoot, pack, sourceState, contract, registryContract,
|
||||
registry.deferredBiomes());
|
||||
} finally {
|
||||
if (!data.isClosed()) {
|
||||
data.close();
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package art.arcane.iris.generation.runtime;
|
||||
|
||||
import art.arcane.iris.world.history.RegistryRestartRequiredException;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* What a Studio world still needs a server restart for. Deferred biomes hotloaded with the definition the server
|
||||
* loaded; blocking biomes have no loaded definition, so their update waits for the restart.
|
||||
*/
|
||||
public record StudioRestartRequirement(List<String> deferredBiomes, List<String> blockingBiomes) {
|
||||
private static final StudioRestartRequirement NONE = new StudioRestartRequirement(List.of(), List.of());
|
||||
private static final int LISTED_BIOME_LIMIT = 3;
|
||||
|
||||
public StudioRestartRequirement {
|
||||
deferredBiomes = List.copyOf(deferredBiomes);
|
||||
blockingBiomes = List.copyOf(blockingBiomes);
|
||||
}
|
||||
|
||||
public static StudioRestartRequirement none() {
|
||||
return NONE;
|
||||
}
|
||||
|
||||
public static StudioRestartRequirement deferring(List<String> deferredBiomes) {
|
||||
return deferredBiomes.isEmpty() ? NONE : new StudioRestartRequirement(deferredBiomes, List.of());
|
||||
}
|
||||
|
||||
public static StudioRestartRequirement blockedBy(RegistryRestartRequiredException restart) {
|
||||
return new StudioRestartRequirement(restart.deferredBiomes(), restart.blockingBiomes());
|
||||
}
|
||||
|
||||
public boolean isPending() {
|
||||
return !deferredBiomes.isEmpty() || !blockingBiomes.isEmpty();
|
||||
}
|
||||
|
||||
public boolean blocksHotload() {
|
||||
return !blockingBiomes.isEmpty();
|
||||
}
|
||||
|
||||
public String biomeSummary() {
|
||||
LinkedHashSet<String> biomes = new LinkedHashSet<>(blockingBiomes);
|
||||
biomes.addAll(deferredBiomes);
|
||||
List<String> listed = biomes.stream().limit(LISTED_BIOME_LIMIT).toList();
|
||||
int hidden = biomes.size() - listed.size();
|
||||
String summary = String.join(", ", listed);
|
||||
return hidden > 0 ? summary + " +" + hidden : summary;
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,11 @@ import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class SimdSupport {
|
||||
private static final String VECTOR_MODULE = "jdk.incubator.vector";
|
||||
private static final Pattern VECTOR_SHAPE_BITS = Pattern.compile("^.*S_(\\d+)_BIT.*$");
|
||||
private static final boolean MODULE_PRESENT = ModuleLayer.boot().findModule(VECTOR_MODULE).isPresent();
|
||||
private static final AtomicReference<Throwable> KERNEL_FAILURE = new AtomicReference<>();
|
||||
private static final SimdKernels KERNELS = selectKernels();
|
||||
@@ -54,8 +56,19 @@ public final class SimdSupport {
|
||||
return "scalar kernels active; the Vector API reported no usable vector shape on this CPU";
|
||||
}
|
||||
|
||||
public static String shortStatus() {
|
||||
if (!isVectorized()) {
|
||||
return "scalar";
|
||||
}
|
||||
return VECTOR_SHAPE_BITS.matcher(KERNELS.describe()).replaceFirst("$1-bit");
|
||||
}
|
||||
|
||||
public static void install() {
|
||||
IrisLogging.info("SIMD: " + kernelStatus());
|
||||
if (isVectorized()) {
|
||||
IrisLogging.debug("SIMD: " + kernelStatus());
|
||||
} else {
|
||||
IrisLogging.info("SIMD: " + kernelStatus());
|
||||
}
|
||||
|
||||
Throwable failure = KERNEL_FAILURE.get();
|
||||
if (failure != null) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@@ -128,6 +129,25 @@ public abstract class ExternalDataProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data The block to keep, possibly an {@link IrisCustomData} this provider returned from {@link #getBlockData}
|
||||
* @return The block made to never decay, like custom leaves, or {@code data} itself when it is not one of the
|
||||
* provider's decaying blocks
|
||||
*/
|
||||
@NotNull
|
||||
public BlockData withoutDecay(@NotNull BlockData data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data The block to check, possibly an {@link IrisCustomData} this provider returned from {@link #getBlockData}
|
||||
* @param tag A block tag, like {@code minecraft:logs}
|
||||
* @return Whether the block is one of the provider's blocks and carries that tag
|
||||
*/
|
||||
public boolean hasBlockTag(@NotNull BlockData data, @NotNull NamespacedKey tag) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawns a mob in the specified location using the given engine and entity identifier.
|
||||
*
|
||||
|
||||
@@ -30,6 +30,7 @@ import art.arcane.volmlib.util.collection.KMap;
|
||||
import art.arcane.iris.platform.bukkit.plugin.IrisService;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -193,6 +194,26 @@ public class ExternalDataSVC implements IrisService {
|
||||
return blockData;
|
||||
}
|
||||
|
||||
/** The block made to never decay by the provider it belongs to, or {@code data} itself. */
|
||||
public BlockData withoutDecay(BlockData data) {
|
||||
for (ExternalDataProvider provider : activeProviders) {
|
||||
BlockData kept = provider.withoutDecay(data);
|
||||
if (kept == data) {
|
||||
continue;
|
||||
}
|
||||
if (kept instanceof IrisCustomData custom && data instanceof IrisCustomData) {
|
||||
return IrisCustomData.of(custom.getBase(), qualifyBlockId(provider, custom.getCustom()));
|
||||
}
|
||||
return kept;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/** Whether {@code data} is a provider's block carrying {@code tag}. */
|
||||
public boolean hasBlockTag(BlockData data, NamespacedKey tag) {
|
||||
return activeProviders.stream().anyMatch(provider -> provider.hasBlockTag(data, tag));
|
||||
}
|
||||
|
||||
public Optional<BlockData> getBlockData(final Identifier key) {
|
||||
Pair<Identifier, KMap<String, String>> pair;
|
||||
try {
|
||||
|
||||
@@ -30,6 +30,7 @@ import net.momirealms.craftengine.core.util.Key;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -57,6 +58,7 @@ public class CraftEngineDataProvider extends ExternalDataProvider implements Lis
|
||||
BlockProperty.ofBoolean("randomPitch", false),
|
||||
BlockProperty.ofDouble("pitch", 0, 0, 360f, false, true)
|
||||
);
|
||||
private static final String PERSISTENT_PROPERTY = "persistent";
|
||||
private static final ContentRegistry EMPTY_CONTENT = new ContentRegistry(Set.of(), Set.of(), false);
|
||||
|
||||
private volatile ContentRegistry content = EMPTY_CONTENT;
|
||||
@@ -131,6 +133,32 @@ public class CraftEngineDataProvider extends ExternalDataProvider implements Lis
|
||||
return state == null || state.isEmpty() ? Optional.empty() : Optional.of(Identifier.fromString(state.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull BlockData withoutDecay(@NotNull BlockData data) {
|
||||
ImmutableBlockState state = customStateOf(data);
|
||||
if (state == null) {
|
||||
return data;
|
||||
}
|
||||
Property<Boolean> persistent = state.getProperty(PERSISTENT_PROPERTY);
|
||||
if (persistent == null || persistent.valueClass() != Boolean.class || state.get(persistent)) {
|
||||
return data;
|
||||
}
|
||||
ImmutableBlockState kept = state.with(persistent, true);
|
||||
return IrisCustomData.of(CraftEngineBlocks.getBukkitBlockData(kept), Identifier.fromString(kept.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBlockTag(@NotNull BlockData data, @NotNull NamespacedKey tag) {
|
||||
ImmutableBlockState state = customStateOf(data);
|
||||
return state != null && state.settings().tags().contains(Key.of(tag.getNamespace(), tag.getKey()));
|
||||
}
|
||||
|
||||
private static ImmutableBlockState customStateOf(BlockData data) {
|
||||
BlockData nativeData = data instanceof IrisCustomData custom ? custom.getBase() : data;
|
||||
ImmutableBlockState state = CraftEngineBlocks.getCustomBlockState(nativeData);
|
||||
return state == null || state.isEmpty() ? null : state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlock(@NotNull Block block, @NotNull Identifier blockId) {
|
||||
Pair<Identifier, KMap<String, String>> parsed = ExternalDataSVC.parseState(blockId);
|
||||
|
||||
@@ -135,7 +135,7 @@ public final class BukkitRuntimeMessages {
|
||||
);
|
||||
public static final TextKey COMMAND_PACK_PACK_IS_BROKEN = TextKey.of(
|
||||
"iris.bukkit.runtime.commandpack.pack_is_broken",
|
||||
C.RED + "Pack '" + "{packName}" + "' is BROKEN:"
|
||||
C.RED + "Pack '" + "{packName}" + "' is broken"
|
||||
);
|
||||
public static final TextKey COMMAND_PACK_MESSAGE = TextKey.of(
|
||||
"iris.bukkit.runtime.commandpack.message",
|
||||
@@ -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",
|
||||
|
||||
@@ -344,7 +344,7 @@ public enum C {
|
||||
}
|
||||
|
||||
C(char code, int intCode, boolean isFormat) {
|
||||
this("^", code, intCode, false);
|
||||
this("^", code, intCode, isFormat);
|
||||
}
|
||||
|
||||
C(String token, char code, int intCode, boolean isFormat) {
|
||||
@@ -384,25 +384,11 @@ public enum C {
|
||||
}
|
||||
|
||||
public static String mini(String s) {
|
||||
String msg = compress(s);
|
||||
StringBuilder b = new StringBuilder();
|
||||
boolean c = false;
|
||||
return toMarkup(s, color -> color.token);
|
||||
}
|
||||
|
||||
for (char i : msg.toCharArray()) {
|
||||
if (!c) {
|
||||
if (i == C.COLOR_CHAR) {
|
||||
c = true;
|
||||
continue;
|
||||
}
|
||||
b.append(i);
|
||||
} else {
|
||||
c = false;
|
||||
C o = C.getByChar(i);
|
||||
b.append(o.token);
|
||||
}
|
||||
}
|
||||
|
||||
return b.toString();
|
||||
public static String escapeTags(String s) {
|
||||
return MiniMessage.miniMessage().escapeTags(s);
|
||||
}
|
||||
|
||||
public static String aura(String s, int hrad, int srad, int vrad) {
|
||||
@@ -410,39 +396,48 @@ public enum C {
|
||||
}
|
||||
|
||||
public static String aura(String s, int hrad, int srad, int vrad, double pulse) {
|
||||
if (hrad == 0 && srad == 0 && vrad == 0) {
|
||||
return mini(s);
|
||||
}
|
||||
return toMarkup(s, color -> pulse > 0
|
||||
? VolmitSender.pulse(spinToHex(color, hrad, srad, vrad), spinToHex(color, -hrad, -srad, -vrad), pulse)
|
||||
: "<gradient:" + spinToHex(color, hrad, srad, vrad) + ":" + spinToHex(color, -hrad, -srad, -vrad) + ">");
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts legacy section codes to MiniMessage. Format codes become their tags, and a color code after a format
|
||||
* emits a reset first, because in legacy text a color ends bold/italic while MiniMessage tags stay open.
|
||||
*/
|
||||
private static String toMarkup(String s, java.util.function.Function<C, String> colorTag) {
|
||||
String msg = compress(s);
|
||||
StringBuilder b = new StringBuilder();
|
||||
boolean c = false;
|
||||
boolean codeFollows = false;
|
||||
boolean formatOpen = false;
|
||||
|
||||
for (char i : msg.toCharArray()) {
|
||||
if (c) {
|
||||
c = false;
|
||||
|
||||
C o = C.getByChar(i);
|
||||
|
||||
if (hrad != 0 || srad != 0 || vrad != 0) {
|
||||
if (pulse > 0) {
|
||||
b.append(VolmitSender.pulse(spinToHex(o, hrad, srad, vrad), spinToHex(o, -hrad, -srad, -vrad), pulse));
|
||||
} else {
|
||||
b.append("<gradient:")
|
||||
.append(spinToHex(o, hrad, srad, vrad))
|
||||
.append(":")
|
||||
.append(spinToHex(o, -hrad, -srad, -vrad))
|
||||
.append(">");
|
||||
}
|
||||
if (!codeFollows) {
|
||||
if (i == C.COLOR_CHAR) {
|
||||
codeFollows = true;
|
||||
} else {
|
||||
b.append(C.getByChar(i).token);
|
||||
b.append(i);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i == C.COLOR_CHAR) {
|
||||
c = true;
|
||||
continue;
|
||||
codeFollows = false;
|
||||
C code = C.getByChar(i);
|
||||
if (code == RESET) {
|
||||
b.append(code.token);
|
||||
formatOpen = false;
|
||||
} else if (code.isFormat()) {
|
||||
b.append(code.token);
|
||||
formatOpen = true;
|
||||
} else {
|
||||
if (formatOpen) {
|
||||
b.append(RESET.token);
|
||||
formatOpen = false;
|
||||
}
|
||||
b.append(colorTag.apply(code));
|
||||
}
|
||||
|
||||
b.append(i);
|
||||
}
|
||||
|
||||
return b.toString();
|
||||
|
||||
@@ -0,0 +1,379 @@
|
||||
package art.arcane.iris.localization;
|
||||
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
|
||||
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 String CONSOLE_CONTINUATION_INDENT = " ";
|
||||
private static final String CONSOLE_COMMAND_INDENT = " ";
|
||||
private static final int CONSOLE_LABEL_WIDTH = 16;
|
||||
private static final Pattern LEGACY_COLOR = Pattern.compile("(?i)[§&][0-9A-FK-ORX]");
|
||||
|
||||
/**
|
||||
* Chat wears the Iris color for success; the console keeps it for the Iris tag and splash, so it stays special there.
|
||||
* Console success is DARK_GREEN because GREEN shares legacy code 'a' with IRIS and renders as Iris teal.
|
||||
*/
|
||||
public enum Tone {
|
||||
SUCCESS(C.IRIS, C.DARK_GREEN, ConsoleGlyphs.CHECK),
|
||||
INFO(C.AQUA, C.AQUA, ""),
|
||||
WARNING(C.GOLD, C.GOLD, ConsoleGlyphs.WARNING),
|
||||
ERROR(C.RED, C.RED, ConsoleGlyphs.CROSS);
|
||||
|
||||
private final C color;
|
||||
private final C consoleColor;
|
||||
private final String mark;
|
||||
|
||||
Tone(C color, C consoleColor, String mark) {
|
||||
this.color = color;
|
||||
this.consoleColor = consoleColor;
|
||||
this.mark = mark;
|
||||
}
|
||||
|
||||
/** Puts already styled console text on the gutter behind this tone's status glyph, or a blank one for info. */
|
||||
public String marked(String styledText) {
|
||||
if (!hasMark()) {
|
||||
return ConsoleLayout.row(styledText);
|
||||
}
|
||||
return consoleColor + mark + " " + styledText;
|
||||
}
|
||||
|
||||
public C consoleColor() {
|
||||
return consoleColor;
|
||||
}
|
||||
|
||||
public String consolePaint(String text) {
|
||||
return consoleColor + clean(text);
|
||||
}
|
||||
|
||||
public boolean hasMark() {
|
||||
return !mark.isEmpty();
|
||||
}
|
||||
|
||||
public String mark() {
|
||||
return mark;
|
||||
}
|
||||
|
||||
public C color() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public String paint(String text) {
|
||||
return color + clean(text);
|
||||
}
|
||||
}
|
||||
|
||||
/** A blank chat line. A single space, because some clients drop fully empty messages. */
|
||||
public static final Line SPACER = new Line(" ", null);
|
||||
|
||||
public record Line(String text, String command) {
|
||||
public boolean clickable() {
|
||||
return command != null && !command.isBlank();
|
||||
}
|
||||
}
|
||||
|
||||
/** A suggested command and what running it gets the reader. */
|
||||
private record NextStep(String instruction, String command) {
|
||||
}
|
||||
|
||||
/** One report entry. Chat shows its styled lines; the console draws them as a branch, a labelled entry as an aligned label row. */
|
||||
private record Entry(List<String> styledLines, String label, String value) {
|
||||
static Entry styled(List<String> styledLines) {
|
||||
return new Entry(List.copyOf(styledLines), null, null);
|
||||
}
|
||||
|
||||
static Entry labelled(String label, String value) {
|
||||
return new Entry(List.of(ChatReport.label(label, value)), clean(label), clean(value));
|
||||
}
|
||||
|
||||
/** The branch's lines from column 2 on: the first sits on the branch, the rest on the trunk. */
|
||||
List<String> consoleBranch() {
|
||||
if (label != null) {
|
||||
return labelRow();
|
||||
}
|
||||
List<String> lines = new ArrayList<>(styledLines.size());
|
||||
lines.add(styledLines.getFirst());
|
||||
for (int index = 1; index < styledLines.size(); index++) {
|
||||
lines.add(CONSOLE_CONTINUATION_INDENT + styledLines.get(index).stripLeading());
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
/** The value starts at column 18; a label too long for its column puts the value on the next line. */
|
||||
private List<String> labelRow() {
|
||||
if (label.length() < CONSOLE_LABEL_WIDTH) {
|
||||
String padding = " ".repeat(CONSOLE_LABEL_WIDTH - label.length());
|
||||
return List.of(C.GRAY + label + padding + C.WHITE + value);
|
||||
}
|
||||
return List.of(C.GRAY + label, " ".repeat(CONSOLE_LABEL_WIDTH) + C.WHITE + value);
|
||||
}
|
||||
}
|
||||
|
||||
private final Tone tone;
|
||||
private final String title;
|
||||
private final List<Entry> entries;
|
||||
private final int itemLimit;
|
||||
private final String hint;
|
||||
private final String hintShownCommand;
|
||||
private final String hintClickCommand;
|
||||
private final List<NextStep> nextSteps;
|
||||
|
||||
private ChatReport(Builder builder) {
|
||||
this.tone = builder.tone;
|
||||
this.title = builder.title;
|
||||
this.entries = List.copyOf(builder.entries);
|
||||
this.itemLimit = builder.itemLimit;
|
||||
this.hint = builder.hint;
|
||||
this.hintShownCommand = builder.hintShownCommand;
|
||||
this.hintClickCommand = builder.hintClickCommand;
|
||||
this.nextSteps = List.copyOf(builder.nextSteps);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/** The compact layout: title first, no spacing. Used for logs and other plain output. */
|
||||
public List<Line> lines() {
|
||||
List<Line> lines = new ArrayList<>();
|
||||
lines.add(titleLine());
|
||||
lines.addAll(bodyLines(false));
|
||||
return lines;
|
||||
}
|
||||
|
||||
public Line titleLine() {
|
||||
return new Line(ReportText.title(tone, clean(title)), null);
|
||||
}
|
||||
|
||||
/** Every line after the title; {@code spaced} adds a blank line between the list and the hint, for chat. */
|
||||
public List<Line> bodyLines(boolean spaced) {
|
||||
List<Line> lines = new ArrayList<>();
|
||||
for (Entry entry : shownEntries()) {
|
||||
addChatEntryLines(lines, entry);
|
||||
}
|
||||
int hidden = hiddenEntryCount();
|
||||
if (hidden > 0) {
|
||||
lines.add(new Line(C.DARK_GRAY + CONTINUATION_INDENT + ReportText.moreLabel(hidden), null));
|
||||
}
|
||||
if (hint == null && nextSteps.isEmpty()) {
|
||||
return lines;
|
||||
}
|
||||
if (spaced && !lines.isEmpty()) {
|
||||
lines.add(SPACER);
|
||||
}
|
||||
if (hint != null) {
|
||||
lines.add(new Line(C.GRAY + chatHint(), hintClickCommand));
|
||||
}
|
||||
for (NextStep step : nextSteps) {
|
||||
lines.add(new Line(C.GRAY + step.instruction() + ": " + highlight(step.command()), step.command()));
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
private String chatHint() {
|
||||
return hintShownCommand == null ? hint : hint.replace(hintShownCommand, highlight(hintShownCommand));
|
||||
}
|
||||
|
||||
private void addChatEntryLines(List<Line> lines, Entry entry) {
|
||||
List<String> styled = entry.styledLines();
|
||||
lines.add(new Line(tone.color() + ITEM_BULLET + C.GRAY + styled.getFirst(), null));
|
||||
for (int index = 1; index < styled.size(); index++) {
|
||||
lines.add(new Line(styled.get(index), null));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The console layout: the title behind the tone's status glyph, then the body, hint and next steps as a tree whose
|
||||
* rails sit in the gutter, so branch text lines up with the title.
|
||||
*/
|
||||
public List<String> consoleLines() {
|
||||
List<String> lines = new ArrayList<>();
|
||||
lines.add(tone.marked(ReportText.title(tone.consoleColor(), clean(title))));
|
||||
List<List<String>> branches = consoleBranches();
|
||||
for (int index = 0; index < branches.size(); index++) {
|
||||
addBranchLines(lines, branches.get(index), index == branches.size() - 1);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
private List<List<String>> consoleBranches() {
|
||||
List<List<String>> branches = new ArrayList<>();
|
||||
for (Entry entry : shownEntries()) {
|
||||
branches.add(entry.consoleBranch());
|
||||
}
|
||||
int hidden = hiddenEntryCount();
|
||||
if (hidden > 0) {
|
||||
branches.add(List.of(C.DARK_GRAY + ReportText.moreLabel(hidden)));
|
||||
}
|
||||
if (hint != null) {
|
||||
branches.add(consoleHintBranch());
|
||||
}
|
||||
for (NextStep step : nextSteps) {
|
||||
branches.add(nextStepBranch(step.instruction(), step.command()));
|
||||
}
|
||||
return branches;
|
||||
}
|
||||
|
||||
private void addBranchLines(List<String> lines, List<String> branch, boolean last) {
|
||||
String connector = last ? ConsoleGlyphs.LAST_BRANCH : ConsoleGlyphs.BRANCH;
|
||||
String trunk = last ? " " : ConsoleGlyphs.BAR;
|
||||
lines.add(tone.consoleColor() + connector + " " + C.GRAY + branch.getFirst());
|
||||
for (int index = 1; index < branch.size(); index++) {
|
||||
lines.add(tone.consoleColor() + trunk + " " + C.GRAY + branch.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A hint that ends in its command reads as a next step; any other hint stays one sentence. The console can't
|
||||
* click, so the step shows the full command a click would run.
|
||||
*/
|
||||
private List<String> consoleHintBranch() {
|
||||
if (hintShownCommand != null && hint.endsWith(hintShownCommand)) {
|
||||
String instruction = hint.substring(0, hint.length() - hintShownCommand.length());
|
||||
String runnable = hintClickCommand == null ? hintShownCommand : clean(hintClickCommand);
|
||||
return nextStepBranch(instruction, runnable);
|
||||
}
|
||||
return List.of(chatHint());
|
||||
}
|
||||
|
||||
/** An instruction ending in a colon, then the exact command on its own line so it copies as is. */
|
||||
private static List<String> nextStepBranch(String instruction, String command) {
|
||||
String trimmed = instruction.strip();
|
||||
String commandLine = CONSOLE_COMMAND_INDENT + C.AQUA + command;
|
||||
if (trimmed.isEmpty()) {
|
||||
return List.of(commandLine);
|
||||
}
|
||||
return List.of(trimmed.endsWith(":") ? trimmed : trimmed + ":", commandLine);
|
||||
}
|
||||
|
||||
private List<Entry> shownEntries() {
|
||||
return entries.subList(0, Math.min(itemLimit, entries.size()));
|
||||
}
|
||||
|
||||
private int hiddenEntryCount() {
|
||||
return entries.size() - shownEntries().size();
|
||||
}
|
||||
|
||||
public void log() {
|
||||
for (String line : consoleLines()) {
|
||||
logLine(line);
|
||||
}
|
||||
}
|
||||
|
||||
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<Entry> entries = new ArrayList<>();
|
||||
private final List<NextStep> nextSteps = new ArrayList<>();
|
||||
private int itemLimit = DEFAULT_ITEM_LIMIT;
|
||||
private String hint;
|
||||
private String hintShownCommand;
|
||||
private String hintClickCommand;
|
||||
|
||||
private Builder(Tone tone, String title) {
|
||||
this.tone = tone;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Builder item(String text) {
|
||||
String cleaned = clean(text);
|
||||
if (!cleaned.isEmpty()) {
|
||||
entries.add(Entry.styled(List.of(ReportText.body(cleaned))));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder styledItem(String styledText) {
|
||||
if (styledText != null && !styledText.isBlank()) {
|
||||
entries.add(Entry.styled(List.of(styledText)));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Adds reasons, collapsing ones that differ only in their quoted subject into a single entry. */
|
||||
public Builder items(Collection<String> texts) {
|
||||
List<String> cleaned = new ArrayList<>(texts.size());
|
||||
for (String text : texts) {
|
||||
String reason = clean(text);
|
||||
if (!reason.isEmpty()) {
|
||||
cleaned.add(reason);
|
||||
}
|
||||
}
|
||||
ReportText.groupedBodies(cleaned, CONTINUATION_INDENT).forEach(lines -> entries.add(Entry.styled(lines)));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder entry(String label, Object value) {
|
||||
entries.add(Entry.labelled(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) {
|
||||
return hint(text, command, command);
|
||||
}
|
||||
|
||||
/** Shows {@code shownCommand} in the hint text while a click runs {@code clickCommand}. */
|
||||
public Builder hint(String text, String shownCommand, String clickCommand) {
|
||||
this.hint = clean(text);
|
||||
this.hintShownCommand = shownCommand == null ? null : clean(shownCommand);
|
||||
this.hintClickCommand = clickCommand;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Suggests a command after the body; chat shows it as one clickable line, the console on its own line. */
|
||||
public Builder nextStep(String instruction, String command) {
|
||||
nextSteps.add(new NextStep(clean(instruction), clean(command)));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChatReport build() {
|
||||
return new ChatReport(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package art.arcane.iris.localization;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.IllegalCharsetNameException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/** Swaps the non-ASCII glyphs Iris prints for ASCII ones when the console charset cannot encode them. */
|
||||
public final class ConsoleGlyphs {
|
||||
public static final String BAR = "\u2502";
|
||||
public static final String BRANCH = "\u251c";
|
||||
public static final String LAST_BRANCH = "\u2514";
|
||||
public static final String CHECK = "\u2714";
|
||||
public static final String WARNING = "\u25b2";
|
||||
public static final String CROSS = "\u2716";
|
||||
public static final String ELLIPSIS = "\u2026";
|
||||
|
||||
private static final Map<String, String> ASCII_FALLBACKS = asciiFallbacks();
|
||||
private static final String[] CONSOLE_CHARSET_PROPERTIES = {"stdout.encoding", "native.encoding"};
|
||||
private static final ConsoleGlyphs CONSOLE = forCharset(consoleCharset());
|
||||
|
||||
private final Map<String, String> replacements;
|
||||
|
||||
private ConsoleGlyphs(Map<String, String> replacements) {
|
||||
this.replacements = replacements;
|
||||
}
|
||||
|
||||
public static ConsoleGlyphs console() {
|
||||
return CONSOLE;
|
||||
}
|
||||
|
||||
public static ConsoleGlyphs forCharset(Charset charset) {
|
||||
Map<String, String> unencodable = new LinkedHashMap<>();
|
||||
for (Map.Entry<String, String> fallback : ASCII_FALLBACKS.entrySet()) {
|
||||
if (!charset.newEncoder().canEncode(fallback.getKey())) {
|
||||
unencodable.put(fallback.getKey(), fallback.getValue());
|
||||
}
|
||||
}
|
||||
return new ConsoleGlyphs(unencodable);
|
||||
}
|
||||
|
||||
public String fit(String text) {
|
||||
if (text == null || replacements.isEmpty()) {
|
||||
return text;
|
||||
}
|
||||
String fitted = text;
|
||||
for (Map.Entry<String, String> replacement : replacements.entrySet()) {
|
||||
fitted = fitted.replace(replacement.getKey(), replacement.getValue());
|
||||
}
|
||||
return fitted;
|
||||
}
|
||||
|
||||
private static Map<String, String> asciiFallbacks() {
|
||||
Map<String, String> fallbacks = new LinkedHashMap<>();
|
||||
fallbacks.put("\u00bb", ">");
|
||||
fallbacks.put(BAR, "|");
|
||||
fallbacks.put(BRANCH, "|");
|
||||
fallbacks.put(LAST_BRANCH, "`");
|
||||
fallbacks.put(CHECK, "+");
|
||||
fallbacks.put(WARNING, "!");
|
||||
fallbacks.put(CROSS, "x");
|
||||
fallbacks.put(ELLIPSIS, "...");
|
||||
fallbacks.put("\u2039", "[");
|
||||
fallbacks.put("\u203a", "]");
|
||||
return fallbacks;
|
||||
}
|
||||
|
||||
private static Charset consoleCharset() {
|
||||
for (String property : CONSOLE_CHARSET_PROPERTIES) {
|
||||
String name = System.getProperty(property);
|
||||
if (name == null || name.isBlank()) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
if (Charset.isSupported(name)) {
|
||||
return Charset.forName(name);
|
||||
}
|
||||
} catch (IllegalCharsetNameException ignored) {
|
||||
// An unusable property value falls through to the next source.
|
||||
}
|
||||
}
|
||||
return Charset.defaultCharset();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package art.arcane.iris.localization;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* The console's two-column gutter. Column 0 holds a status glyph, a tree rail or a space, and content starts at
|
||||
* column 2, so a report's rails, its title text and plain log lines all line up.
|
||||
*/
|
||||
public final class ConsoleLayout {
|
||||
public static final int GUTTER_WIDTH = 2;
|
||||
|
||||
private static final String BLANK_GUTTER = " ".repeat(GUTTER_WIDTH);
|
||||
private static final List<String> RAILS = List.of(ConsoleGlyphs.BRANCH, ConsoleGlyphs.LAST_BRANCH, ConsoleGlyphs.BAR);
|
||||
private static final Pattern STYLING = Pattern.compile("(?i)§[0-9A-FK-ORX]|<[/#!?]?[a-z0-9_:#-]+(?::[^>]*)?>");
|
||||
|
||||
private ConsoleLayout() {
|
||||
}
|
||||
|
||||
public static String row(String text) {
|
||||
return BLANK_GUTTER + text;
|
||||
}
|
||||
|
||||
/** Puts a log line on the gutter, marked for its tone, unless it already starts with a gutter of its own. */
|
||||
public static String onGutter(ChatReport.Tone tone, String styledLine) {
|
||||
if (styledLine == null || hasGutter(styledLine)) {
|
||||
return styledLine;
|
||||
}
|
||||
return tone.marked(styledLine);
|
||||
}
|
||||
|
||||
static boolean hasGutter(String styledLine) {
|
||||
String plain = STYLING.matcher(styledLine).replaceAll("");
|
||||
if (plain.isBlank() || plain.startsWith(BLANK_GUTTER)) {
|
||||
return true;
|
||||
}
|
||||
for (String rail : RAILS) {
|
||||
if (plain.startsWith(rail + " ")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (ChatReport.Tone tone : ChatReport.Tone.values()) {
|
||||
if (tone.hasMark() && plain.startsWith(tone.mark() + " ")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -213,6 +213,14 @@ public final class DirectorCommandMessages {
|
||||
"iris.director.commanddeveloper.director.generate_chunks_into_buffers_no_world_writes_hash_blocks_biomes_captures_golden",
|
||||
"Generate chunks into buffers (no world writes) and hash blocks+biomes; captures a golden file or verifies against an existing one. Deletes the world's entire mantle - use on disposable test worlds."
|
||||
);
|
||||
public static final TextKey COMMAND_DEVELOPER_DIRECTOR_STOP_REGEN_RUNNING_WORLD = TextKey.of(
|
||||
"iris.director.commanddeveloper.director.stop_regen_running_world",
|
||||
"Stop the regen running in a world"
|
||||
);
|
||||
public static final TextKey COMMAND_DEVELOPER_PARAM_WORLD_REGEN_STOP = TextKey.of(
|
||||
"iris.director.commanddeveloper.param.world_regen_stop",
|
||||
"The world whose regen to stop"
|
||||
);
|
||||
public static final TextKey COMMAND_DEVELOPER_PARAM_WORLD_SCAN = TextKey.of(
|
||||
"iris.director.commanddeveloper.param.world_scan",
|
||||
"The world to scan"
|
||||
@@ -992,6 +1000,8 @@ public final class DirectorCommandMessages {
|
||||
COMMAND_DEVELOPER_DIRECTOR_TEST_4,
|
||||
COMMAND_DEVELOPER_DIRECTOR_DELETE_REGENERATE_NEARBY_CHUNKS_PLACE_USING_IRIS_GENERATION,
|
||||
COMMAND_DEVELOPER_PARAM_RADIUS_NEARBY_CHUNKS,
|
||||
COMMAND_DEVELOPER_DIRECTOR_STOP_REGEN_RUNNING_WORLD,
|
||||
COMMAND_DEVELOPER_PARAM_WORLD_REGEN_STOP,
|
||||
COMMAND_DEVELOPER_DIRECTOR_GENERATE_CHUNKS_INTO_BUFFERS_NO_WORLD_WRITES_HASH_BLOCKS_BIOMES_CAPTURES_GOLDEN,
|
||||
COMMAND_DEVELOPER_PARAM_WORLD_SCAN,
|
||||
COMMAND_DEVELOPER_PARAM_RADIUS_CHUNKS_AROUND_CENTER_2,
|
||||
|
||||
@@ -615,11 +615,11 @@ public final class IrisLanguage {
|
||||
IrisLogging.info("Updated Iris language " + locale + " from " + source + ": " + result.summary() + ".");
|
||||
}
|
||||
if (report.coolingDown()) {
|
||||
IrisLogging.info("Iris language source " + sourceDescription() + " was checked recently; the next check is allowed in "
|
||||
IrisLogging.debug("Iris language source " + sourceDescription() + " was checked recently; the next check is allowed in "
|
||||
+ report.cooldownRemaining() + ".");
|
||||
} else if (report.failure().isEmpty() && report.changedLocales().isEmpty() && report.failures().isEmpty()
|
||||
&& report.revision().isPresent()) {
|
||||
IrisLogging.info("Iris languages match " + sourceDescription() + " (" + revision + ").");
|
||||
IrisLogging.debug("Iris languages match " + sourceDescription() + " (" + revision + ").");
|
||||
}
|
||||
return report;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package art.arcane.iris.localization;
|
||||
|
||||
import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Styles plain report text so long reasons scan quickly: names and keys get their own color, the explanation after
|
||||
* the first sentence is dimmed, and reasons that differ only in their subject collapse into one entry.
|
||||
*/
|
||||
final class ReportText {
|
||||
private static final int GROUP_SUBJECTS_SHOWN = 4;
|
||||
private static final Pattern SENTENCE_BREAK = Pattern.compile("(?<=[.!?])\\s+(?=[A-Z\\[])");
|
||||
private static final String QUOTED_NAME = "(?<![A-Za-z])'[^']+'(?![A-Za-z])";
|
||||
private static final Pattern QUOTED = Pattern.compile(QUOTED_NAME);
|
||||
private static final Pattern TOKEN = Pattern.compile(
|
||||
"(?<quoted>" + QUOTED_NAME + ")"
|
||||
+ "|(?<command>/iris(?: [\\w:=./-]+)+)"
|
||||
+ "|(?<key>\\b[a-z0-9_.-]+:[a-z0-9_./-]+)"
|
||||
+ "|(?<path>\\b[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*|\\[\\d+])+)");
|
||||
private static final Pattern SUBJECT_REASON = Pattern.compile("^([A-Z][\\w ]*?) '([^']+)'(.+)$", Pattern.DOTALL);
|
||||
private static final Pattern LEADING_JOINER = Pattern.compile("^[.\\s]+");
|
||||
|
||||
private ReportText() {
|
||||
}
|
||||
|
||||
static String title(ChatReport.Tone tone, String plain) {
|
||||
return title(tone.color(), plain);
|
||||
}
|
||||
|
||||
static String title(C color, String plain) {
|
||||
String base = color.toString();
|
||||
return base + highlightQuoted(plain, C.WHITE.toString(), base);
|
||||
}
|
||||
|
||||
static String body(String plain) {
|
||||
Matcher sentenceBreak = SENTENCE_BREAK.matcher(plain);
|
||||
if (!sentenceBreak.find()) {
|
||||
return C.GRAY + highlightTokens(plain, C.GRAY.toString());
|
||||
}
|
||||
String head = plain.substring(0, sentenceBreak.start());
|
||||
String tail = plain.substring(sentenceBreak.end());
|
||||
return C.GRAY + highlightTokens(head, C.GRAY.toString()) + " " + C.DARK_GRAY + tail;
|
||||
}
|
||||
|
||||
/** Groups reasons shaped like {@code Kind 'subject' rest} that share kind and rest; other reasons stay single. */
|
||||
static List<List<String>> groupedBodies(List<String> plainReasons, String continuationIndent) {
|
||||
Map<String, SubjectGroup> groups = new LinkedHashMap<>();
|
||||
for (String reason : plainReasons) {
|
||||
Matcher matcher = SUBJECT_REASON.matcher(reason);
|
||||
if (!matcher.matches()) {
|
||||
groups.put("\u0000" + groups.size(), new SubjectGroup(null, reason));
|
||||
continue;
|
||||
}
|
||||
String kind = matcher.group(1);
|
||||
String rest = LEADING_JOINER.matcher(matcher.group(3)).replaceFirst("");
|
||||
groups.computeIfAbsent(kind + "\u0000" + rest, ignored -> new SubjectGroup(kind, rest))
|
||||
.add(matcher.group(2), reason);
|
||||
}
|
||||
|
||||
List<List<String>> entries = new ArrayList<>(groups.size());
|
||||
for (SubjectGroup group : groups.values()) {
|
||||
entries.add(group.render(continuationIndent));
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
private static String highlightQuoted(String plain, String highlight, String base) {
|
||||
Matcher matcher = QUOTED.matcher(plain);
|
||||
StringBuilder styled = new StringBuilder();
|
||||
while (matcher.find()) {
|
||||
matcher.appendReplacement(styled, Matcher.quoteReplacement(highlight + matcher.group() + base));
|
||||
}
|
||||
matcher.appendTail(styled);
|
||||
return styled.toString();
|
||||
}
|
||||
|
||||
private static String highlightTokens(String plain, String base) {
|
||||
Matcher matcher = TOKEN.matcher(plain);
|
||||
StringBuilder styled = new StringBuilder();
|
||||
while (matcher.find()) {
|
||||
matcher.appendReplacement(styled, Matcher.quoteReplacement(tokenColor(matcher) + matcher.group() + base));
|
||||
}
|
||||
matcher.appendTail(styled);
|
||||
return styled.toString();
|
||||
}
|
||||
|
||||
private static String tokenColor(Matcher matcher) {
|
||||
if (matcher.group("quoted") != null) {
|
||||
return C.WHITE.toString();
|
||||
}
|
||||
if (matcher.group("command") != null) {
|
||||
return C.IRIS.toString();
|
||||
}
|
||||
return C.AQUA.toString();
|
||||
}
|
||||
|
||||
static String moreLabel(int hidden) {
|
||||
return ChatReport.clean(IrisLanguage.plain(RuntimeUiMessages.REPORT_MORE, MessageArgument.trusted("count", hidden)));
|
||||
}
|
||||
|
||||
private static String plural(String kind) {
|
||||
String lower = kind.toLowerCase(Locale.ROOT);
|
||||
if (lower.endsWith("s")) {
|
||||
return lower;
|
||||
}
|
||||
if (lower.endsWith("y") && !lower.endsWith("ey")) {
|
||||
return lower.substring(0, lower.length() - 1) + "ies";
|
||||
}
|
||||
return lower + "s";
|
||||
}
|
||||
|
||||
private static final class SubjectGroup {
|
||||
private final String kind;
|
||||
private final String rest;
|
||||
private final List<String> subjects = new ArrayList<>();
|
||||
private String singleReason;
|
||||
|
||||
private SubjectGroup(String kind, String reasonOrRest) {
|
||||
this.kind = kind;
|
||||
this.rest = reasonOrRest;
|
||||
this.singleReason = kind == null ? reasonOrRest : null;
|
||||
}
|
||||
|
||||
private void add(String subject, String reason) {
|
||||
subjects.add(subject);
|
||||
singleReason = subjects.size() == 1 ? reason : null;
|
||||
}
|
||||
|
||||
private List<String> render(String continuationIndent) {
|
||||
if (singleReason != null) {
|
||||
return List.of(body(singleReason));
|
||||
}
|
||||
String head = C.WHITE + String.valueOf(subjects.size()) + " " + plural(kind) + C.DARK_GRAY + ": " + body(rest);
|
||||
return List.of(head, continuationIndent + subjectList());
|
||||
}
|
||||
|
||||
private String subjectList() {
|
||||
int shown = Math.min(GROUP_SUBJECTS_SHOWN, subjects.size());
|
||||
StringBuilder list = new StringBuilder();
|
||||
for (int index = 0; index < shown; index++) {
|
||||
if (index > 0) {
|
||||
list.append(C.DARK_GRAY).append(", ");
|
||||
}
|
||||
list.append(C.WHITE).append(subjects.get(index));
|
||||
}
|
||||
int hidden = subjects.size() - shown;
|
||||
if (hidden > 0) {
|
||||
list.append(C.DARK_GRAY).append(" ").append(moreLabel(hidden));
|
||||
}
|
||||
return list.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,14 @@ public final class RuntimeProgressMessages {
|
||||
public static final TextKey CHUNK_ACTION_FAILED = TextKey.of("iris.runtime.chunk_job.action.failed", "{bar}" + C.GRAY + " " + C.RED + "Failed" + C.GRAY + " | " + C.WHITE + "{summary}");
|
||||
public static final TextKey CHUNK_COMPLETE = TextKey.of("iris.runtime.chunk_job.complete", C.GREEN + "{title} complete: {summary}");
|
||||
public static final TextKey CHUNK_FAILED = TextKey.of("iris.runtime.chunk_job.failed", C.RED + "{title} finished with errors: {summary}");
|
||||
public static final TextKey CHUNK_STAGE_STOPPING = TextKey.of("iris.runtime.chunk_job.stage.stopping", "Stopping");
|
||||
public static final TextKey CHUNK_BOSSBAR_STOPPED = TextKey.of("iris.runtime.chunk_job.bossbar.stopped", C.GOLD + "{title} " + C.YELLOW + "STOPPED" + C.GRAY + " " + C.YELLOW + "{summary}");
|
||||
public static final TextKey CHUNK_ACTION_STOPPED = TextKey.of("iris.runtime.chunk_job.action.stopped", "{bar}" + C.GRAY + " " + C.YELLOW + "Stopped" + C.GRAY + " | " + C.WHITE + "{summary}");
|
||||
public static final TextKey CHUNK_STOPPED = TextKey.of("iris.runtime.chunk_job.stopped", C.GOLD + "{title} stopped: {summary}");
|
||||
public static final TextKey CHUNK_ALREADY_RUNNING = TextKey.of("iris.runtime.chunk_job.already_running", "{title} is already running in {world}: {applied}/{total} chunks");
|
||||
public static final TextKey CHUNK_STOP_HINT = TextKey.of("iris.runtime.chunk_job.stop_hint", "Stop it with {command}");
|
||||
public static final TextKey CHUNK_STOPPING = TextKey.of("iris.runtime.chunk_job.stopping", "Stopping {title} in {world}; chunks in progress finish first");
|
||||
public static final TextKey CHUNK_NONE_RUNNING = TextKey.of("iris.runtime.chunk_job.none_running", "No {title} is running in {world}");
|
||||
public static final TextKey GOLDEN_NO_CAPTURE = TextKey.of("iris.runtime.golden.no_capture", "No golden capture at {path}; run a capture first.");
|
||||
public static final PluralKey GOLDEN_ABORTED = PluralKey.of(
|
||||
"iris.runtime.golden.aborted",
|
||||
@@ -180,6 +188,14 @@ public final class RuntimeProgressMessages {
|
||||
CHUNK_ACTION_FAILED,
|
||||
CHUNK_COMPLETE,
|
||||
CHUNK_FAILED,
|
||||
CHUNK_STAGE_STOPPING,
|
||||
CHUNK_BOSSBAR_STOPPED,
|
||||
CHUNK_ACTION_STOPPED,
|
||||
CHUNK_STOPPED,
|
||||
CHUNK_ALREADY_RUNNING,
|
||||
CHUNK_STOP_HINT,
|
||||
CHUNK_STOPPING,
|
||||
CHUNK_NONE_RUNNING,
|
||||
GOLDEN_NO_CAPTURE,
|
||||
GOLDEN_ABORTED,
|
||||
GOLDEN_FAILED,
|
||||
|
||||
@@ -29,6 +29,9 @@ public final class RuntimeUiMessages {
|
||||
public static final TextKey MODDED_NO_DIMENSION_MATCH = TextKey.of("iris.runtime.modded.no_dimension_match", "No Iris dimension matches '{filter}'.");
|
||||
public static final TextKey TELEPORTED_TO_WORLD = TextKey.of("iris.runtime.teleport.world", "You have been teleported to {world}.");
|
||||
public static final TextKey ENGINE_HOTLOADED = TextKey.of("iris.runtime.engine.hotloaded", "Engine Hotloaded");
|
||||
public static final TextKey STUDIO_RESTART_NEEDED = TextKey.of("iris.runtime.studio.restart_needed", "restart needed: {biomes}");
|
||||
public static final TextKey STUDIO_HOTLOADED_RESTART_NEEDED = TextKey.of("iris.runtime.studio.hotloaded_restart_needed", C.YELLOW + "Studio hotloaded · restart needed: {biomes}");
|
||||
public static final TextKey STUDIO_HOTLOAD_BLOCKED_RESTART_NEEDED = TextKey.of("iris.runtime.studio.hotload_blocked_restart_needed", C.RED + "Studio hotload blocked · restart needed: {biomes}");
|
||||
public static final TextKey JOB_COMPLETED = TextKey.of("iris.runtime.job.completed", "Completed {job} in {duration}");
|
||||
public static final TextKey JOB_SCANNING_SELECTION = TextKey.of("iris.runtime.job.scanning_selection", "Scanning Selection");
|
||||
public static final TextKey JOB_SEARCHED_CHUNKS = TextKey.of("iris.runtime.job.searched_chunks", "Searched {chunks} Chunks");
|
||||
@@ -122,6 +125,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,
|
||||
@@ -147,6 +152,9 @@ public final class RuntimeUiMessages {
|
||||
MODDED_NO_DIMENSION_MATCH,
|
||||
TELEPORTED_TO_WORLD,
|
||||
ENGINE_HOTLOADED,
|
||||
STUDIO_RESTART_NEEDED,
|
||||
STUDIO_HOTLOADED_RESTART_NEEDED,
|
||||
STUDIO_HOTLOAD_BLOCKED_RESTART_NEEDED,
|
||||
JOB_COMPLETED,
|
||||
JOB_SCANNING_SELECTION,
|
||||
JOB_SEARCHED_CHUNKS,
|
||||
@@ -239,7 +247,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) {
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package art.arcane.iris.pack;
|
||||
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.pack.validation.PackCompatReport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** 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_KEYS_SHOWN = 2;
|
||||
private static final Pattern SENTENCE_BREAK = Pattern.compile("(?<=[.!?])\\s+(?=[A-Z\\[])");
|
||||
|
||||
private PackBootReporter() {
|
||||
}
|
||||
|
||||
public static void logBroken(PackValidationResult result, String minecraftVersion) {
|
||||
String pack = result.getPackName();
|
||||
logReport(ChatReport.Tone.ERROR,
|
||||
"Pack '" + pack + "' failed validation. Worlds and Studio won't load it.",
|
||||
result, minecraftVersion, result.getBlockingErrors());
|
||||
}
|
||||
|
||||
public static void logValidated(PackValidationResult result, String minecraftVersion, boolean announceClean) {
|
||||
String pack = result.getPackName();
|
||||
int warnings = result.getWarnings().size();
|
||||
if (warnings > 0) {
|
||||
logReport(ChatReport.Tone.WARNING,
|
||||
"Pack '" + pack + "' has " + warnings + (warnings == 1 ? " warning" : " warnings"),
|
||||
result, minecraftVersion, result.getWarnings());
|
||||
return;
|
||||
}
|
||||
if (!result.getCompatFindings().isEmpty()) {
|
||||
logReport(ChatReport.Tone.WARNING, "Pack '" + pack + "' uses content this version doesn't have",
|
||||
result, minecraftVersion, List.of());
|
||||
return;
|
||||
}
|
||||
if (announceClean) {
|
||||
ChatReport.of(ChatReport.Tone.SUCCESS, "Validated pack '" + pack + "'").build().log();
|
||||
}
|
||||
}
|
||||
|
||||
private static void logReport(ChatReport.Tone tone, String title, PackValidationResult result,
|
||||
String minecraftVersion, List<String> reasons) {
|
||||
String pack = result.getPackName();
|
||||
List<String> items = new ArrayList<>(reasons.size() + 1);
|
||||
reasons.forEach(reason -> items.add(firstSentence(reason)));
|
||||
boolean hasCompatFindings = !result.getCompatFindings().isEmpty();
|
||||
if (hasCompatFindings) {
|
||||
items.add(PackCompatReport.of(result.getCompatFindings())
|
||||
.bootItem(PackValidator.versionOf(result, minecraftVersion), COMPAT_KEYS_SHOWN));
|
||||
}
|
||||
ChatReport.Builder report = ChatReport.of(tone, title).items(items).limit(BOOT_ITEM_LIMIT);
|
||||
if (!reasons.isEmpty()) {
|
||||
report.nextStep("See every issue", "/iris pack validate " + pack);
|
||||
}
|
||||
if (hasCompatFindings) {
|
||||
report.nextStep("See the missing content", "/iris pack compat " + pack);
|
||||
}
|
||||
report.build().log();
|
||||
}
|
||||
|
||||
private static String firstSentence(String reason) {
|
||||
return SENTENCE_BREAK.split(reason, 2)[0];
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -350,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;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public final class DatapackIngestService {
|
||||
urls,
|
||||
localFingerprint)) {
|
||||
DatapackStartupValidation.activeStartupValidation = cached;
|
||||
IrisLogging.info("External datapacks match the persisted startup validation; remote resolution and full revalidation were skipped.");
|
||||
IrisLogging.debug("External datapacks match the persisted startup validation; remote resolution and full revalidation were skipped.");
|
||||
IrisStartupValidation.markDatapacksReady();
|
||||
return StartupValidationOutcome.READY;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
@@ -133,7 +134,7 @@ public class ServerConfigurator {
|
||||
&& pinLoadedDatapackCompilerInputs(
|
||||
DefaultPackBootstrapProvisioner.compilerInputFingerprintThisStartup())
|
||||
&& pinLoadedDatapackRegistryRequirements();
|
||||
IrisLogging.info("Paper loaded the Iris datapack during bootstrap; skipping the legacy startup install.");
|
||||
IrisLogging.debug("Paper loaded the Iris datapack during bootstrap; skipping the legacy startup install.");
|
||||
} else {
|
||||
DatapackInstallResult result = installDataPacks(true);
|
||||
loadedDatapackRuntimeReady = result.succeeded()
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ final class JsonSchemaValidator {
|
||||
private JsonSchemaValidator() {
|
||||
}
|
||||
|
||||
static void validateTopLevelKeys(JSONObject parsed, String rawText, File file, String resourceTypeName, Class<?> objectClass) {
|
||||
static void validateTopLevelKeys(JSONObject parsed, String rawText, File file, File dataFolder, String resourceTypeName, Class<?> objectClass) {
|
||||
if (parsed == null || objectClass == null) {
|
||||
return;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ final class JsonSchemaValidator {
|
||||
if (known.contains(key)) {
|
||||
continue;
|
||||
}
|
||||
reportUnknownKey(key, rawText, file, resourceTypeName, known);
|
||||
reportUnknownKey(key, rawText, file, dataFolder, resourceTypeName, known);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,25 +56,10 @@ final class JsonSchemaValidator {
|
||||
IrisLogging.warn(out.toString());
|
||||
}
|
||||
|
||||
private static void reportUnknownKey(String key, String rawText, File file, String resourceTypeName, Set<String> known) {
|
||||
private static void reportUnknownKey(String key, String rawText, File file, File dataFolder, String resourceTypeName, Set<String> known) {
|
||||
int line = findLineForKey(rawText, key);
|
||||
String suggestion = closestMatch(key, known);
|
||||
StringBuilder out = new StringBuilder();
|
||||
out.append("Unknown ").append(resourceTypeName).append(" field ")
|
||||
.append(C.WHITE).append('"').append(key).append('"').append(C.YELLOW)
|
||||
.append(" in ").append(C.WHITE).append(file.getPath());
|
||||
if (line > 0) {
|
||||
out.append(":").append(line);
|
||||
}
|
||||
out.append(C.YELLOW).append(" (Gson will silently ignore this)");
|
||||
if (suggestion != null) {
|
||||
out.append(". Did you mean ").append(C.WHITE).append('"').append(suggestion).append('"').append(C.YELLOW).append("?");
|
||||
}
|
||||
String snippet = buildSnippet(rawText, line);
|
||||
if (snippet != null) {
|
||||
out.append('\n').append(snippet);
|
||||
}
|
||||
IrisLogging.warn(out.toString());
|
||||
UnknownFieldReport.record(dataFolder, file, resourceTypeName, key, line, suggestion);
|
||||
}
|
||||
|
||||
private static Set<String> collectFieldNames(Class<?> cls) {
|
||||
|
||||
@@ -417,7 +417,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
rawText = IO.readAll(j);
|
||||
JSONObject parsed = new JSONObject(rawText);
|
||||
JsonSchemaValidator.validateTopLevelKeys(parsed, rawText, j, resourceTypeName, objectClass);
|
||||
JsonSchemaValidator.validateTopLevelKeys(parsed, rawText, j, root, resourceTypeName, objectClass);
|
||||
if (objectClass == IrisDimension.class) {
|
||||
PackValidator.requireValidObjectSettings(manager.getDataFolder(), name, parsed);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
package art.arcane.iris.pack.loading;
|
||||
|
||||
import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.world.history.GenerationHistoryPaths;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
final class UnknownFieldReport {
|
||||
private static final long QUIET_PERIOD_BEFORE_FLUSH_MS = 1_500L;
|
||||
private static final String FLUSH_THREAD_NAME = "Iris Unknown Field Report";
|
||||
private static final String EPOCH_METADATA_FILE_NAME = "epoch.json";
|
||||
private static final Set<String> REPORTED = ConcurrentHashMap.newKeySet();
|
||||
private static final Map<Path, String> PACK_LABELS = new ConcurrentHashMap<>();
|
||||
private static final List<UnknownField> PENDING = new ArrayList<>();
|
||||
private static final ScheduledExecutorService FLUSHER = Executors.newSingleThreadScheduledExecutor(runnable -> {
|
||||
Thread thread = new Thread(runnable, FLUSH_THREAD_NAME);
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
});
|
||||
private static ScheduledFuture<?> scheduledFlush;
|
||||
|
||||
private UnknownFieldReport() {
|
||||
}
|
||||
|
||||
static void record(File dataFolder, File file, String resourceTypeName, String field, int line, String suggestion) {
|
||||
String pack = packLabel(dataFolder);
|
||||
String location = relativeLocation(dataFolder, file, line);
|
||||
UnknownField unknown = new UnknownField(pack, resourceTypeName, field, location, suggestion);
|
||||
if (!REPORTED.add(unknown.identity())) {
|
||||
return;
|
||||
}
|
||||
synchronized (PENDING) {
|
||||
PENDING.add(unknown);
|
||||
rescheduleFlush();
|
||||
}
|
||||
}
|
||||
|
||||
static void flush() {
|
||||
if (!IrisPlatforms.isBound()) {
|
||||
synchronized (PENDING) {
|
||||
rescheduleFlush();
|
||||
}
|
||||
return;
|
||||
}
|
||||
drainReports().forEach(ChatReport::log);
|
||||
}
|
||||
|
||||
static List<ChatReport> drainReports() {
|
||||
List<UnknownField> batch;
|
||||
synchronized (PENDING) {
|
||||
batch = new ArrayList<>(PENDING);
|
||||
PENDING.clear();
|
||||
}
|
||||
List<ChatReport> reports = new ArrayList<>();
|
||||
groupByPack(batch).forEach((pack, fields) -> reports.add(packReport(pack, fields)));
|
||||
return reports;
|
||||
}
|
||||
|
||||
static void resetForTests() {
|
||||
synchronized (PENDING) {
|
||||
PENDING.clear();
|
||||
}
|
||||
REPORTED.clear();
|
||||
PACK_LABELS.clear();
|
||||
}
|
||||
|
||||
private static void rescheduleFlush() {
|
||||
if (scheduledFlush != null) {
|
||||
scheduledFlush.cancel(false);
|
||||
}
|
||||
scheduledFlush = FLUSHER.schedule(UnknownFieldReport::flush, QUIET_PERIOD_BEFORE_FLUSH_MS, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private static Map<String, Map<String, List<UnknownField>>> groupByPack(List<UnknownField> batch) {
|
||||
Map<String, Map<String, List<UnknownField>>> packs = new TreeMap<>();
|
||||
for (UnknownField unknown : batch) {
|
||||
packs.computeIfAbsent(unknown.pack(), key -> new TreeMap<>())
|
||||
.computeIfAbsent(unknown.typeAndField(), key -> new ArrayList<>())
|
||||
.add(unknown);
|
||||
}
|
||||
return packs;
|
||||
}
|
||||
|
||||
private static ChatReport packReport(String pack, Map<String, List<UnknownField>> fields) {
|
||||
String title = "Pack '" + pack + "' has " + fields.size() + (fields.size() == 1 ? " unknown field" : " unknown fields")
|
||||
+ ". Iris ignores " + (fields.size() == 1 ? "it." : "them.");
|
||||
ChatReport.Builder report = ChatReport.of(ChatReport.Tone.WARNING, title);
|
||||
int labelWidth = fields.keySet().stream().mapToInt(String::length).max().orElse(0);
|
||||
fields.forEach((typeAndField, occurrences) -> report.styledItem(describeField(typeAndField, occurrences, labelWidth)));
|
||||
return report.build();
|
||||
}
|
||||
|
||||
private static String describeField(String typeAndField, List<UnknownField> occurrences, int labelWidth) {
|
||||
UnknownField first = occurrences.getFirst();
|
||||
int count = occurrences.size();
|
||||
StringBuilder out = new StringBuilder()
|
||||
.append(C.WHITE).append(padRight(typeAndField, labelWidth))
|
||||
.append(C.DARK_GRAY).append(" ").append(count).append(count == 1 ? " file " : " files")
|
||||
.append(" ").append(C.GRAY).append(count == 1 ? "" : "e.g. ")
|
||||
.append(C.AQUA).append(first.location());
|
||||
if (first.suggestion() != null) {
|
||||
out.append(C.GRAY).append(" Did you mean ").append(C.WHITE).append('\'').append(first.suggestion()).append('\'').append(C.GRAY).append('?');
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
private static String padRight(String text, int width) {
|
||||
return text + " ".repeat(Math.max(0, width - text.length()));
|
||||
}
|
||||
|
||||
private static String packLabel(File dataFolder) {
|
||||
if (dataFolder == null) {
|
||||
return "pack";
|
||||
}
|
||||
Path folder = dataFolder.toPath().toAbsolutePath().normalize();
|
||||
return PACK_LABELS.computeIfAbsent(folder, UnknownFieldReport::resolvePackLabel);
|
||||
}
|
||||
|
||||
private static String resolvePackLabel(Path dataFolder) {
|
||||
Path epochs = ancestor(dataFolder, 2);
|
||||
boolean epochSnapshot = GenerationHistoryPaths.LEGACY_PACK_DIRECTORY_NAME.equals(name(dataFolder))
|
||||
&& GenerationHistoryPaths.EPOCHS_DIRECTORY_NAME.equals(name(epochs));
|
||||
if (!epochSnapshot) {
|
||||
return name(dataFolder);
|
||||
}
|
||||
String dimensionKey = epochDimensionKey(dataFolder.getParent().resolve(EPOCH_METADATA_FILE_NAME));
|
||||
return dimensionKey != null ? dimensionKey : name(ancestor(epochs, 3));
|
||||
}
|
||||
|
||||
private static String epochDimensionKey(Path epochMetadata) {
|
||||
try {
|
||||
JSONObject contract = new JSONObject(Files.readString(epochMetadata)).optJSONObject("dimensionContract");
|
||||
String dimensionKey = contract == null ? "" : contract.optString("dimensionKey", "");
|
||||
return dimensionKey.isBlank() ? null : dimensionKey;
|
||||
} catch (IOException | RuntimeException unreadable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Path ancestor(Path path, int levels) {
|
||||
Path current = path;
|
||||
for (int i = 0; i < levels && current != null; i++) {
|
||||
current = current.getParent();
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
private static String name(Path path) {
|
||||
return path == null || path.getFileName() == null ? null : path.getFileName().toString();
|
||||
}
|
||||
|
||||
private static String relativeLocation(File dataFolder, File file, int line) {
|
||||
String path = file.getPath();
|
||||
if (dataFolder != null) {
|
||||
Path root = dataFolder.toPath().toAbsolutePath().normalize();
|
||||
Path target = file.toPath().toAbsolutePath().normalize();
|
||||
if (target.startsWith(root)) {
|
||||
path = root.relativize(target).toString().replace(File.separatorChar, '/');
|
||||
}
|
||||
}
|
||||
return line > 0 ? path + ":" + line : path;
|
||||
}
|
||||
|
||||
private record UnknownField(String pack, String resourceTypeName, String field, String location, String suggestion) {
|
||||
String typeAndField() {
|
||||
return resourceTypeName + " '" + field + "'";
|
||||
}
|
||||
|
||||
String identity() {
|
||||
return pack + '\u0000' + typeAndField() + '\u0000' + location;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,6 +129,16 @@ public final class MissingBlockState implements NativeBlockState {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLog() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeaves() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoliagePlantable() {
|
||||
return false;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package art.arcane.iris.pack.validation;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumMap;
|
||||
@@ -157,15 +158,34 @@ 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;
|
||||
}
|
||||
|
||||
/** {@code 4 content keys unavailable on Minecraft 26.3: create:limestone, create:scoria +2 more} */
|
||||
public synchronized String bootItem(String minecraftVersion, int maxKeys) {
|
||||
List<String> keys = byKey().values().stream().map(group -> group.getFirst().key()).toList();
|
||||
int shown = Math.min(maxKeys, keys.size());
|
||||
int hidden = keys.size() - shown;
|
||||
return keys.size() + (keys.size() == 1 ? " content key" : " content keys")
|
||||
+ " unavailable on Minecraft " + versionOrUnknown(minecraftVersion) + ": "
|
||||
+ String.join(", ", keys.subList(0, shown))
|
||||
+ (hidden > 0 ? " +" + hidden + " more" : "");
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
@@ -67,11 +67,10 @@ public class Agent {
|
||||
return false;
|
||||
|
||||
try {
|
||||
IrisLogging.info("Installing Java Agent...");
|
||||
IrisLogging.info("Note: JVM [Attach Listener/ERROR] [STDERR] warning lines during this step are expected and not Iris errors.");
|
||||
IrisLogging.info("Installing Java agent… The JVM warnings below are expected.");
|
||||
ByteBuddyAgent.attach(AGENT_JAR, ByteBuddyAgent.ProcessProvider.ForCurrentVm.INSTANCE);
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.error("Failed to install Java Agent: " + e.getMessage());
|
||||
IrisLogging.error("Couldn't install the Java agent. " + e.getMessage());
|
||||
IrisLogging.reportError(e);
|
||||
}
|
||||
return doGetInstrumentation() != null;
|
||||
|
||||
@@ -100,8 +100,12 @@ public final class BukkitBlockResolution {
|
||||
}
|
||||
|
||||
Identifier key = Identifier.fromString(ix);
|
||||
Optional<BlockData> bd = IrisServices.get(ExternalDataSVC.class).getBlockData(key);
|
||||
ExternalDataSVC external = IrisServices.get(ExternalDataSVC.class);
|
||||
Optional<BlockData> bd = external.getBlockData(key);
|
||||
debug("Loading block data " + key);
|
||||
if (bd.isPresent() && shouldPreventLeafDecay()) {
|
||||
return external.withoutDecay(bd.get());
|
||||
}
|
||||
return bd.orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,11 @@ import art.arcane.volmlib.nativelib.terrain.BlockStateKey;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.iris.generation.block.IrisCustomData;
|
||||
import art.arcane.iris.generation.geometry.IrisBlockVector;
|
||||
import art.arcane.iris.spi.IrisServices;
|
||||
import art.arcane.volmlib.util.collection.KMap;
|
||||
import org.bukkit.Axis;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@@ -75,6 +77,8 @@ public final class BukkitBlockState implements NativeBlockState {
|
||||
private byte updatable;
|
||||
private byte foliage;
|
||||
private byte treeBlock;
|
||||
private byte log;
|
||||
private byte leaves;
|
||||
private byte foliagePlantable;
|
||||
private byte decorant;
|
||||
private byte storage;
|
||||
@@ -318,12 +322,41 @@ public final class BukkitBlockState implements NativeBlockState {
|
||||
public boolean isTreeBlock() {
|
||||
byte cached = treeBlock;
|
||||
if (cached == UNKNOWN) {
|
||||
cached = flag(Tag.LOGS.isTagged(data.getMaterial()) || Tag.LEAVES.isTagged(data.getMaterial()));
|
||||
cached = flag(isLog() || isLeaves());
|
||||
treeBlock = cached;
|
||||
}
|
||||
return cached == TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLog() {
|
||||
byte cached = log;
|
||||
if (cached == UNKNOWN) {
|
||||
cached = flag(hasTag(Tag.LOGS));
|
||||
log = cached;
|
||||
}
|
||||
return cached == TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeaves() {
|
||||
byte cached = leaves;
|
||||
if (cached == UNKNOWN) {
|
||||
cached = flag(hasTag(Tag.LEAVES));
|
||||
leaves = cached;
|
||||
}
|
||||
return cached == TRUE;
|
||||
}
|
||||
|
||||
// A plugin's custom block shows up as some other material, so the plugin is asked for its own tags too.
|
||||
private boolean hasTag(Tag<Material> tag) {
|
||||
if (tag.isTagged(data.getMaterial())) {
|
||||
return true;
|
||||
}
|
||||
ExternalDataSVC external = IrisServices.getOrNull(ExternalDataSVC.class);
|
||||
return external != null && external.hasBlockTag(data, tag.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoliagePlantable() {
|
||||
byte cached = foliagePlantable;
|
||||
|
||||
@@ -27,6 +27,11 @@ 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.ConsoleGlyphs;
|
||||
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;
|
||||
@@ -251,7 +256,8 @@ public class VolmitSender implements CommandSender {
|
||||
ComponentMessenger.sendActionBar(player, message);
|
||||
}
|
||||
|
||||
private ComponentText createNoPrefixComponent(String message) {
|
||||
private ComponentText createNoPrefixComponent(String rawMessage) {
|
||||
String message = fitForRecipient(rawMessage);
|
||||
if (!IrisSettings.get().getGeneral().canUseCustomColors(this)) {
|
||||
String t = C.translateAlternateColorCodes('&', MiniMessage.miniMessage().stripTags(message));
|
||||
return ComponentText.markup(C.mini(t));
|
||||
@@ -263,59 +269,111 @@ public class VolmitSender implements CommandSender {
|
||||
}
|
||||
|
||||
private ComponentText createNoPrefixComponentNoProcessing(String message) {
|
||||
return ComponentText.markup(C.mini(message));
|
||||
return ComponentText.markup(C.mini(fitForRecipient(message)));
|
||||
}
|
||||
|
||||
private ComponentText createComponent(String message) {
|
||||
if (!IrisSettings.get().getGeneral().canUseCustomColors(this)) {
|
||||
String t = C.translateAlternateColorCodes('&', MiniMessage.miniMessage().stripTags(getTag() + message));
|
||||
String t = C.translateAlternateColorCodes('&', MiniMessage.miniMessage().stripTags(taggedForRecipient(message)));
|
||||
return ComponentText.markup(C.mini(t));
|
||||
}
|
||||
|
||||
String t = C.translateAlternateColorCodes('&', getTag() + message);
|
||||
String t = C.translateAlternateColorCodes('&', taggedForRecipient(message));
|
||||
String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb());
|
||||
return ComponentText.markup(a);
|
||||
}
|
||||
|
||||
private ComponentText createComponentRaw(String message) {
|
||||
if (!IrisSettings.get().getGeneral().canUseCustomColors(this)) {
|
||||
String t = C.translateAlternateColorCodes('&', MiniMessage.miniMessage().stripTags(getTag() + message));
|
||||
String t = C.translateAlternateColorCodes('&', MiniMessage.miniMessage().stripTags(taggedForRecipient(message)));
|
||||
return ComponentText.markup(C.mini(t));
|
||||
}
|
||||
|
||||
String t = C.translateAlternateColorCodes('&', getTag() + message);
|
||||
String t = C.translateAlternateColorCodes('&', taggedForRecipient(message));
|
||||
return ComponentText.markup(C.mini(t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
if ((!IrisSettings.get().getGeneral().isUseCustomColorsIngame() && s instanceof Player) || !IrisSettings.get().getGeneral().isUseConsoleCustomColors()) {
|
||||
ComponentMessenger.sendSection(s, C.translateAlternateColorCodes('&', getTag() + message));
|
||||
sendSection(C.translateAlternateColorCodes('&', taggedForRecipient(message)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.contains("<NOMINI>")) {
|
||||
ComponentMessenger.sendSection(
|
||||
s,
|
||||
C.translateAlternateColorCodes('&', getTag() + message.replace("<NOMINI>", "")));
|
||||
sendSection(C.translateAlternateColorCodes('&', taggedForRecipient(message).replace("<NOMINI>", "")));
|
||||
return;
|
||||
}
|
||||
|
||||
deliver(createComponent(message));
|
||||
}
|
||||
|
||||
public void sendSuccess(String message) {
|
||||
sendToned(ChatReport.Tone.SUCCESS, message);
|
||||
}
|
||||
|
||||
public void sendInfo(String message) {
|
||||
sendToned(ChatReport.Tone.INFO, message);
|
||||
}
|
||||
|
||||
public void sendWarning(String message) {
|
||||
sendToned(ChatReport.Tone.WARNING, message);
|
||||
}
|
||||
|
||||
public void sendError(String message) {
|
||||
sendToned(ChatReport.Tone.ERROR, message);
|
||||
}
|
||||
|
||||
private void sendToned(ChatReport.Tone tone, String message) {
|
||||
sendMessage(isPlayer() ? tone.paint(message) : tone.marked(tone.consolePaint(message)));
|
||||
}
|
||||
|
||||
public void sendReport(ChatReport report) {
|
||||
if (!isPlayer()) {
|
||||
report.consoleLines().forEach(this::sendMessage);
|
||||
return;
|
||||
}
|
||||
sendUntagged(ChatReport.SPACER);
|
||||
sendMessage(report.titleLine().text());
|
||||
for (ChatReport.Line line : report.bodyLines(true)) {
|
||||
sendUntagged(line);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendUntagged(ChatReport.Line line) {
|
||||
if (!rendersMarkup()) {
|
||||
sendSection(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));
|
||||
sendSection(C.translateAlternateColorCodes('&', taggedForRecipient(message)));
|
||||
}
|
||||
|
||||
public void sendMessageRaw(String message) {
|
||||
if ((!IrisSettings.get().getGeneral().isUseCustomColorsIngame() && s instanceof Player) || !IrisSettings.get().getGeneral().isUseConsoleCustomColors()) {
|
||||
ComponentMessenger.sendSection(s, C.translateAlternateColorCodes('&', message));
|
||||
sendSection(C.translateAlternateColorCodes('&', message));
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.contains("<NOMINI>")) {
|
||||
ComponentMessenger.sendSection(s, message.replace("<NOMINI>", ""));
|
||||
sendSection(message.replace("<NOMINI>", ""));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -326,6 +384,21 @@ public class VolmitSender implements CommandSender {
|
||||
deliver(ComponentText.component(component));
|
||||
}
|
||||
|
||||
private void sendSection(String text) {
|
||||
ComponentMessenger.sendSection(s, fitForRecipient(text));
|
||||
}
|
||||
|
||||
private String taggedForRecipient(String message) {
|
||||
return fitForRecipient(getTag() + message);
|
||||
}
|
||||
|
||||
private String fitForRecipient(String text) {
|
||||
if (s instanceof Player) {
|
||||
return text;
|
||||
}
|
||||
return ConsoleGlyphs.console().fit(text);
|
||||
}
|
||||
|
||||
private void deliver(ComponentText message) {
|
||||
ComponentMessenger.send(s, message);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,11 @@ import art.arcane.iris.generation.runtime.IrisWorldManager;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.generation.chunk.TerrainChunk;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.StudioRestartRequirement;
|
||||
import art.arcane.iris.world.history.RegistryRestartRequiredException;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.localization.RuntimeUiMessages;
|
||||
import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
import art.arcane.iris.generation.runtime.EngineTarget;
|
||||
import art.arcane.iris.generation.runtime.GenerationSessionException;
|
||||
import art.arcane.iris.generation.runtime.GenerationSessionLease;
|
||||
@@ -1080,11 +1085,32 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
|
||||
withExclusiveControl(() -> {
|
||||
if (!studioUpdatesPaused && !closing) {
|
||||
getEngine().hotload();
|
||||
hotloadEngine();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void hotloadEngine() {
|
||||
Engine activeEngine = getEngine();
|
||||
long started = M.ms();
|
||||
activeEngine.hotload();
|
||||
IrisLogging.info("Hotloaded " + packKeyOf(activeEngine) + " in " + (M.ms() - started) + "ms"
|
||||
+ restartSuffix(activeEngine.getStudioRestartRequirement()));
|
||||
}
|
||||
|
||||
private static String restartSuffix(StudioRestartRequirement requirement) {
|
||||
if (!requirement.isPending()) {
|
||||
return "";
|
||||
}
|
||||
return " · " + IrisLanguage.plain(RuntimeUiMessages.STUDIO_RESTART_NEEDED,
|
||||
MessageArgument.untrusted("biomes", requirement.biomeSummary()));
|
||||
}
|
||||
|
||||
private static String packKeyOf(Engine activeEngine) {
|
||||
IrisDimension dimension = activeEngine.getDimension();
|
||||
return dimension == null ? "unknown pack" : dimension.getLoadKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> hotloadAsync() {
|
||||
if (!canHotloadStudio()) {
|
||||
@@ -1094,7 +1120,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
if (!canHotloadStudio()) {
|
||||
throw new IllegalStateException("Studio is not ready for hotload.");
|
||||
}
|
||||
getEngine().hotload();
|
||||
hotloadEngine();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1119,7 +1145,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
if (!initialEntryPending && !studioUpdatesPaused && shouldRunStudioHotload(isStudio(), closing, jigsawStudioActive)) {
|
||||
IrisLogging.debug("Studio update admission: world=%s wait=%dms",
|
||||
getTarget().getWorld().name(), TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - queuedAt));
|
||||
getEngine().hotload();
|
||||
hotloadEngine();
|
||||
}
|
||||
}, pending));
|
||||
}
|
||||
@@ -1129,6 +1155,9 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
Thread.currentThread().interrupt();
|
||||
throw new CancellationException("Studio hotload watcher interrupted.");
|
||||
} catch (ExecutionException failure) {
|
||||
if (RegistryRestartRequiredException.inCauseChain(failure)) {
|
||||
return;
|
||||
}
|
||||
throw new CompletionException(failure.getCause());
|
||||
} finally {
|
||||
watcherHotload.compareAndSet(pending, null);
|
||||
|
||||
@@ -86,14 +86,15 @@ public final class BulkStructureImporter {
|
||||
int skipped = 0;
|
||||
int failed = 0;
|
||||
TreeSet<String> captureCandidates = new TreeSet<>();
|
||||
ImportFeed feed = new ImportFeed(sender);
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_IMPORTING_VANILLA_DATAPACK_STRUCTURES_MODE_INCLUDENONJIGSAW, MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("mode", String.valueOf(mode)), MessageArgument.untrusted("includeNonJigsaw", String.valueOf(includeNonJigsaw))));
|
||||
feed.start(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_IMPORTING_VANILLA_DATAPACK_STRUCTURES_MODE_INCLUDENONJIGSAW, MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("mode", String.valueOf(mode)), MessageArgument.untrusted("includeNonJigsaw", String.valueOf(includeNonJigsaw))));
|
||||
|
||||
for (String keyString : vanilla) {
|
||||
NamespacedKey nk = NamespacedKey.fromString(keyString.toLowerCase());
|
||||
if (nk == null) {
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_INVALID_KEY, MessageArgument.untrusted("keyString", String.valueOf(keyString))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_INVALID_KEY, MessageArgument.untrusted("keyString", String.valueOf(keyString))));
|
||||
continue;
|
||||
}
|
||||
String name = StructureImporter.deriveName(nk);
|
||||
@@ -102,7 +103,7 @@ public final class BulkStructureImporter {
|
||||
VillageImporter.Result jigsaw = VillageImporter.importVillage(data, nk, name, mode);
|
||||
if (jigsaw.success()) {
|
||||
imported++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_JIGSAW, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("name", String.valueOf(name))));
|
||||
feed.success(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_JIGSAW, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("name", String.valueOf(name))));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -115,16 +116,16 @@ public final class BulkStructureImporter {
|
||||
StructureImporter.Result single = StructureImporter.importStructure(data, nk, name, mode);
|
||||
if (single.success()) {
|
||||
imported++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_SINGLE, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("name", String.valueOf(name))));
|
||||
feed.success(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_SINGLE, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("name", String.valueOf(name))));
|
||||
} else if (single.message() != null && single.message().startsWith("Skipped")) {
|
||||
skipped++;
|
||||
} else if (isCaptureCandidate(message, single.message())) {
|
||||
skipped++;
|
||||
captureCandidates.add(nk.toString());
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_SKIP_NO_SINGLE_TEMPLATE_NBT_VANILLA_BUILDS_THIS_CODE_FROM_SEPARATE_PIECE, MessageArgument.untrusted("keyString", String.valueOf(keyString))));
|
||||
feed.success(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_SKIP_NO_SINGLE_TEMPLATE_NBT_VANILLA_BUILDS_THIS_CODE_FROM_SEPARATE_PIECE, MessageArgument.untrusted("keyString", String.valueOf(keyString))));
|
||||
} else {
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("message", String.valueOf(single.message()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("message", String.valueOf(single.message()))));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -135,16 +136,16 @@ public final class BulkStructureImporter {
|
||||
}
|
||||
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_2, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("message", String.valueOf(message))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_2, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("message", String.valueOf(message))));
|
||||
} catch (Throwable e) {
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_3, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_3, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
}
|
||||
}
|
||||
|
||||
StructureIndexService.write(data);
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_BULK_IMPORT_COMPLETE_IMPORTED_SKIPPED_FAILED_TOTAL, MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed)), MessageArgument.untrusted("total", String.valueOf(total))));
|
||||
feed.finish(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_BULK_IMPORT_COMPLETE_IMPORTED_SKIPPED_FAILED_TOTAL, MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed)), MessageArgument.untrusted("total", String.valueOf(total))));
|
||||
return new Report(total, imported, skipped, failed, Map.of(), false, captureCandidates);
|
||||
}
|
||||
|
||||
@@ -159,28 +160,29 @@ public final class BulkStructureImporter {
|
||||
int imported = 0;
|
||||
int skipped = 0;
|
||||
int failed = 0;
|
||||
ImportFeed feed = new ImportFeed(sender);
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_BUILDING_SINGLE_TEMPLATE_STRUCTURES_FROM_IMPORTED_PIECES_ONE_VARIANT_PLACED_PER_GENERATION));
|
||||
feed.start(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_BUILDING_SINGLE_TEMPLATE_STRUCTURES_FROM_IMPORTED_PIECES_ONE_VARIANT_PLACED_PER_GENERATION));
|
||||
for (String[] g : groups) {
|
||||
try {
|
||||
StructureImporter.Result result = StructureImporter.importTemplateGroup(data, g[0], g[1], g[2], mode);
|
||||
if (result.success()) {
|
||||
imported++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_GROUP_VARIANTS, MessageArgument.untrusted("value", String.valueOf(g[1])), MessageArgument.untrusted("value2", String.valueOf(g[0])), MessageArgument.untrusted("blocks", String.valueOf(result.blocks()))));
|
||||
feed.success(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_GROUP_VARIANTS, MessageArgument.untrusted("value", String.valueOf(g[1])), MessageArgument.untrusted("value2", String.valueOf(g[0])), MessageArgument.untrusted("blocks", String.valueOf(result.blocks()))));
|
||||
} else if (result.message() != null && result.message().startsWith("Skipped")) {
|
||||
skipped++;
|
||||
} else {
|
||||
skipped++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_SKIP, MessageArgument.untrusted("value", String.valueOf(g[0])), MessageArgument.untrusted("message", String.valueOf(result.message()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_SKIP, MessageArgument.untrusted("value", String.valueOf(g[0])), MessageArgument.untrusted("message", String.valueOf(result.message()))));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_4, MessageArgument.untrusted("value", String.valueOf(g[0])), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_4, MessageArgument.untrusted("value", String.valueOf(g[0])), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
}
|
||||
}
|
||||
|
||||
StructureIndexService.write(data);
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_SINGLE_TEMPLATE_STRUCTURES_BUILT_SKIPPED_FAILED, MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed))));
|
||||
feed.finish(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_SINGLE_TEMPLATE_STRUCTURES_BUILT_SKIPPED_FAILED, MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed))));
|
||||
return new Report(groups.length, imported, skipped, failed);
|
||||
}
|
||||
|
||||
@@ -189,7 +191,7 @@ public final class BulkStructureImporter {
|
||||
try {
|
||||
templateKeys = enumerateTemplateKeys();
|
||||
} catch (Throwable e) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAILED_ENUMERATE_STRUCTURE_TEMPLATES_VIA_SERVER_RESOURCEMANAGER, MessageArgument.untrusted("e", String.valueOf(e))));
|
||||
sender.sendError(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAILED_ENUMERATE_STRUCTURE_TEMPLATES_VIA_SERVER_RESOURCEMANAGER, MessageArgument.untrusted("e", String.valueOf(e))));
|
||||
return enumerationFailureReport();
|
||||
}
|
||||
|
||||
@@ -207,17 +209,18 @@ public final class BulkStructureImporter {
|
||||
int failed = 0;
|
||||
|
||||
if (total == 0) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_NO_STRUCTURE_TEMPLATES_WERE_FOUND_UNDER_STRUCTURE_RESOURCE_PATH));
|
||||
sender.sendWarning(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_NO_STRUCTURE_TEMPLATES_WERE_FOUND_UNDER_STRUCTURE_RESOURCE_PATH));
|
||||
return new Report(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_IMPORTING_STRUCTURE_TEMPLATES_MODE, MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("mode", String.valueOf(mode))));
|
||||
ImportFeed feed = new ImportFeed(sender);
|
||||
feed.start(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_IMPORTING_STRUCTURE_TEMPLATES_MODE, MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("mode", String.valueOf(mode))));
|
||||
|
||||
for (String keyString : all) {
|
||||
NamespacedKey nk = NamespacedKey.fromString(keyString.toLowerCase());
|
||||
if (nk == null) {
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_INVALID_KEY_2, MessageArgument.untrusted("keyString", String.valueOf(keyString))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_INVALID_KEY_2, MessageArgument.untrusted("keyString", String.valueOf(keyString))));
|
||||
continue;
|
||||
}
|
||||
String name = templateNameFor(keyString);
|
||||
@@ -230,22 +233,20 @@ public final class BulkStructureImporter {
|
||||
skipped++;
|
||||
} else {
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_5, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("message", String.valueOf(result.message()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_5, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("message", String.valueOf(result.message()))));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_6, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_6, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
}
|
||||
|
||||
int processed = imported + skipped + failed;
|
||||
if (processed % 50 == 0) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_IMPORTED_SKIPPED_FAILED, MessageArgument.untrusted("processed", String.valueOf(processed)), MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed))));
|
||||
}
|
||||
feed.progress(processed, total, IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_IMPORTED_SKIPPED_FAILED, MessageArgument.untrusted("processed", String.valueOf(processed)), MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed))));
|
||||
}
|
||||
|
||||
StructureIndexService.write(data);
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_TEMPLATE_IMPORT_COMPLETE_IMPORTED_SKIPPED_FAILED_TOTAL, MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed)), MessageArgument.untrusted("total", String.valueOf(total))));
|
||||
feed.finish(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_TEMPLATE_IMPORT_COMPLETE_IMPORTED_SKIPPED_FAILED_TOTAL, MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed)), MessageArgument.untrusted("total", String.valueOf(total))));
|
||||
return new Report(total, imported, skipped, failed);
|
||||
}
|
||||
|
||||
@@ -296,19 +297,20 @@ public final class BulkStructureImporter {
|
||||
int failed = structureSelection.missing().size();
|
||||
boolean retryRequired = false;
|
||||
Map<String, String> successfulBundles = new TreeMap<>();
|
||||
ImportFeed feed = new ImportFeed(sender);
|
||||
|
||||
if (structureAttempts == 0) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_NO_DATAPACK_NON_MINECRAFT_STRUCTURES_ARE_REGISTERED_INGEST_DATAPACK_RESTART_FIRST_THEN));
|
||||
sender.sendWarning(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_NO_DATAPACK_NON_MINECRAFT_STRUCTURES_ARE_REGISTERED_INGEST_DATAPACK_RESTART_FIRST_THEN));
|
||||
} else {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_IMPORTING_DATAPACK_STRUCTURES_MODE, MessageArgument.untrusted("total", String.valueOf(structureAttempts)), MessageArgument.untrusted("mode", String.valueOf(mode))));
|
||||
feed.start(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_IMPORTING_DATAPACK_STRUCTURES_MODE, MessageArgument.untrusted("total", String.valueOf(structureAttempts)), MessageArgument.untrusted("mode", String.valueOf(mode))));
|
||||
for (String missingKey : structureSelection.missing()) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_8, MessageArgument.untrusted("keyString", missingKey), MessageArgument.untrusted("message", "allowed structure key is absent from the live registry")));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_8, MessageArgument.untrusted("keyString", missingKey), MessageArgument.untrusted("message", "allowed structure key is absent from the live registry")));
|
||||
}
|
||||
for (String keyString : datapack) {
|
||||
NamespacedKey nk = NamespacedKey.fromString(keyString.toLowerCase());
|
||||
if (nk == null) {
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_INVALID_KEY_3, MessageArgument.untrusted("keyString", String.valueOf(keyString))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_INVALID_KEY_3, MessageArgument.untrusted("keyString", String.valueOf(keyString))));
|
||||
continue;
|
||||
}
|
||||
String name = StructureImporter.deriveName(nk);
|
||||
@@ -324,7 +326,7 @@ public final class BulkStructureImporter {
|
||||
if (jigsaw.success()) {
|
||||
imported++;
|
||||
successfulBundles.put(bundleKey(name), keyString);
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_JIGSAW_2, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("name", String.valueOf(name))));
|
||||
feed.success(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_JIGSAW_2, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("name", String.valueOf(name))));
|
||||
continue;
|
||||
}
|
||||
retryRequired |= jigsaw.retryableFailure();
|
||||
@@ -342,7 +344,7 @@ public final class BulkStructureImporter {
|
||||
if (single.success()) {
|
||||
imported++;
|
||||
successfulBundles.put(bundleKey(name), keyString);
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_SINGLE_2, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("name", String.valueOf(name))));
|
||||
feed.success(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_SINGLE_2, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("name", String.valueOf(name))));
|
||||
} else if (single.message() != null && single.message().startsWith("Skipped")) {
|
||||
skipped++;
|
||||
} else if (single.message() != null && single.message().contains("No loadable structure NBT")) {
|
||||
@@ -350,7 +352,7 @@ public final class BulkStructureImporter {
|
||||
} else {
|
||||
failed++;
|
||||
retryRequired |= single.retryableFailure();
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_7, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("message", String.valueOf(single.message()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_7, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("message", String.valueOf(single.message()))));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -361,11 +363,11 @@ public final class BulkStructureImporter {
|
||||
}
|
||||
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_8, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("message", String.valueOf(message))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_8, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("message", String.valueOf(message))));
|
||||
} catch (Throwable e) {
|
||||
failed++;
|
||||
retryRequired = true;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_9, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_9, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -380,7 +382,7 @@ public final class BulkStructureImporter {
|
||||
templateAttempts++;
|
||||
failed++;
|
||||
retryRequired = true;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_COULD_NOT_ENUMERATE_DATAPACK_TEMPLATES_VIA_SERVER_RESOURCEMANAGER, MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_COULD_NOT_ENUMERATE_DATAPACK_TEMPLATES_VIA_SERVER_RESOURCEMANAGER, MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
}
|
||||
if (enumerationSucceeded) {
|
||||
KeySelection templateSelection = selectDatapackKeys(templateKeys, allowedTemplateKeys);
|
||||
@@ -388,15 +390,15 @@ public final class BulkStructureImporter {
|
||||
templateAttempts += templateSelection.total();
|
||||
failed += templateSelection.missing().size();
|
||||
for (String missingKey : templateSelection.missing()) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_10, MessageArgument.untrusted("keyString", missingKey), MessageArgument.untrusted("message", "allowed template key is absent from the live server resources")));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_10, MessageArgument.untrusted("keyString", missingKey), MessageArgument.untrusted("message", "allowed template key is absent from the live server resources")));
|
||||
}
|
||||
if (!datapackTemplates.isEmpty()) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_IMPORTING_DATAPACK_STRUCTURE_TEMPLATES, MessageArgument.untrusted("size", String.valueOf(datapackTemplates.size()))));
|
||||
feed.start(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_IMPORTING_DATAPACK_STRUCTURE_TEMPLATES, MessageArgument.untrusted("size", String.valueOf(datapackTemplates.size()))));
|
||||
for (String keyString : datapackTemplates) {
|
||||
NamespacedKey nk = NamespacedKey.fromString(keyString.toLowerCase());
|
||||
if (nk == null) {
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_INVALID_KEY_2, MessageArgument.untrusted("keyString", String.valueOf(keyString))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_INVALID_KEY_2, MessageArgument.untrusted("keyString", String.valueOf(keyString))));
|
||||
continue;
|
||||
}
|
||||
String name = templateNameFor(keyString);
|
||||
@@ -417,12 +419,12 @@ public final class BulkStructureImporter {
|
||||
} else {
|
||||
failed++;
|
||||
retryRequired |= result.retryableFailure();
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_10, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("message", String.valueOf(result.message()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_10, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("message", String.valueOf(result.message()))));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
failed++;
|
||||
retryRequired = true;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_11, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_FAIL_11, MessageArgument.untrusted("keyString", String.valueOf(keyString)), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -430,7 +432,7 @@ public final class BulkStructureImporter {
|
||||
}
|
||||
|
||||
StructureIndexService.write(data);
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_DATAPACK_STRUCTURE_IMPORT_COMPLETE_IMPORTED_SKIPPED_FAILED, MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed))));
|
||||
feed.finish(IrisLanguage.text(BukkitRuntimeMessages.BULK_STRUCTURE_IMPORTER_DATAPACK_STRUCTURE_IMPORT_COMPLETE_IMPORTED_SKIPPED_FAILED, MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed))));
|
||||
return datapackReport(
|
||||
structureAttempts,
|
||||
templateAttempts,
|
||||
|
||||
@@ -99,11 +99,12 @@ public final class FeatureImporter {
|
||||
List<Row> rows = parseRows(INMS.get().getObjectFeatureKeys());
|
||||
int total = rows.size();
|
||||
if (total == 0) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_NO_VANILLA_TREE_OBJECT_FEATURES_ARE_EXPOSED_BY_ACTIVE_NMS_BINDING_IMPORTING));
|
||||
sender.sendWarning(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_NO_VANILLA_TREE_OBJECT_FEATURES_ARE_EXPOSED_BY_ACTIVE_NMS_BINDING_IMPORTING));
|
||||
return new Report(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_IMPORTING_VANILLA_TREE_OBJECT_FEATURES_VARIANTS_EACH_INTO_SCRATCH_WORLD, MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("wantVariants", String.valueOf(wantVariants))));
|
||||
ImportFeed feed = new ImportFeed(sender);
|
||||
feed.start(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_IMPORTING_VANILLA_TREE_OBJECT_FEATURES_VARIANTS_EACH_INTO_SCRATCH_WORLD, MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("wantVariants", String.valueOf(wantVariants))));
|
||||
|
||||
World scratch = createScratchWorld(sender);
|
||||
if (scratch == null) {
|
||||
@@ -147,27 +148,25 @@ public final class FeatureImporter {
|
||||
|
||||
if (written > 0) {
|
||||
imported++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_OBJ_OBJECTS_VANILLA, MessageArgument.untrusted("key", String.valueOf(row.key())), MessageArgument.untrusted("group", String.valueOf(row.group())), MessageArgument.untrusted("safeName", String.valueOf(row.safeName())), MessageArgument.untrusted("written", String.valueOf(written))));
|
||||
feed.success(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_OBJ_OBJECTS_VANILLA, MessageArgument.untrusted("key", String.valueOf(row.key())), MessageArgument.untrusted("group", String.valueOf(row.group())), MessageArgument.untrusted("safeName", String.valueOf(row.safeName())), MessageArgument.untrusted("written", String.valueOf(written))));
|
||||
} else {
|
||||
skipped++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_SKIP_FEATURE_PLACED_NOTHING_AFTER_RETRIES, MessageArgument.untrusted("key", String.valueOf(row.key()))));
|
||||
feed.success(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_SKIP_FEATURE_PLACED_NOTHING_AFTER_RETRIES, MessageArgument.untrusted("key", String.valueOf(row.key()))));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_FAIL, MessageArgument.untrusted("key", String.valueOf(row.key())), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_FAIL, MessageArgument.untrusted("key", String.valueOf(row.key())), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
IrisLogging.reportError(e);
|
||||
}
|
||||
|
||||
int processed = imported + skipped + failed;
|
||||
if (processed % 25 == 0) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_IMPORTED_SKIPPED_FAILED, MessageArgument.untrusted("processed", String.valueOf(processed)), MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed))));
|
||||
}
|
||||
feed.progress(processed, total, IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_IMPORTED_SKIPPED_FAILED, MessageArgument.untrusted("processed", String.valueOf(processed)), MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed))));
|
||||
}
|
||||
} finally {
|
||||
destroyScratchWorld(scratch, sender);
|
||||
}
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_FEATURE_IMPORT_COMPLETE_FEATURES_WRITTEN_SKIPPED_FAILED_TOTAL, MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed)), MessageArgument.untrusted("total", String.valueOf(total))));
|
||||
feed.finish(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_FEATURE_IMPORT_COMPLETE_FEATURES_WRITTEN_SKIPPED_FAILED_TOTAL, MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed)), MessageArgument.untrusted("total", String.valueOf(total))));
|
||||
return new Report(total, imported, skipped, failed);
|
||||
}
|
||||
|
||||
@@ -371,7 +370,7 @@ public final class FeatureImporter {
|
||||
+ (reservation == null ? "unreserved" : reservation.name()) + "\".");
|
||||
}
|
||||
if (sender != null) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_COULD_NOT_CREATE_SCRATCH_WORLD_FEATURE_IMPORT_SKIPPING_TREE_OBJECT_PASS, MessageArgument.untrusted("error", String.valueOf(failure.getMessage()))));
|
||||
sender.sendError(IrisLanguage.text(BukkitRuntimeMessages.FEATURE_IMPORTER_COULD_NOT_CREATE_SCRATCH_WORLD_FEATURE_IMPORT_SKIPPING_TREE_OBJECT_PASS, MessageArgument.untrusted("error", String.valueOf(failure.getMessage()))));
|
||||
}
|
||||
return null;
|
||||
} finally {
|
||||
@@ -486,7 +485,7 @@ public final class FeatureImporter {
|
||||
state.lease().close();
|
||||
}
|
||||
if (failure != null && sender != null) {
|
||||
sender.sendMessage("Feature-import scratch world cleanup was deferred until the next startup: "
|
||||
sender.sendWarning("Feature-import scratch world cleanup was deferred until the next startup: "
|
||||
+ failure.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package art.arcane.iris.structure;
|
||||
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Chat output for a bulk import. Per-item successes only update the action bar, per-item problems are held back,
|
||||
* and {@link #finish(String)} sends one summary report that lists the problems.
|
||||
*/
|
||||
public final class ImportFeed {
|
||||
private static final int CONSOLE_PROGRESS_INTERVAL = 50;
|
||||
|
||||
private final VolmitSender sender;
|
||||
private final List<String> problems = new ArrayList<>();
|
||||
|
||||
public ImportFeed(VolmitSender sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public void start(String message) {
|
||||
sender.sendInfo(message);
|
||||
}
|
||||
|
||||
public void success(String message) {
|
||||
if (sender.isPlayer()) {
|
||||
sender.sendAction(ChatReport.Tone.SUCCESS.paint(message));
|
||||
}
|
||||
}
|
||||
|
||||
public void problem(String message) {
|
||||
problems.add(message);
|
||||
if (sender.isPlayer()) {
|
||||
sender.sendAction(ChatReport.Tone.WARNING.paint(message));
|
||||
}
|
||||
}
|
||||
|
||||
public void progress(int processed, int total, String message) {
|
||||
if (sender.isPlayer()) {
|
||||
sender.sendProgress(total <= 0 ? 1D : (double) processed / total, message);
|
||||
return;
|
||||
}
|
||||
if (processed % CONSOLE_PROGRESS_INTERVAL == 0) {
|
||||
sender.sendInfo(message);
|
||||
}
|
||||
}
|
||||
|
||||
public void finish(String summary) {
|
||||
ChatReport.Tone tone = problems.isEmpty() ? ChatReport.Tone.SUCCESS : ChatReport.Tone.WARNING;
|
||||
sender.sendReport(ChatReport.of(tone, summary).items(problems).build());
|
||||
problems.clear();
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public final class StructureCaptureImporter {
|
||||
Set<String> allowedStructureKeys) {
|
||||
StructureImporter.Mode activeMode = mode == null ? StructureImporter.Mode.ADD_ONLY : mode;
|
||||
if (!INMS.get().supportsStructureCapture()) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_STRUCTURE_CAPTURE_IS_NOT_SUPPORTED_BY_ACTIVE_NMS_BINDING_SKIPPING_CAPTURE_PASS));
|
||||
sender.sendWarning(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_STRUCTURE_CAPTURE_IS_NOT_SUPPORTED_BY_ACTIVE_NMS_BINDING_SKIPPING_CAPTURE_PASS));
|
||||
return new Report(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -84,11 +84,12 @@ public final class StructureCaptureImporter {
|
||||
|
||||
int total = targets.size();
|
||||
if (total == 0) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_NO_CODE_GENERATED_STRUCTURES_LEFT_CAPTURE_EVERYTHING_IS_ALREADY_IMPORTED_AS_STRUCTURE));
|
||||
sender.sendSuccess(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_NO_CODE_GENERATED_STRUCTURES_LEFT_CAPTURE_EVERYTHING_IS_ALREADY_IMPORTED_AS_STRUCTURE));
|
||||
return new Report(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_CAPTURING_CODE_GENERATED_STRUCTURES_NO_NBT_TEMPLATE_INTO_SCRATCH_WORLD_SKIPPING_ANY, MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("MAXSPAN", String.valueOf(MAX_SPAN))));
|
||||
ImportFeed feed = new ImportFeed(sender);
|
||||
feed.start(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_CAPTURING_CODE_GENERATED_STRUCTURES_NO_NBT_TEMPLATE_INTO_SCRATCH_WORLD_SKIPPING_ANY, MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("MAXSPAN", String.valueOf(MAX_SPAN))));
|
||||
|
||||
World scratch = FeatureImporter.createScratchWorld(sender);
|
||||
if (scratch == null) {
|
||||
@@ -107,7 +108,7 @@ public final class StructureCaptureImporter {
|
||||
IrisObject object = captureOne(scratch, key, cellIndex++);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
skipped++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_SKIP_DID_NOT_PLACE_CAPTURABLE_STRUCTURE_HERE_TOO_LARGE_WRONG_DIMENSION_NO, MessageArgument.untrusted("key", String.valueOf(key))));
|
||||
feed.success(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_SKIP_DID_NOT_PLACE_CAPTURABLE_STRUCTURE_HERE_TOO_LARGE_WRONG_DIMENSION_NO, MessageArgument.untrusted("key", String.valueOf(key))));
|
||||
continue;
|
||||
}
|
||||
object.shrinkwrap();
|
||||
@@ -115,27 +116,25 @@ public final class StructureCaptureImporter {
|
||||
data, name, key, object, "CENTER_HEIGHT", activeMode);
|
||||
if (!result.success()) {
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_FAIL, MessageArgument.untrusted("key", String.valueOf(key)), MessageArgument.untrusted("message", String.valueOf(result.message()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_FAIL, MessageArgument.untrusted("key", String.valueOf(key)), MessageArgument.untrusted("message", String.valueOf(result.message()))));
|
||||
continue;
|
||||
}
|
||||
imported++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_CAPTURE_OBJECTS_IOB_X_X, MessageArgument.untrusted("key", String.valueOf(key)), MessageArgument.untrusted("name", String.valueOf(name)), MessageArgument.untrusted("w", String.valueOf(object.getW())), MessageArgument.untrusted("h", String.valueOf(object.getH())), MessageArgument.untrusted("d", String.valueOf(object.getD()))));
|
||||
feed.success(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_CAPTURE_OBJECTS_IOB_X_X, MessageArgument.untrusted("key", String.valueOf(key)), MessageArgument.untrusted("name", String.valueOf(name)), MessageArgument.untrusted("w", String.valueOf(object.getW())), MessageArgument.untrusted("h", String.valueOf(object.getH())), MessageArgument.untrusted("d", String.valueOf(object.getD()))));
|
||||
} catch (Throwable e) {
|
||||
failed++;
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_FAIL_2, MessageArgument.untrusted("key", String.valueOf(key)), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
feed.problem(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_FAIL_2, MessageArgument.untrusted("key", String.valueOf(key)), MessageArgument.untrusted("error", String.valueOf(e.getMessage()))));
|
||||
IrisLogging.reportError(e);
|
||||
}
|
||||
|
||||
int processed = imported + skipped + failed;
|
||||
if (processed % 10 == 0) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_CAPTURED_SKIPPED_FAILED, MessageArgument.untrusted("processed", String.valueOf(processed)), MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed))));
|
||||
}
|
||||
feed.progress(processed, total, IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_CAPTURED_SKIPPED_FAILED, MessageArgument.untrusted("processed", String.valueOf(processed)), MessageArgument.untrusted("total", String.valueOf(total)), MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed))));
|
||||
}
|
||||
} finally {
|
||||
FeatureImporter.destroyScratchWorld(scratch, sender);
|
||||
}
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_STRUCTURE_CAPTURE_COMPLETE_CAPTURED_SKIPPED_FAILED_TOTAL, MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed)), MessageArgument.untrusted("total", String.valueOf(total))));
|
||||
feed.finish(IrisLanguage.text(BukkitRuntimeMessages.STRUCTURE_CAPTURE_IMPORTER_STRUCTURE_CAPTURE_COMPLETE_CAPTURED_SKIPPED_FAILED_TOTAL, MessageArgument.untrusted("imported", String.valueOf(imported)), MessageArgument.untrusted("skipped", String.valueOf(skipped)), MessageArgument.untrusted("failed", String.valueOf(failed)), MessageArgument.untrusted("total", String.valueOf(total))));
|
||||
return new Report(total, imported, skipped, failed);
|
||||
}
|
||||
|
||||
|
||||
@@ -141,8 +141,9 @@ final class ObjectBlockPass {
|
||||
|
||||
private boolean handleCustomData(NativeBlockState data, boolean air, TileData tile, String marker, int xx, int yy, int zz) {
|
||||
// Short-circuit order matters for cost only: the mantle read is paid solely
|
||||
// for vine blocks. Both operands are pure, so the value is unchanged.
|
||||
boolean wouldReplace = !is(ObjectPlaceMode.STRUCTURE_PIECE) && B.isVineBlock(data) && B.isSolid(state.placer.get(xx, yy, zz));
|
||||
// for vine blocks and leaves. Both operands are pure, so the value is unchanged.
|
||||
boolean wouldReplace = !is(ObjectPlaceMode.STRUCTURE_PIECE) && readsExistingBlock(data)
|
||||
&& keepsExisting(data, state.placer.get(xx, yy, zz));
|
||||
boolean place = shouldPlaceObjectBlock(is(ObjectPlaceMode.STRUCTURE_PIECE), air, wouldReplace);
|
||||
if (data.isCustom() || place) {
|
||||
state.placer.set(xx, yy, zz, data);
|
||||
@@ -160,6 +161,15 @@ final class ObjectBlockPass {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean readsExistingBlock(NativeBlockState data) {
|
||||
return B.isVineBlock(data) || B.isLeaves(data);
|
||||
}
|
||||
|
||||
/** Vines never replace solid blocks, and leaves never cut a log: the trunk above the cut would float. */
|
||||
static boolean keepsExisting(NativeBlockState data, NativeBlockState existing) {
|
||||
return B.isVineBlock(data) ? B.isSolid(existing) : B.isLeaves(data) && B.isLog(existing);
|
||||
}
|
||||
|
||||
private EditResult applyEdits(double[] exact, int index, NativeBlockState data, TileData tile) {
|
||||
double exactX = exact[index * 3];
|
||||
double exactY = exact[index * 3 + 1];
|
||||
|
||||
@@ -70,8 +70,7 @@ final class PlacementPalette {
|
||||
NativeBlockState resolved = decayed[entry];
|
||||
if (resolved == null) {
|
||||
NativeBlockState data = source(entry);
|
||||
resolved = preventingDecay && IrisProceduralBlocks.hasProperty(data, "distance")
|
||||
&& "false".equals(IrisProceduralBlocks.propertyValue(data, "persistent"))
|
||||
resolved = preventingDecay && "false".equals(IrisProceduralBlocks.propertyValue(data, "persistent"))
|
||||
? data.withProperty("persistent", "true") : data;
|
||||
decayed[entry] = resolved;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,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;
|
||||
@@ -152,8 +154,10 @@ public class StudioSVC implements IrisService {
|
||||
MultiBurst.ioBurst.completeValueAsync(() -> {
|
||||
String configuredPack = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||
if (!PackDownloader.isPackPresent(getWorkspaceFolder(), configuredPack)) {
|
||||
IrisLogging.warn("Default pack '" + configuredPack
|
||||
+ "' is not installed. Install a built-in pack with /iris download pack=overworld or provide /iris download link=<zip-url>.");
|
||||
ChatReport.of(ChatReport.Tone.WARNING, "Default pack '" + configuredPack + "' isn't installed")
|
||||
.nextStep("Download it", PackDownloader.downloadCommandFor(configuredPack))
|
||||
.build()
|
||||
.log();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
@@ -673,14 +677,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);
|
||||
@@ -792,7 +796,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()))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -813,22 +817,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();
|
||||
@@ -867,6 +881,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");
|
||||
@@ -882,7 +897,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))))));
|
||||
});
|
||||
@@ -984,7 +999,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;
|
||||
@@ -992,7 +1007,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;
|
||||
@@ -1000,7 +1015,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;
|
||||
@@ -1039,7 +1054,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);
|
||||
@@ -1243,7 +1258,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;
|
||||
@@ -1254,7 +1269,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;
|
||||
}
|
||||
|
||||
@@ -1282,7 +1297,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;
|
||||
}
|
||||
|
||||
@@ -1291,13 +1306,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;
|
||||
@@ -1306,10 +1323,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;
|
||||
}
|
||||
|
||||
@@ -1324,17 +1339,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);
|
||||
}
|
||||
@@ -1587,15 +1599,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("Open it: " + 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) {
|
||||
@@ -1622,7 +1649,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) {
|
||||
|
||||
@@ -10,6 +10,8 @@ import art.arcane.iris.structure.graph.StructureAssemblyResult;
|
||||
import art.arcane.iris.pack.value.IrisPosition;
|
||||
import art.arcane.iris.structure.placement.IrisStructure;
|
||||
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.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.IrisServices;
|
||||
@@ -389,7 +391,16 @@ public final class JigsawStudioService implements IrisService, JigsawStudioMenuA
|
||||
|
||||
static void message(Player player, String text) {
|
||||
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 "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-27
@@ -22,7 +22,7 @@ import art.arcane.iris.localization.BukkitRuntimeMessages;
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
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.world.task.J;
|
||||
import art.arcane.volmlib.util.format.Form;
|
||||
@@ -36,13 +36,14 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
final class StudioOpenProgressReporter {
|
||||
private static final int STUDIO_PROGRESS_BAR_WIDTH = 44;
|
||||
private static final long CONSOLE_HEARTBEAT_MILLIS = 10_000L;
|
||||
|
||||
private StudioOpenProgressReporter() {
|
||||
}
|
||||
|
||||
static void startStudioOpenReporter(VolmitSender sender, AtomicReference<String> stage, AtomicReference<Double> progress, AtomicBoolean complete, AtomicBoolean failed) {
|
||||
AtomicLong nextConsoleUpdate = new AtomicLong(0L);
|
||||
AtomicReference<String> lastConsoleStage = new AtomicReference<>("");
|
||||
AtomicLong startMs = new AtomicLong(System.currentTimeMillis());
|
||||
AtomicInteger taskId = new AtomicInteger(-1);
|
||||
org.bukkit.boss.BossBar bossBar;
|
||||
@@ -133,17 +134,17 @@ final class StudioOpenProgressReporter {
|
||||
));
|
||||
} else {
|
||||
long now = System.currentTimeMillis();
|
||||
long nextUpdate = nextConsoleUpdate.get();
|
||||
if (now >= nextUpdate) {
|
||||
String bar = buildStudioConsoleBar(currentProgress);
|
||||
boolean stageChanged = !currentStage.equals(lastConsoleStage.get());
|
||||
if (stageChanged || now >= nextConsoleUpdate.get()) {
|
||||
sender.sendMessage(IrisLanguage.text(
|
||||
RuntimeProgressMessages.STUDIO_CONSOLE_PROGRESS,
|
||||
MessageArgument.trusted("bar", bar),
|
||||
MessageArgument.trusted("bar", ProgressBar.console(currentProgress)),
|
||||
MessageArgument.trusted("percent", percent),
|
||||
MessageArgument.trusted("stage", currentStage),
|
||||
MessageArgument.trusted("elapsed", Form.duration(elapsed, 0))
|
||||
));
|
||||
nextConsoleUpdate.set(now + 1500L);
|
||||
lastConsoleStage.set(currentStage);
|
||||
nextConsoleUpdate.set(now + CONSOLE_HEARTBEAT_MILLIS);
|
||||
}
|
||||
}
|
||||
}, 3);
|
||||
@@ -155,26 +156,7 @@ final class StudioOpenProgressReporter {
|
||||
}
|
||||
|
||||
private static String buildStudioProgressBar(double progress) {
|
||||
int filled = (int) Math.round(Math.max(0.0D, Math.min(1.0D, progress)) * STUDIO_PROGRESS_BAR_WIDTH);
|
||||
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();
|
||||
return ProgressBar.player(progress);
|
||||
}
|
||||
|
||||
private static String describeStage(String stage) {
|
||||
|
||||
@@ -38,6 +38,7 @@ import art.arcane.iris.world.lifecycle.WorldLifecycleCaller;
|
||||
import art.arcane.iris.world.lifecycle.WorldLifecycleRequest;
|
||||
import art.arcane.iris.world.lifecycle.WorldLifecycleService;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.localization.ProgressBar;
|
||||
import art.arcane.iris.localization.RuntimeProgressMessages;
|
||||
import art.arcane.iris.platform.bukkit.nms.INMS;
|
||||
import art.arcane.iris.world.pregen.PregenTask;
|
||||
@@ -97,6 +98,8 @@ public class IrisCreator {
|
||||
private static final long INITIAL_SPAWN_TIMEOUT_SECONDS = 600L;
|
||||
private static final long WORLD_ENTRY_TELEPORT_TIMEOUT_SECONDS = 60L;
|
||||
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
|
||||
@@ -641,7 +644,9 @@ public class IrisCreator {
|
||||
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(() -> {
|
||||
if (done.get()) {
|
||||
cancelRepeatingTask(taskId);
|
||||
@@ -693,7 +698,7 @@ public class IrisCreator {
|
||||
WorldCreationProgressReporter creationReporter
|
||||
) {
|
||||
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(() -> {
|
||||
if (done.get()) {
|
||||
cancelRepeatingTask(taskId);
|
||||
@@ -714,17 +719,9 @@ public class IrisCreator {
|
||||
MessageArgument.trusted("percent", percent)
|
||||
), 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(
|
||||
RuntimeProgressMessages.WORLD_PREGEN_ACTION,
|
||||
MessageArgument.trusted("bar", bar.toString()),
|
||||
MessageArgument.trusted("bar", ProgressBar.player(p)),
|
||||
MessageArgument.trusted("percent", percent)
|
||||
));
|
||||
return;
|
||||
|
||||
@@ -20,7 +20,7 @@ package art.arcane.iris.world;
|
||||
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
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.world.task.J;
|
||||
import art.arcane.volmlib.util.format.Form;
|
||||
@@ -33,8 +33,6 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
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 final VolmitSender sender;
|
||||
@@ -207,11 +205,11 @@ final class WorldCreationProgressReporter {
|
||||
}
|
||||
|
||||
static String buildPlayerBar(double progress) {
|
||||
return buildBar(progress, PLAYER_BAR_WIDTH, true);
|
||||
return ProgressBar.player(progress);
|
||||
}
|
||||
|
||||
static String buildConsoleBar(double progress) {
|
||||
return buildBar(progress, CONSOLE_BAR_WIDTH, false);
|
||||
return ProgressBar.console(progress);
|
||||
}
|
||||
|
||||
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) {
|
||||
if (stage == null || stage.isBlank()) {
|
||||
|
||||
+150
-45
@@ -145,6 +145,50 @@ public final class GenerationRegistryContractFactory {
|
||||
PlatformRegistries registries,
|
||||
PlatformGenerationRegistry generationRegistry,
|
||||
CustomBiomeAliasPolicy aliasPolicy
|
||||
) throws IOException {
|
||||
return capture(data, dimension, packFingerprint, fixer, registries, generationRegistry, aliasPolicy,
|
||||
CustomBiomeSelection.CURRENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Captures a Studio update's registry contract, keeping the server's loaded definition for every custom
|
||||
* biome whose edited definition only a restart can load. Biomes the server never loaded block the update.
|
||||
*/
|
||||
public static StudioRegistryCapture createRetainingLoadedBiomes(
|
||||
IrisData data,
|
||||
IrisDimension dimension,
|
||||
String packFingerprint,
|
||||
GenerationRegistryContract loadedContract
|
||||
) throws IOException {
|
||||
PlatformRegistries registries = IrisPlatforms.get().registries();
|
||||
return createRetainingLoadedBiomes(data, dimension, packFingerprint, loadedContract,
|
||||
DataVersion.getRuntime().get(), registries, registries.generationRegistry());
|
||||
}
|
||||
|
||||
public static StudioRegistryCapture createRetainingLoadedBiomes(
|
||||
IrisData data,
|
||||
IrisDimension dimension,
|
||||
String packFingerprint,
|
||||
GenerationRegistryContract loadedContract,
|
||||
IDataFixer fixer,
|
||||
PlatformRegistries registries,
|
||||
PlatformGenerationRegistry generationRegistry
|
||||
) throws IOException {
|
||||
LoadedCustomBiomeRetention retention = new LoadedCustomBiomeRetention(loadedContract, fixer, generationRegistry);
|
||||
GenerationRegistryContract contract = capture(data, dimension, packFingerprint, fixer, registries,
|
||||
generationRegistry, CustomBiomeAliasPolicy.CONTENT_ADDRESSED_ONLY, retention);
|
||||
return retention.finish(contract);
|
||||
}
|
||||
|
||||
private static GenerationRegistryContract capture(
|
||||
IrisData data,
|
||||
IrisDimension dimension,
|
||||
String packFingerprint,
|
||||
IDataFixer fixer,
|
||||
PlatformRegistries registries,
|
||||
PlatformGenerationRegistry generationRegistry,
|
||||
CustomBiomeAliasPolicy aliasPolicy,
|
||||
CustomBiomeSelection biomeSelection
|
||||
) throws IOException {
|
||||
IrisData requiredData = Objects.requireNonNull(data, "data");
|
||||
IrisDimension requiredDimension = Objects.requireNonNull(dimension, "dimension");
|
||||
@@ -201,6 +245,7 @@ public final class GenerationRegistryContractFactory {
|
||||
requiredFixer,
|
||||
requiredGenerationRegistry,
|
||||
requiredAliasPolicy,
|
||||
biomeSelection,
|
||||
biomeTags
|
||||
);
|
||||
}
|
||||
@@ -379,30 +424,21 @@ public final class GenerationRegistryContractFactory {
|
||||
generationRegistry,
|
||||
"generationRegistry"
|
||||
);
|
||||
String selectedKey = null;
|
||||
for (Map.Entry<GenerationRegistryContract.PhysicalResourceKey, GenerationRegistryContract.GeneratedSource>
|
||||
entry : requiredContract.generatedSources().entrySet()) {
|
||||
GenerationRegistryContract.GeneratedSource source = entry.getValue();
|
||||
if (!entry.getKey().registryKey().equals(BIOME_REGISTRY)
|
||||
|| !source.sourceSchema().equals(CUSTOM_BIOME_EFFECTIVE_SOURCE_SCHEMA)) {
|
||||
continue;
|
||||
}
|
||||
String identity = fingerprintCustomBiomeIdentity(
|
||||
source.semanticSha256(),
|
||||
dimensionKey,
|
||||
customBiomeId
|
||||
List<GenerationRegistryContract.PhysicalResourceKey> recordedKeys = recordedCustomBiomeKeys(
|
||||
requiredContract,
|
||||
dimensionKey,
|
||||
customBiomeId,
|
||||
registry::customBiomeResourceKey
|
||||
);
|
||||
for (GenerationRegistryContract.PhysicalResourceKey recordedKey : recordedKeys) {
|
||||
requireGeneratedSemanticFingerprint(
|
||||
recordedKey,
|
||||
requiredContract.generatedSources().get(recordedKey),
|
||||
requiredContract.definitions().get(recordedKey)
|
||||
);
|
||||
String expectedResourceKey = registry.customBiomeResourceKey(identity);
|
||||
if (!entry.getKey().resourceKey().equals(expectedResourceKey)) {
|
||||
continue;
|
||||
}
|
||||
String expectedDefinition = requiredContract.definitions().get(entry.getKey());
|
||||
requireGeneratedSemanticFingerprint(entry.getKey(), source, expectedDefinition);
|
||||
if (selectedKey == null || expectedResourceKey.compareTo(selectedKey) < 0) {
|
||||
selectedKey = expectedResourceKey;
|
||||
}
|
||||
}
|
||||
if (selectedKey != null) {
|
||||
if (!recordedKeys.isEmpty()) {
|
||||
String selectedKey = recordedKeys.getFirst().resourceKey();
|
||||
registerCustomBiomeName(dimensionKey, customBiomeId, selectedKey);
|
||||
return selectedKey;
|
||||
}
|
||||
@@ -411,6 +447,33 @@ public final class GenerationRegistryContractFactory {
|
||||
+ requireText(customBiomeId, "Custom biome ID") + ".");
|
||||
}
|
||||
|
||||
/**
|
||||
* Every custom biome definition the contract records for one dimension's biome id, in key order. Several
|
||||
* exist when a pack gives two custom biomes the same id.
|
||||
*/
|
||||
static List<GenerationRegistryContract.PhysicalResourceKey> recordedCustomBiomeKeys(
|
||||
GenerationRegistryContract contract,
|
||||
String dimensionKey,
|
||||
String customBiomeId,
|
||||
UnaryOperator<String> resourceKeyFactory
|
||||
) {
|
||||
List<GenerationRegistryContract.PhysicalResourceKey> keys = new ArrayList<>();
|
||||
for (Map.Entry<GenerationRegistryContract.PhysicalResourceKey, GenerationRegistryContract.GeneratedSource>
|
||||
entry : contract.generatedSources().entrySet()) {
|
||||
GenerationRegistryContract.GeneratedSource source = entry.getValue();
|
||||
if (!entry.getKey().registryKey().equals(BIOME_REGISTRY)
|
||||
|| !source.sourceSchema().equals(CUSTOM_BIOME_EFFECTIVE_SOURCE_SCHEMA)) {
|
||||
continue;
|
||||
}
|
||||
String identity = fingerprintCustomBiomeIdentity(source.semanticSha256(), dimensionKey, customBiomeId);
|
||||
if (entry.getKey().resourceKey().equals(resourceKeyFactory.apply(identity))) {
|
||||
keys.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
keys.sort(null);
|
||||
return keys;
|
||||
}
|
||||
|
||||
public static String fingerprintCustomBiomeAuthoredDefinition(IrisBiomeCustom customBiome) {
|
||||
return fingerprintCustomBiomeEffectiveDefinition(customBiome, null);
|
||||
}
|
||||
@@ -746,6 +809,7 @@ public final class GenerationRegistryContractFactory {
|
||||
IDataFixer fixer,
|
||||
PlatformGenerationRegistry registry,
|
||||
CustomBiomeAliasPolicy aliasPolicy,
|
||||
CustomBiomeSelection biomeSelection,
|
||||
Map<String, Set<String>> biomeTags
|
||||
) throws IOException {
|
||||
TreeSet<String> platformBiomeKeys = new TreeSet<>();
|
||||
@@ -764,13 +828,12 @@ public final class GenerationRegistryContractFactory {
|
||||
continue;
|
||||
}
|
||||
String customBiomeId = requireText(customBiome.getId(), "Custom biome ID");
|
||||
CustomBiomeDefinition generated = customBiomeDefinition(
|
||||
data,
|
||||
dimension,
|
||||
customBiome,
|
||||
fixer,
|
||||
registry
|
||||
SelectedCustomBiome selected = biomeSelection.select(
|
||||
dimensionKey,
|
||||
customBiomeId,
|
||||
customBiomeDefinition(data, dimension, customBiome, fixer, registry)
|
||||
);
|
||||
CustomBiomeDefinition generated = selected.definition();
|
||||
putGeneratedDefinition(
|
||||
definitions,
|
||||
generatedSources,
|
||||
@@ -782,17 +845,10 @@ public final class GenerationRegistryContractFactory {
|
||||
generated.definition()
|
||||
);
|
||||
Set<String> tags = biomeTags.computeIfAbsent(generated.physicalKey().resourceKey(), ignored -> new TreeSet<>());
|
||||
for (String rawTag : customBiome.getEffectiveTags(biome.getVanillaDerivativeKey())) {
|
||||
if (rawTag == null || rawTag.isBlank()) {
|
||||
continue;
|
||||
}
|
||||
String tag = rawTag.trim().toLowerCase(Locale.ROOT);
|
||||
if (tag.indexOf(':') < 0) {
|
||||
tag = "minecraft:" + tag;
|
||||
}
|
||||
if (tag.matches("[a-z0-9_.-]+:[a-z0-9/._-]+")) {
|
||||
tags.add(tag);
|
||||
}
|
||||
if (selected.retainsLoadedDefinition()) {
|
||||
tags.addAll(selected.loadedTags());
|
||||
} else {
|
||||
addEffectiveTags(tags, customBiome, biome);
|
||||
}
|
||||
String logicalKey = dimensionKey.toLowerCase(Locale.ROOT)
|
||||
+ ":" + customBiomeId.toLowerCase(Locale.ROOT);
|
||||
@@ -844,6 +900,21 @@ public final class GenerationRegistryContractFactory {
|
||||
addPlatformDefinitions(definitions, BIOME_REGISTRY, platformBiomeKeys, registry);
|
||||
}
|
||||
|
||||
private static void addEffectiveTags(Set<String> tags, IrisBiomeCustom customBiome, IrisBiome biome) {
|
||||
for (String rawTag : customBiome.getEffectiveTags(biome.getVanillaDerivativeKey())) {
|
||||
if (rawTag == null || rawTag.isBlank()) {
|
||||
continue;
|
||||
}
|
||||
String tag = rawTag.trim().toLowerCase(Locale.ROOT);
|
||||
if (tag.indexOf(':') < 0) {
|
||||
tag = "minecraft:" + tag;
|
||||
}
|
||||
if (tag.matches("[a-z0-9_.-]+:[a-z0-9/._-]+")) {
|
||||
tags.add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addNativeStructures(
|
||||
Map<GenerationRegistryContract.PhysicalResourceKey, PlatformGenerationRegistry.Definition> definitions,
|
||||
IrisDimension dimension,
|
||||
@@ -1046,7 +1117,7 @@ public final class GenerationRegistryContractFactory {
|
||||
&& parseJson(left.semanticJson()).equals(parseJson(right.semanticJson()));
|
||||
}
|
||||
|
||||
private static PlatformGenerationRegistry.Definition canonicalGeneratedDefinition(
|
||||
static PlatformGenerationRegistry.Definition canonicalGeneratedDefinition(
|
||||
GenerationRegistryContract.PhysicalResourceKey key,
|
||||
GenerationRegistryContract.GeneratedSource source,
|
||||
IDataFixer fixer,
|
||||
@@ -1629,13 +1700,26 @@ public final class GenerationRegistryContractFactory {
|
||||
GenerationRegistryContract.PhysicalResourceKey physicalKey = key(BIOME_REGISTRY, resourceKey);
|
||||
GenerationRegistryContract.GeneratedSource source = contract.generatedSources().get(physicalKey);
|
||||
if (source == null || !semanticFingerprint.equals(source.semanticSha256())) {
|
||||
throw new IOException("Historical generation registry contract has no exact custom biome definition for "
|
||||
+ dimension + ":" + requiredBiome.getId() + ".");
|
||||
physicalKey = requireSoleRecordedKey(dimension, requiredBiome.getId());
|
||||
source = contract.generatedSources().get(physicalKey);
|
||||
}
|
||||
requireGeneratedSemanticFingerprint(physicalKey, source, contract.definitions().get(physicalKey));
|
||||
registerCustomBiomeName(dimension, requiredBiome.getId(), resourceKey);
|
||||
dimensionKeys.put(requiredBiome, resourceKey);
|
||||
return resourceKey;
|
||||
registerCustomBiomeName(dimension, requiredBiome.getId(), physicalKey.resourceKey());
|
||||
dimensionKeys.put(requiredBiome, physicalKey.resourceKey());
|
||||
return physicalKey.resourceKey();
|
||||
}
|
||||
|
||||
// A Studio update keeps the server's loaded definition for an edited biome until restart, so its epoch
|
||||
// records that definition instead of the pack's. The biome id then names exactly one recorded definition.
|
||||
private GenerationRegistryContract.PhysicalResourceKey requireSoleRecordedKey(String dimension, String biomeId)
|
||||
throws IOException {
|
||||
List<GenerationRegistryContract.PhysicalResourceKey> recorded = recordedCustomBiomeKeys(
|
||||
contract, dimension, biomeId, resourceKeyFactory);
|
||||
if (recorded.size() != 1) {
|
||||
throw new IOException("Historical generation registry contract has no exact custom biome definition for "
|
||||
+ dimension + ":" + biomeId + ".");
|
||||
}
|
||||
return recorded.getFirst();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1670,4 +1754,25 @@ public final class GenerationRegistryContractFactory {
|
||||
|
||||
private record ReferencedPlatformKeys(Set<String> blockKeys, Set<String> entityKeys) {
|
||||
}
|
||||
|
||||
interface CustomBiomeSelection {
|
||||
CustomBiomeSelection CURRENT = (dimensionKey, customBiomeId, current) -> SelectedCustomBiome.current(current);
|
||||
|
||||
SelectedCustomBiome select(String dimensionKey, String customBiomeId, CustomBiomeDefinition current)
|
||||
throws IOException;
|
||||
}
|
||||
|
||||
record SelectedCustomBiome(CustomBiomeDefinition definition, Collection<String> loadedTags) {
|
||||
static SelectedCustomBiome current(CustomBiomeDefinition definition) {
|
||||
return new SelectedCustomBiome(definition, null);
|
||||
}
|
||||
|
||||
static SelectedCustomBiome loaded(CustomBiomeDefinition definition, Collection<String> tags) {
|
||||
return new SelectedCustomBiome(definition, List.copyOf(tags));
|
||||
}
|
||||
|
||||
boolean retainsLoadedDefinition() {
|
||||
return loadedTags != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package art.arcane.iris.world.history;
|
||||
|
||||
import art.arcane.iris.pack.datapack.IDataFixer;
|
||||
import art.arcane.iris.spi.PlatformGenerationRegistry;
|
||||
import art.arcane.iris.world.history.GenerationRegistryContractFactory.CustomBiomeDefinition;
|
||||
import art.arcane.iris.world.history.GenerationRegistryContractFactory.CustomBiomeSelection;
|
||||
import art.arcane.iris.world.history.GenerationRegistryContractFactory.SelectedCustomBiome;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* Picks, for each custom biome of a Studio update, a definition the running server has loaded: the edited one
|
||||
* when the server already has it, otherwise the definition the active epoch recorded for the same biome id.
|
||||
* Biomes with neither are collected and block the update.
|
||||
*/
|
||||
final class LoadedCustomBiomeRetention implements CustomBiomeSelection {
|
||||
private static final String GENERATED_RENDERER = "generated";
|
||||
|
||||
private final GenerationRegistryContract loadedContract;
|
||||
private final IDataFixer fixer;
|
||||
private final PlatformGenerationRegistry registry;
|
||||
private final Map<String, BiomeIdentity> deferred = new TreeMap<>();
|
||||
private final TreeSet<String> blocking = new TreeSet<>();
|
||||
|
||||
LoadedCustomBiomeRetention(
|
||||
GenerationRegistryContract loadedContract,
|
||||
IDataFixer fixer,
|
||||
PlatformGenerationRegistry registry
|
||||
) {
|
||||
this.loadedContract = Objects.requireNonNull(loadedContract, "loadedContract");
|
||||
this.fixer = Objects.requireNonNull(fixer, "fixer");
|
||||
this.registry = Objects.requireNonNull(registry, "registry");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectedCustomBiome select(String dimensionKey, String customBiomeId, CustomBiomeDefinition current)
|
||||
throws IOException {
|
||||
if (isLoaded(current)) {
|
||||
return SelectedCustomBiome.current(current);
|
||||
}
|
||||
BiomeIdentity identity = new BiomeIdentity(dimensionKey, customBiomeId);
|
||||
List<GenerationRegistryContract.PhysicalResourceKey> loadedKeys = recordedKeys(loadedContract, identity);
|
||||
if (loadedKeys.size() != 1) {
|
||||
blocking.add(identity.label());
|
||||
return SelectedCustomBiome.current(current);
|
||||
}
|
||||
GenerationRegistryContract.PhysicalResourceKey loadedKey = loadedKeys.getFirst();
|
||||
CustomBiomeDefinition loaded = loadedDefinition(loadedKey, identity);
|
||||
if (!isLoaded(loaded)) {
|
||||
blocking.add(identity.label());
|
||||
return SelectedCustomBiome.current(current);
|
||||
}
|
||||
deferred.put(identity.logicalKey(), identity);
|
||||
return SelectedCustomBiome.loaded(
|
||||
loaded,
|
||||
loadedContract.biomeTags().getOrDefault(loadedKey.resourceKey(), List.of())
|
||||
);
|
||||
}
|
||||
|
||||
StudioRegistryCapture finish(GenerationRegistryContract contract) throws RegistryRestartRequiredException {
|
||||
TreeSet<String> deferredLabels = new TreeSet<>();
|
||||
for (BiomeIdentity identity : deferred.values()) {
|
||||
if (recordedKeys(contract, identity).size() == 1) {
|
||||
deferredLabels.add(identity.label());
|
||||
} else {
|
||||
blocking.add(identity.label());
|
||||
}
|
||||
}
|
||||
if (!blocking.isEmpty()) {
|
||||
throw new RegistryRestartRequiredException(List.copyOf(blocking), List.copyOf(deferredLabels));
|
||||
}
|
||||
return new StudioRegistryCapture(contract, List.copyOf(deferredLabels));
|
||||
}
|
||||
|
||||
private List<GenerationRegistryContract.PhysicalResourceKey> recordedKeys(
|
||||
GenerationRegistryContract contract,
|
||||
BiomeIdentity identity
|
||||
) {
|
||||
return GenerationRegistryContractFactory.recordedCustomBiomeKeys(
|
||||
contract, identity.dimensionKey(), identity.biomeId(), registry::customBiomeResourceKey);
|
||||
}
|
||||
|
||||
private CustomBiomeDefinition loadedDefinition(
|
||||
GenerationRegistryContract.PhysicalResourceKey key,
|
||||
BiomeIdentity identity
|
||||
) throws IOException {
|
||||
GenerationRegistryContract.GeneratedSource source = loadedContract.generatedSources().get(key);
|
||||
PlatformGenerationRegistry.Definition definition =
|
||||
GenerationRegistryContractFactory.canonicalGeneratedDefinition(key, source, fixer, registry);
|
||||
return new CustomBiomeDefinition(
|
||||
key,
|
||||
GenerationRegistryContractFactory.fingerprintCustomBiomeIdentity(
|
||||
source.semanticSha256(), identity.dimensionKey(), identity.biomeId()),
|
||||
source.semanticSha256(),
|
||||
source.semanticJson(),
|
||||
GenerationRegistryContractFactory.fingerprintCustomBiomeDefinition(definition.value()),
|
||||
definition.value(),
|
||||
definition
|
||||
);
|
||||
}
|
||||
|
||||
private boolean isLoaded(CustomBiomeDefinition definition) {
|
||||
GenerationRegistryContract.PhysicalResourceKey key = definition.physicalKey();
|
||||
PlatformGenerationRegistry.Definition live;
|
||||
try {
|
||||
live = registry.generatedDefinition(key.registryKey(), key.resourceKey());
|
||||
} catch (RuntimeException missing) {
|
||||
return false;
|
||||
}
|
||||
if (live == null || live.encoding() != PlatformGenerationRegistry.Encoding.JSON) {
|
||||
return false;
|
||||
}
|
||||
return GenerationRegistryContractFactory.fingerprintDefinition(key, live, GENERATED_RENDERER)
|
||||
.equals(GenerationRegistryContractFactory.fingerprintDefinition(
|
||||
key, definition.definition(), GENERATED_RENDERER));
|
||||
}
|
||||
|
||||
private record BiomeIdentity(String dimensionKey, String biomeId) {
|
||||
String logicalKey() {
|
||||
return dimensionKey.toLowerCase(Locale.ROOT) + ":" + biomeId.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
String label() {
|
||||
return biomeId.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package art.arcane.iris.world.history;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A Studio update references custom biomes the running server has no definition for, so only a restart can
|
||||
* apply it.
|
||||
*/
|
||||
public final class RegistryRestartRequiredException extends IOException {
|
||||
private final List<String> blockingBiomes;
|
||||
private final List<String> deferredBiomes;
|
||||
|
||||
public RegistryRestartRequiredException(List<String> blockingBiomes, List<String> deferredBiomes) {
|
||||
super("Restart needed to load biomes: " + String.join(", ", blockingBiomes));
|
||||
this.blockingBiomes = List.copyOf(blockingBiomes);
|
||||
this.deferredBiomes = List.copyOf(deferredBiomes);
|
||||
}
|
||||
|
||||
public static boolean inCauseChain(Throwable failure) {
|
||||
for (Throwable cause = failure; cause != null; cause = cause.getCause()) {
|
||||
if (cause instanceof RegistryRestartRequiredException) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String> blockingBiomes() {
|
||||
return blockingBiomes;
|
||||
}
|
||||
|
||||
public List<String> deferredBiomes() {
|
||||
return deferredBiomes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package art.arcane.iris.world.history;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A Studio update's registry contract and the custom biomes it keeps at their loaded definition until restart.
|
||||
*/
|
||||
public record StudioRegistryCapture(GenerationRegistryContract contract, List<String> deferredBiomes) {
|
||||
public StudioRegistryCapture {
|
||||
contract = Objects.requireNonNull(contract, "contract");
|
||||
deferredBiomes = List.copyOf(deferredBiomes);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
|
||||
import art.arcane.iris.world.task.J;
|
||||
import art.arcane.volmlib.util.format.Form;
|
||||
import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
import art.arcane.volmlib.util.localization.TextKey;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.boss.BarColor;
|
||||
@@ -54,8 +55,10 @@ public final class ChunkJobReporter {
|
||||
private final AtomicReference<Double> progress = new AtomicReference<>(0.0D);
|
||||
private final AtomicBoolean complete = new AtomicBoolean(false);
|
||||
private final AtomicBoolean failed = new AtomicBoolean(false);
|
||||
private final AtomicBoolean stopped = new AtomicBoolean(false);
|
||||
private final AtomicInteger applied = new AtomicInteger(0);
|
||||
private final AtomicInteger failures = new AtomicInteger(0);
|
||||
private final AtomicInteger skipped = new AtomicInteger(0);
|
||||
private volatile int total = 0;
|
||||
private volatile long startMs = 0L;
|
||||
|
||||
@@ -89,18 +92,45 @@ public final class ChunkJobReporter {
|
||||
failures.incrementAndGet();
|
||||
}
|
||||
|
||||
int finished = applied.get() + failures.get();
|
||||
updateProgress();
|
||||
}
|
||||
|
||||
/** A chunk the job had nothing to do for. It leaves the total, so the summary only counts chunks the job worked on. */
|
||||
public void countSkipped() {
|
||||
skipped.incrementAndGet();
|
||||
updateProgress();
|
||||
}
|
||||
|
||||
private void updateProgress() {
|
||||
int finished = applied.get() + failures.get() + skipped.get();
|
||||
if (total > 0) {
|
||||
progress.set(Math.min(0.999D, (double) finished / total));
|
||||
}
|
||||
}
|
||||
|
||||
public void finish(boolean error) {
|
||||
finish(error, false);
|
||||
}
|
||||
|
||||
public void finish(boolean error, boolean stoppedEarly) {
|
||||
progress.set(1.0D);
|
||||
failed.set(error || (applied.get() == 0 && total > 0));
|
||||
stopped.set(stoppedEarly && !error);
|
||||
failed.set(error || (!stoppedEarly && applied.get() == 0 && workedTotal() > 0));
|
||||
complete.set(true);
|
||||
}
|
||||
|
||||
public int total() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public int skipped() {
|
||||
return skipped.get();
|
||||
}
|
||||
|
||||
private int workedTotal() {
|
||||
return total - skipped.get();
|
||||
}
|
||||
|
||||
public int applied() {
|
||||
return applied.get();
|
||||
}
|
||||
@@ -151,7 +181,7 @@ public final class ChunkJobReporter {
|
||||
MessageArgument.trusted("percent", percent),
|
||||
MessageArgument.trusted("stage", stage.get()),
|
||||
MessageArgument.trusted("applied", applied.get()),
|
||||
MessageArgument.trusted("total", total <= 0 ? "?" : total)
|
||||
MessageArgument.trusted("total", total <= 0 ? "?" : workedTotal())
|
||||
));
|
||||
}
|
||||
}, REPORT_INTERVAL_TICKS));
|
||||
@@ -161,27 +191,27 @@ public final class ChunkJobReporter {
|
||||
}
|
||||
|
||||
private void finishReporter(BossBar bossBar, long elapsed) {
|
||||
boolean ok = !failed.get();
|
||||
Outcome outcome = stopped.get() ? Outcome.STOPPED : failed.get() ? Outcome.FAILED : Outcome.DONE;
|
||||
String summary = failures.get() > 0
|
||||
? IrisLanguage.text(
|
||||
RuntimeProgressMessages.CHUNK_SUMMARY_FAILED,
|
||||
MessageArgument.trusted("applied", applied.get()),
|
||||
MessageArgument.trusted("total", total),
|
||||
MessageArgument.trusted("total", workedTotal()),
|
||||
MessageArgument.trusted("elapsed", Form.duration(elapsed, 1)),
|
||||
MessageArgument.trusted("failures", failures.get())
|
||||
)
|
||||
: IrisLanguage.text(
|
||||
RuntimeProgressMessages.CHUNK_SUMMARY,
|
||||
MessageArgument.trusted("applied", applied.get()),
|
||||
MessageArgument.trusted("total", total),
|
||||
MessageArgument.trusted("total", workedTotal()),
|
||||
MessageArgument.trusted("elapsed", Form.duration(elapsed, 1))
|
||||
);
|
||||
|
||||
if (bossBar != null) {
|
||||
bossBar.setProgress(1.0D);
|
||||
bossBar.setColor(ok ? BarColor.GREEN : BarColor.RED);
|
||||
bossBar.setColor(outcome.barColor);
|
||||
bossBar.setTitle(IrisLanguage.text(
|
||||
ok ? RuntimeProgressMessages.CHUNK_BOSSBAR_DONE : RuntimeProgressMessages.CHUNK_BOSSBAR_FAILED,
|
||||
outcome.bossBarKey,
|
||||
MessageArgument.trusted("title", title),
|
||||
MessageArgument.trusted("summary", summary)
|
||||
));
|
||||
@@ -193,13 +223,13 @@ public final class ChunkJobReporter {
|
||||
|
||||
if (sender.isPlayer()) {
|
||||
sender.sendAction(IrisLanguage.text(
|
||||
ok ? RuntimeProgressMessages.CHUNK_ACTION_DONE : RuntimeProgressMessages.CHUNK_ACTION_FAILED,
|
||||
outcome.actionKey,
|
||||
MessageArgument.trusted("bar", progressBar(1.0D)),
|
||||
MessageArgument.trusted("summary", summary)
|
||||
));
|
||||
}
|
||||
sender.sendMessage(IrisLanguage.text(
|
||||
ok ? RuntimeProgressMessages.CHUNK_COMPLETE : RuntimeProgressMessages.CHUNK_FAILED,
|
||||
outcome.chatKey,
|
||||
MessageArgument.trusted("title", title),
|
||||
MessageArgument.trusted("summary", summary)
|
||||
));
|
||||
@@ -215,4 +245,22 @@ public final class ChunkJobReporter {
|
||||
bar.append(C.DARK_GRAY).append("]");
|
||||
return bar.toString();
|
||||
}
|
||||
|
||||
private enum Outcome {
|
||||
DONE(BarColor.GREEN, RuntimeProgressMessages.CHUNK_BOSSBAR_DONE, RuntimeProgressMessages.CHUNK_ACTION_DONE, RuntimeProgressMessages.CHUNK_COMPLETE),
|
||||
STOPPED(BarColor.YELLOW, RuntimeProgressMessages.CHUNK_BOSSBAR_STOPPED, RuntimeProgressMessages.CHUNK_ACTION_STOPPED, RuntimeProgressMessages.CHUNK_STOPPED),
|
||||
FAILED(BarColor.RED, RuntimeProgressMessages.CHUNK_BOSSBAR_FAILED, RuntimeProgressMessages.CHUNK_ACTION_FAILED, RuntimeProgressMessages.CHUNK_FAILED);
|
||||
|
||||
private final BarColor barColor;
|
||||
private final TextKey bossBarKey;
|
||||
private final TextKey actionKey;
|
||||
private final TextKey chatKey;
|
||||
|
||||
Outcome(BarColor barColor, TextKey bossBarKey, TextKey actionKey, TextKey chatKey) {
|
||||
this.barColor = barColor;
|
||||
this.bossBarKey = bossBarKey;
|
||||
this.actionKey = actionKey;
|
||||
this.chatKey = chatKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,13 @@ import art.arcane.iris.platform.bukkit.nms.INMS;
|
||||
import art.arcane.iris.generation.chunk.TerrainChunk;
|
||||
import art.arcane.iris.generation.chunk.ChunkDataHunkView;
|
||||
import art.arcane.iris.generation.chunk.TerrainChunkBiomeHunkView;
|
||||
import art.arcane.iris.platform.bukkit.BukkitPlatform;
|
||||
import art.arcane.iris.platform.generation.BukkitChunkGenerator;
|
||||
import art.arcane.iris.platform.generation.BukkitChunkGenerator.GenerationStagePermit;
|
||||
import art.arcane.iris.platform.generation.EngineBukkitOps;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.WrongEngineBroException;
|
||||
import art.arcane.iris.world.IrisToolbelt;
|
||||
import art.arcane.iris.generation.mantle.EngineMantle;
|
||||
import art.arcane.iris.generation.mantle.DeferredPlacementRecords;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBiome;
|
||||
@@ -46,8 +51,14 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Consumer;
|
||||
@@ -55,6 +66,9 @@ import java.util.function.Consumer;
|
||||
public final class InPlaceChunkRegenerator {
|
||||
private static final int BIOME_STEP = 4;
|
||||
private static final int APPLY_AHEAD = 8;
|
||||
private static final int PROBE_BATCH_CHUNKS = 256;
|
||||
private static final String GENERATION_STAGE = "regen";
|
||||
private static final ConcurrentMap<String, InPlaceChunkRegenerator> ACTIVE_BY_WORLD = new ConcurrentHashMap<>();
|
||||
|
||||
private final World world;
|
||||
private final Engine engine;
|
||||
@@ -62,6 +76,7 @@ public final class InPlaceChunkRegenerator {
|
||||
private final int centerChunkZ;
|
||||
private final int radius;
|
||||
private final ChunkJobReporter reporter;
|
||||
private final AtomicBoolean stopRequested = new AtomicBoolean();
|
||||
|
||||
public InPlaceChunkRegenerator(World world, Engine engine, VolmitSender sender, int centerChunkX, int centerChunkZ, int radius) {
|
||||
this.world = world;
|
||||
@@ -72,11 +87,35 @@ public final class InPlaceChunkRegenerator {
|
||||
this.reporter = new ChunkJobReporter(sender, IrisLanguage.text(RuntimeProgressMessages.CHUNK_TITLE_REGEN), world);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
public static Optional<InPlaceChunkRegenerator> activeIn(World world) {
|
||||
return Optional.ofNullable(ACTIVE_BY_WORLD.get(world.getName()));
|
||||
}
|
||||
|
||||
/** Starts the regen unless one is already running in this world; overlapping regens fight over the same mantle. */
|
||||
public boolean start() {
|
||||
if (ACTIVE_BY_WORLD.putIfAbsent(world.getName(), this) != null) {
|
||||
return false;
|
||||
}
|
||||
reporter.start();
|
||||
Thread thread = new Thread(this::run, "Iris Regenerate");
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Stops queueing chunks; chunks already generating still finish so none is left half-applied. */
|
||||
public void requestStop() {
|
||||
if (stopRequested.compareAndSet(false, true)) {
|
||||
reporter.setStage(IrisLanguage.text(RuntimeProgressMessages.CHUNK_STAGE_STOPPING));
|
||||
}
|
||||
}
|
||||
|
||||
public int appliedChunks() {
|
||||
return reporter.applied();
|
||||
}
|
||||
|
||||
public int totalChunks() {
|
||||
return reporter.total();
|
||||
}
|
||||
|
||||
private void run() {
|
||||
@@ -87,16 +126,28 @@ public final class InPlaceChunkRegenerator {
|
||||
|
||||
List<int[]> targets = ChunkJobReporter.orderedTargets(centerChunkX, centerChunkZ, radius);
|
||||
reporter.setTotal(targets.size());
|
||||
reporter.setStage(IrisLanguage.text(RuntimeProgressMessages.CHUNK_STAGE_REGENERATING));
|
||||
if (!stopRequested.get()) {
|
||||
reporter.setStage(IrisLanguage.text(RuntimeProgressMessages.CHUNK_STAGE_REGENERATING));
|
||||
}
|
||||
regenerate(targets);
|
||||
logSkippedChunks();
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
error = true;
|
||||
} finally {
|
||||
reporter.finish(error);
|
||||
ACTIVE_BY_WORLD.remove(world.getName(), this);
|
||||
reporter.finish(error, stopRequested.get());
|
||||
}
|
||||
}
|
||||
|
||||
private void logSkippedChunks() {
|
||||
if (reporter.skipped() == 0) {
|
||||
return;
|
||||
}
|
||||
IrisLogging.info("Regen skipped " + reporter.skipped() + " chunks in " + world.getName()
|
||||
+ " that were never generated; they generate fresh when visited.");
|
||||
}
|
||||
|
||||
private void resetMantleMargin() {
|
||||
EngineMantle engineMantle = engine.getMantle();
|
||||
Mantle<Matter> mantle = engineMantle.getMantle();
|
||||
@@ -111,59 +162,136 @@ public final class InPlaceChunkRegenerator {
|
||||
|
||||
private void regenerate(List<int[]> targets) throws InterruptedException {
|
||||
Semaphore inFlight = new Semaphore(APPLY_AHEAD);
|
||||
CountDownLatch allApplied = new CountDownLatch(targets.size());
|
||||
|
||||
for (int[] target : targets) {
|
||||
int chunkX = target[0];
|
||||
int chunkZ = target[1];
|
||||
for (int from = 0; from < targets.size() && !stopRequested.get(); from += PROBE_BATCH_CHUNKS) {
|
||||
List<int[]> batch = targets.subList(from, Math.min(targets.size(), from + PROBE_BATCH_CHUNKS));
|
||||
for (int[] generated : generatedChunksOf(batch)) {
|
||||
if (stopRequested.get()) {
|
||||
break;
|
||||
}
|
||||
inFlight.acquire();
|
||||
MultiBurst.burst.lazy(() -> regenerateChunk(generated[0], generated[1], inFlight::release));
|
||||
}
|
||||
}
|
||||
|
||||
inFlight.acquire();
|
||||
MultiBurst.burst.lazy(() -> {
|
||||
// Settle exactly once no matter which path fails: an unguarded throw here
|
||||
// (TerrainChunk.create, runRegion) parked the regen thread on the latch
|
||||
// forever and stranded the player's boss bar. CAS is required — on Folia's
|
||||
// owned-region path runRegion runs the apply inline before returning.
|
||||
AtomicBoolean settled = new AtomicBoolean();
|
||||
Consumer<Boolean> settle = ok -> {
|
||||
if (settled.compareAndSet(false, true)) {
|
||||
reporter.countApplied(ok);
|
||||
inFlight.release();
|
||||
allApplied.countDown();
|
||||
}
|
||||
};
|
||||
try {
|
||||
TerrainChunk buffer = TerrainChunk.create(world);
|
||||
engine.generate(chunkX << 4, chunkZ << 4, new ChunkDataHunkView(buffer.getChunkData()),
|
||||
new TerrainChunkBiomeHunkView(buffer), false);
|
||||
inFlight.acquire(APPLY_AHEAD);
|
||||
}
|
||||
|
||||
boolean scheduled = J.runRegion(world, chunkX, chunkZ, () -> {
|
||||
boolean ok = false;
|
||||
try {
|
||||
applyToLiveChunk(chunkX, chunkZ, buffer);
|
||||
ok = true;
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
} finally {
|
||||
settle.accept(ok);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Chunks that were never generated are skipped: their mantle is reset, so they generate fresh when first visited.
|
||||
* Regenerating them here would generate each one twice, and loading them on the server thread stalls it.
|
||||
*/
|
||||
private List<int[]> generatedChunksOf(List<int[]> batch) {
|
||||
List<CompletableFuture<Chunk>> loads = new ArrayList<>(batch.size());
|
||||
for (int[] target : batch) {
|
||||
loads.add(loadIfGenerated(target[0], target[1]));
|
||||
}
|
||||
|
||||
if (!scheduled) {
|
||||
IrisLogging.warn("Regen could not schedule chunk apply at " + chunkX + "," + chunkZ + " in " + world.getName() + ".");
|
||||
settle.accept(false);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
List<int[]> generated = new ArrayList<>(batch.size());
|
||||
for (int index = 0; index < batch.size(); index++) {
|
||||
try {
|
||||
if (loads.get(index).join() == null) {
|
||||
reporter.countSkipped();
|
||||
continue;
|
||||
}
|
||||
generated.add(batch.get(index));
|
||||
} catch (CompletionException | CancellationException e) {
|
||||
IrisLogging.reportError(e);
|
||||
reporter.countApplied(false);
|
||||
}
|
||||
}
|
||||
return generated;
|
||||
}
|
||||
|
||||
/** Spigot has no async chunk loading, so its fallback loads in place; that must happen on the server thread. */
|
||||
private CompletableFuture<Chunk> loadIfGenerated(int chunkX, int chunkZ) {
|
||||
if (BukkitPlatform.isPaperServer()) {
|
||||
return BukkitPlatform.chunkAtAsync(world, chunkX, chunkZ, false);
|
||||
}
|
||||
return J.sfut(() -> BukkitPlatform.chunkAtAsync(world, chunkX, chunkZ, false)).thenCompose(load -> load);
|
||||
}
|
||||
|
||||
private void regenerateChunk(int chunkX, int chunkZ, Runnable release) {
|
||||
// Settle exactly once no matter which path fails: an unguarded throw stranded the regen thread and the
|
||||
// player's boss bar. CAS is required because the apply can run inline, before the scheduling call returns.
|
||||
AtomicBoolean settled = new AtomicBoolean();
|
||||
Consumer<Boolean> settle = ok -> {
|
||||
if (settled.compareAndSet(false, true)) {
|
||||
reporter.countApplied(ok);
|
||||
release.run();
|
||||
}
|
||||
};
|
||||
try {
|
||||
TerrainChunk buffer = generate(chunkX, chunkZ);
|
||||
loadIfGenerated(chunkX, chunkZ).whenComplete((chunk, loadFailure) -> {
|
||||
if (loadFailure != null) {
|
||||
IrisLogging.reportError(loadFailure);
|
||||
}
|
||||
if (!scheduledApply(chunk, buffer, settle)) {
|
||||
settle.accept(false);
|
||||
}
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
settle.accept(false);
|
||||
}
|
||||
|
||||
allApplied.await();
|
||||
}
|
||||
|
||||
private void applyToLiveChunk(int chunkX, int chunkZ, TerrainChunk buffer) {
|
||||
Chunk chunk = world.getChunkAt(chunkX, chunkZ);
|
||||
/**
|
||||
* @return false when the apply could not be handed to the thread owning the chunk, so the caller settles the chunk
|
||||
* as failed; true leaves settling to the apply.
|
||||
*/
|
||||
private boolean scheduledApply(Chunk chunk, TerrainChunk buffer, Consumer<Boolean> settle) {
|
||||
if (chunk == null) {
|
||||
IrisLogging.warn("Regen could not load a chunk it found generated in " + world.getName() + ".");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return runOnThreadOwning(chunk, () -> settle.accept(applied(chunk, buffer)));
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Holds a generation stage like any chunk the server generates, so a hotload waits for it instead of rejecting it. */
|
||||
private TerrainChunk generate(int chunkX, int chunkZ) throws WrongEngineBroException {
|
||||
TerrainChunk buffer = TerrainChunk.create(world);
|
||||
try (GenerationStagePermit ignored = acquireGenerationStage()) {
|
||||
engine.generate(chunkX << 4, chunkZ << 4, new ChunkDataHunkView(buffer.getChunkData()),
|
||||
new TerrainChunkBiomeHunkView(buffer), false);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private GenerationStagePermit acquireGenerationStage() {
|
||||
if (IrisToolbelt.access(world) instanceof BukkitChunkGenerator generator) {
|
||||
return generator.acquireGenerationStage(GENERATION_STAGE);
|
||||
}
|
||||
return GenerationStagePermit.noop();
|
||||
}
|
||||
|
||||
private boolean runOnThreadOwning(Chunk chunk, Runnable task) {
|
||||
if (!J.isFolia() && J.isPrimaryThread()) {
|
||||
task.run();
|
||||
return true;
|
||||
}
|
||||
return J.runRegion(world, chunk.getX(), chunk.getZ(), task);
|
||||
}
|
||||
|
||||
private boolean applied(Chunk chunk, TerrainChunk buffer) {
|
||||
try {
|
||||
applyToLiveChunk(chunk, buffer);
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void applyToLiveChunk(Chunk chunk, TerrainChunk buffer) {
|
||||
int chunkX = chunk.getX();
|
||||
int chunkZ = chunk.getZ();
|
||||
for (Entity entity : chunk.getEntities()) {
|
||||
if (!(entity instanceof Player)) {
|
||||
entity.remove();
|
||||
|
||||
@@ -2,7 +2,7 @@ package art.arcane.iris.world.safeguard;
|
||||
|
||||
import art.arcane.iris.world.IrisStartupValidation;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -105,21 +105,29 @@ public final class IrisSafeguard {
|
||||
|
||||
public static void printReports() {
|
||||
switch (mode) {
|
||||
case STABLE -> IrisLogging.info(C.BLUE + "0 Conflicts found");
|
||||
case WARNING -> IrisLogging.warn(C.GOLD + "%s Issues found", count);
|
||||
case UNSTABLE -> IrisLogging.error(C.DARK_RED + "%s Issues found", count);
|
||||
case STABLE -> {
|
||||
}
|
||||
case WARNING -> IrisLogging.warn(issueCountLine());
|
||||
case UNSTABLE -> IrisLogging.error(issueCountLine());
|
||||
}
|
||||
|
||||
for (CheckResult value : results.values()) {
|
||||
if (value.mode() == Mode.STABLE) {
|
||||
continue;
|
||||
}
|
||||
// Without the stack trace: Diagnostic.Logger splits on newlines, so a trace became one log
|
||||
// record per frame at the diagnostic's own severity. Traces go through reportError.
|
||||
value.log(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
private static String issueCountLine() {
|
||||
return count == 1 ? "1 startup issue" : count + " startup issues";
|
||||
}
|
||||
|
||||
public static void printFooter() {
|
||||
switch (mode) {
|
||||
case STABLE -> IrisLogging.info(C.BLUE + "Iris is running Stable");
|
||||
case STABLE -> IrisLogging.info(ChatReport.Tone.SUCCESS.marked(ChatReport.Tone.SUCCESS.consolePaint("Stable, no conflicts")));
|
||||
case WARNING -> warning();
|
||||
case UNSTABLE -> unstable();
|
||||
}
|
||||
@@ -133,14 +141,18 @@ public final class IrisSafeguard {
|
||||
// A log record carries a level, so a blank record renders as an empty [WARN] line and a rule of
|
||||
// dashes renders as a [SEVERE] one. Spacing belongs to a console, not to the server log.
|
||||
private static void warning() {
|
||||
IrisLogging.warn(C.GOLD + "Iris is running in Warning Mode");
|
||||
IrisLogging.warn(C.GRAY + "Some startup checks need attention. Review the messages above for tuning suggestions.");
|
||||
IrisLogging.warn(C.GRAY + "Iris will continue startup normally.");
|
||||
ChatReport.of(ChatReport.Tone.WARNING, "Iris is running in Warning Mode")
|
||||
.item("Some startup checks need attention. The warnings above suggest fixes.")
|
||||
.item("Startup continues.")
|
||||
.build()
|
||||
.log();
|
||||
}
|
||||
|
||||
private static void unstable() {
|
||||
IrisLogging.error(C.DARK_RED + "Iris is running in Danger Mode");
|
||||
IrisLogging.error("Critical startup checks failed. Review and resolve the errors above as soon as possible.");
|
||||
ChatReport.of(ChatReport.Tone.ERROR, "Iris is running in Danger Mode")
|
||||
.item("Critical startup checks failed. Fix the errors above.")
|
||||
.build()
|
||||
.log();
|
||||
// No startup sleep: blocking the boot thread protected nothing — world creation and
|
||||
// player admission are already gated by IrisStartupValidation.
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package art.arcane.iris.world.safeguard;
|
||||
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.diagnostics.splash.IrisSplashComposer;
|
||||
import art.arcane.iris.diagnostics.splash.IrisSplashRenderer;
|
||||
import art.arcane.iris.platform.bukkit.BukkitPlatform;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.ConsoleGlyphs;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public enum Mode {
|
||||
@@ -43,18 +43,15 @@ public enum Mode {
|
||||
return wrap("Iris") + " " + wrap(subTag) + C.GRAY + ": ";
|
||||
}
|
||||
|
||||
public void trySplash() {
|
||||
if (!IrisSettings.get().getGeneral().isSplashLogoStartup()) {
|
||||
return;
|
||||
}
|
||||
splash();
|
||||
public String logTag() {
|
||||
return color.toString() + C.BOLD + "Iris" + C.RESET + C.DARK_GRAY + " " + ConsoleGlyphs.BAR + " " + C.RESET;
|
||||
}
|
||||
|
||||
public void splash() {
|
||||
public String composeSplash(List<List<IrisSplashComposer.Detail>> detailRows) {
|
||||
String version = BukkitPlatform.plugin().getDescription().getVersion();
|
||||
String[] splash = IrisSplashRenderer.render(this::splashTone);
|
||||
String[] info = IrisSplashComposer.composeInfo(version, getServerVersion(), infoStyle());
|
||||
IrisLogging.info(IrisSplashComposer.compose(splash, info));
|
||||
String[] info = IrisSplashComposer.composeInfo(version, getServerVersion(), infoStyle(), detailRows);
|
||||
return IrisSplashComposer.compose(splash, info);
|
||||
}
|
||||
|
||||
private IrisSplashComposer.InfoStyle infoStyle() {
|
||||
@@ -66,17 +63,17 @@ public enum Mode {
|
||||
|
||||
@Override
|
||||
public String title(String text) {
|
||||
return color + text;
|
||||
return color.toString() + C.BOLD + text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String subtitle(String text) {
|
||||
return C.AQUA + text;
|
||||
return C.WHITE.toString() + C.BOLD + text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tag(String text) {
|
||||
return C.RED + text;
|
||||
return C.DARK_GRAY + text;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,7 +83,12 @@ public enum Mode {
|
||||
|
||||
@Override
|
||||
public String value(String text) {
|
||||
return color + text;
|
||||
return C.GRAY + text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String headlineValue(String text) {
|
||||
return C.WHITE + text;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -102,7 +104,7 @@ public enum Mode {
|
||||
}
|
||||
|
||||
private String wrap(String tag) {
|
||||
return C.BOLD.toString() + C.DARK_GRAY + "[" + C.BOLD + color + tag + C.BOLD + C.DARK_GRAY + "]" + C.RESET;
|
||||
return C.DARK_GRAY.toString() + C.BOLD + "[" + color + C.BOLD + tag + C.DARK_GRAY + C.BOLD + "]" + C.RESET;
|
||||
}
|
||||
|
||||
private String getServerVersion() {
|
||||
|
||||
@@ -21,7 +21,6 @@ package art.arcane.iris.world.task.jobs;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.localization.RuntimeUiMessages;
|
||||
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.localization.MessageArgument;
|
||||
import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
|
||||
@@ -31,6 +30,9 @@ import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface Job {
|
||||
int PLAYER_PROGRESS_INTERVAL_TICKS = 4;
|
||||
int CONSOLE_PROGRESS_INTERVAL_TICKS = 100;
|
||||
|
||||
String getName();
|
||||
|
||||
void execute();
|
||||
@@ -74,7 +76,7 @@ public interface Job {
|
||||
} else {
|
||||
sender.sendMessage(getName() + ": " + getProgressString());
|
||||
}
|
||||
}, sender.isPlayer() ? 0 : 20);
|
||||
}, sender.isPlayer() ? PLAYER_PROGRESS_INTERVAL_TICKS : CONSOLE_PROGRESS_INTERVAL_TICKS);
|
||||
f.whenComplete((fs, ff) -> {
|
||||
J.car(c);
|
||||
if (sender.isPlayer()) {
|
||||
@@ -82,7 +84,7 @@ public interface Job {
|
||||
BukkitPlatform.hudLanes().hide(sender.player(), "iris:job");
|
||||
}
|
||||
if (!silentMsg) {
|
||||
sender.sendMessage(C.AQUA + IrisLanguage.text(
|
||||
sender.sendSuccess(IrisLanguage.text(
|
||||
RuntimeUiMessages.JOB_COMPLETED,
|
||||
MessageArgument.untrusted("job", getName()),
|
||||
MessageArgument.trusted("duration", Form.duration(p.getMilliseconds(), 1))
|
||||
|
||||
@@ -1119,6 +1119,8 @@ replace_installed_types = "Installierte Packs: {value}"
|
||||
"export.invalid" = "Ungültige Argumente für den Datapack-Export: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "Das laufende Regenerieren in einer Welt stoppen"
|
||||
"param.world_regen_stop" = "Die Welt, deren Regenerieren gestoppt werden soll"
|
||||
"director.iris_world_manager" = "Iris-Weltverwaltung"
|
||||
"director.get_loaded_tectonicplates_count" = "Anzahl geladener TectonicPlates abrufen"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "Generierte Blockausgabe eines festen Bereichs für Determinismus- und Identitätstests hashen"
|
||||
@@ -1635,6 +1637,14 @@ progress = "§eErsetzung für {world}: {stage} ({elapsed}s vergangen)"
|
||||
"stage.cleanup" = "Fehlgeschlagene Ersetzung wird bereinigt"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "Wird gestoppt"
|
||||
"bossbar.stopped" = "§6{title} §eGESTOPPT§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §eGestoppt§7 | §f{summary}"
|
||||
stopped = "§6{title} gestoppt: {summary}"
|
||||
already_running = "{title} läuft bereits in {world}: {applied}/{total} Chunks"
|
||||
stop_hint = "Stoppen mit {command}"
|
||||
stopping = "{title} in {world} wird gestoppt; laufende Chunks werden noch fertiggestellt"
|
||||
none_running = "In {world} läuft kein {title}"
|
||||
"title.regen" = "Regenerieren"
|
||||
"title.delete" = "Löschung"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2126,3 +2136,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"
|
||||
@@ -1119,6 +1119,8 @@ replace_installed_types = "Packs instalados: {value}"
|
||||
"export.invalid" = "Argumentos de exportación de datapack no válidos: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "Detener la regeneración en curso de un mundo"
|
||||
"param.world_regen_stop" = "El mundo cuya regeneración se detendrá"
|
||||
"director.iris_world_manager" = "Gestor de mundos de Iris"
|
||||
"director.get_loaded_tectonicplates_count" = "Obtener el número de TectonicPlates cargadas"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "Calcular el hash de los bloques generados en un área fija para comprobar el determinismo y la identidad"
|
||||
@@ -1635,6 +1637,14 @@ progress = "§eReemplazo de {world}: {stage} ({elapsed}s transcurridos)"
|
||||
"stage.cleanup" = "Limpiando el reemplazo fallido"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "Deteniendo"
|
||||
"bossbar.stopped" = "§6{title} §eDETENIDO§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §eDetenido§7 | §f{summary}"
|
||||
stopped = "§6{title} detenido: {summary}"
|
||||
already_running = "{title} ya se está ejecutando en {world}: {applied}/{total} chunks"
|
||||
stop_hint = "Detenlo con {command}"
|
||||
stopping = "Deteniendo {title} en {world}; los chunks en curso terminarán primero"
|
||||
none_running = "No hay ningún {title} en ejecución en {world}"
|
||||
"title.regen" = "Regenerar"
|
||||
"title.delete" = "Eliminar"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2126,3 +2136,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}"
|
||||
@@ -1124,6 +1124,8 @@ replace_installed_types = "Asennetut paketit: {value}"
|
||||
"export.invalid" = "Virheelliset datapaketin vientiargumentit: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "Pysäytä maailmassa käynnissä oleva uudelleengenerointi"
|
||||
"param.world_regen_stop" = "Maailma, jonka uudelleengenerointi pysäytetään"
|
||||
"director.iris_world_manager" = "Iris-maailmanhallinta"
|
||||
"director.get_loaded_tectonicplates_count" = "Hae ladattujen TectonicPlates-olioiden määrä"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "Laske kiinteän alueen generoidun lohkotuloksen hash determinismi-/identiteettitestausta varten"
|
||||
@@ -1640,6 +1642,14 @@ progress = "§eMaailman {world} korvaaminen: {stage} ({elapsed}s kulunut)"
|
||||
"stage.cleanup" = "Siivotaan epäonnistunutta korvausyritystä"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "Pysäytetään"
|
||||
"bossbar.stopped" = "§6{title} §ePYSÄYTETTY§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §ePysäytetty§7 | §f{summary}"
|
||||
stopped = "§6{title} pysäytetty: {summary}"
|
||||
already_running = "{title} on jo käynnissä maailmassa {world}: {applied}/{total} chunkkia"
|
||||
stop_hint = "Pysäytä komennolla {command}"
|
||||
stopping = "Pysäytetään {title} maailmassa {world}; käynnissä olevat chunkit valmistuvat ensin"
|
||||
none_running = "Maailmassa {world} ei ole käynnissä {title}-ajoa"
|
||||
"title.regen" = "Regen"
|
||||
"title.delete" = "Poista"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2131,3 +2141,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}"
|
||||
@@ -1119,6 +1119,8 @@ replace_installed_types = "Packs installés : {value}"
|
||||
"export.invalid" = "Arguments d'export de datapack invalides : {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "Arrêter la régénération en cours dans un monde"
|
||||
"param.world_regen_stop" = "Le monde dont la régénération doit être arrêtée"
|
||||
"director.iris_world_manager" = "Gestionnaire de mondes Iris"
|
||||
"director.get_loaded_tectonicplates_count" = "Obtenir le nombre de TectonicPlates chargées"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "Calculer le hash des blocs générés dans une zone fixe afin de tester le déterminisme et l'identité"
|
||||
@@ -1635,6 +1637,14 @@ progress = "§eRemplacement de {world} : {stage} ({elapsed}s écoulées)"
|
||||
"stage.cleanup" = "Nettoyage du remplacement ayant échoué"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "Arrêt en cours"
|
||||
"bossbar.stopped" = "§6{title} §eARRÊTɧ7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §eArrêté§7 | §f{summary}"
|
||||
stopped = "§6{title} arrêté : {summary}"
|
||||
already_running = "{title} est déjà en cours dans {world} : {applied}/{total} chunks"
|
||||
stop_hint = "Arrêtez-le avec {command}"
|
||||
stopping = "Arrêt de {title} dans {world} ; les chunks en cours se terminent d'abord"
|
||||
none_running = "Aucun {title} en cours dans {world}"
|
||||
"title.regen" = "Régénérer"
|
||||
"title.delete" = "Supprimer"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2126,3 +2136,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}"
|
||||
@@ -1124,6 +1124,8 @@ replace_installed_types = "חבילות מותקנות: {value}"
|
||||
"export.invalid" = "ארגומנטים לא תקינים לייצוא datapack: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "עצירת היצירה מחדש הפועלת בעולם"
|
||||
"param.world_regen_stop" = "העולם שבו תיעצר היצירה מחדש"
|
||||
"director.iris_world_manager" = "מנהל העולמות של Iris"
|
||||
"director.get_loaded_tectonicplates_count" = "קבלת מספר ה-TectonicPlates הטעונים"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "חישוב hash של פלט הבלוקים שנוצר באזור קבוע לבדיקות דטרמיניזם/זהות"
|
||||
@@ -1640,6 +1642,14 @@ progress = "§eהחלפה עבור {world}: {stage} ({elapsed} שניות חלפ
|
||||
"stage.cleanup" = "מנקה את ההחלפה שנכשלה"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "עוצר"
|
||||
"bossbar.stopped" = "§6{title} §eנעצר§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §eנעצר§7 | §f{summary}"
|
||||
stopped = "§6{title} נעצר: {summary}"
|
||||
already_running = "{title} כבר פועל ב-{world}: {applied}/{total} צ'אנקים"
|
||||
stop_hint = "עצור באמצעות {command}"
|
||||
stopping = "עוצר את {title} ב-{world}; צ'אנקים בתהליך יסתיימו קודם"
|
||||
none_running = "אין {title} פועל ב-{world}"
|
||||
"title.regen" = "יצירה מחדש"
|
||||
"title.delete" = "מחיקה"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2131,3 +2141,7 @@ open = "פתיחה: {url}"
|
||||
open-description = "פתיחת דוח האבחון שהועלה."
|
||||
copy-path = "העתקת הנתיב המקומי"
|
||||
copy-path-description = "העתקת הנתיב של הדוח המקומי."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "+{count} נוספים"
|
||||
click_to_insert = "לחצו כדי להוסיף את {command}"
|
||||
@@ -1119,6 +1119,8 @@ replace_installed_types = "Pack installati: {value}"
|
||||
"export.invalid" = "Argomenti di esportazione datapack non validi: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "Ferma la rigenerazione in corso in un mondo"
|
||||
"param.world_regen_stop" = "Il mondo di cui fermare la rigenerazione"
|
||||
"director.iris_world_manager" = "Gestore dei mondi Iris"
|
||||
"director.get_loaded_tectonicplates_count" = "Ottieni il numero di TectonicPlates caricate"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "Calcola l'hash dei blocchi generati in un'area fissa per test di determinismo e identità"
|
||||
@@ -1635,6 +1637,14 @@ progress = "§eSostituzione di {world}: {stage} ({elapsed}s trascorsi)"
|
||||
"stage.cleanup" = "Pulizia della sostituzione non riuscita"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "Arresto in corso"
|
||||
"bossbar.stopped" = "§6{title} §eFERMATO§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §eFermato§7 | §f{summary}"
|
||||
stopped = "§6{title} fermato: {summary}"
|
||||
already_running = "{title} è già in esecuzione in {world}: {applied}/{total} chunk"
|
||||
stop_hint = "Fermalo con {command}"
|
||||
stopping = "Arresto di {title} in {world}; i chunk in corso verranno completati prima"
|
||||
none_running = "Nessun {title} in esecuzione in {world}"
|
||||
"title.regen" = "Rigenera"
|
||||
"title.delete" = "Cancella"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2126,3 +2136,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}"
|
||||
@@ -1122,6 +1122,8 @@ replace_installed_types = "インストール済みのパック: {value}"
|
||||
"export.invalid" = "データパックのエクスポート引数が無効です: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "ワールドで実行中の再生成を停止する"
|
||||
"param.world_regen_stop" = "再生成を停止するワールド"
|
||||
"director.iris_world_manager" = "Iris ワールドマネージャー"
|
||||
"director.get_loaded_tectonicplates_count" = "読み込み済み TectonicPlates の数を取得します"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "固定範囲で生成されたブロック出力をハッシュ化し、決定性と一致性を検証します"
|
||||
@@ -1638,6 +1640,14 @@ progress = "§e{world} の置き換え: {stage} ({elapsed}秒経過)"
|
||||
"stage.cleanup" = "失敗した置き換えのデータを整理しています"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "停止中"
|
||||
"bossbar.stopped" = "§6{title} §e停止§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §e停止§7 | §f{summary}"
|
||||
stopped = "§6{title} を停止しました: {summary}"
|
||||
already_running = "{world} ではすでに {title} が実行中です: {applied}/{total} チャンク"
|
||||
stop_hint = "{command} で停止できます"
|
||||
stopping = "{world} の {title} を停止しています。処理中のチャンクは先に完了します"
|
||||
none_running = "{world} で実行中の {title} はありません"
|
||||
"title.regen" = "再生成"
|
||||
"title.delete" = "削除"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2129,3 +2139,7 @@ open = "開く: {url}"
|
||||
open-description = "アップロードした診断レポートを開きます。"
|
||||
copy-path = "ローカルパスをコピー"
|
||||
copy-path-description = "ローカルのレポートのパスをコピーします。"
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "他 {count} 件"
|
||||
click_to_insert = "クリックして {command} を入力"
|
||||
@@ -1122,6 +1122,8 @@ replace_installed_types = "설치된 팩: {value}"
|
||||
"export.invalid" = "데이터 팩 내보내기 인수가 잘못되었습니다: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "월드에서 실행 중인 재생성 중지"
|
||||
"param.world_regen_stop" = "재생성을 중지할 월드"
|
||||
"director.iris_world_manager" = "Iris 월드 관리자"
|
||||
"director.get_loaded_tectonicplates_count" = "로드된 TectonicPlates 수를 가져옵니다"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "고정 영역의 생성 블록 출력을 해시해 결정성과 일치성을 검사합니다"
|
||||
@@ -1638,6 +1640,14 @@ progress = "§e{world} 교체: {stage} ({elapsed}초 경과)"
|
||||
"stage.cleanup" = "실패한 교체 작업 정리 중"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "중지 중"
|
||||
"bossbar.stopped" = "§6{title} §e중지됨§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §e중지됨§7 | §f{summary}"
|
||||
stopped = "§6{title} 중지됨: {summary}"
|
||||
already_running = "{world}에서 이미 {title}이(가) 실행 중입니다: {applied}/{total} 청크"
|
||||
stop_hint = "{command}(으)로 중지하세요"
|
||||
stopping = "{world}의 {title}을(를) 중지하는 중입니다. 진행 중인 청크는 먼저 완료됩니다"
|
||||
none_running = "{world}에서 실행 중인 {title}이(가) 없습니다"
|
||||
"title.regen" = "재생성"
|
||||
"title.delete" = "삭제"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2129,3 +2139,7 @@ open = "열기: {url}"
|
||||
open-description = "업로드한 진단 보고서를 엽니다."
|
||||
copy-path = "로컬 경로 복사"
|
||||
copy-path-description = "로컬 보고서 경로를 복사합니다."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "외 {count}개"
|
||||
click_to_insert = "클릭하여 {command} 입력"
|
||||
@@ -1124,6 +1124,8 @@ replace_installed_types = "Įdiegti paketai: {value}"
|
||||
"export.invalid" = "Netinkami datapack eksporto argumentai: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "Sustabdyti pasaulyje vykdomą regeneravimą"
|
||||
"param.world_regen_stop" = "Pasaulis, kurio regeneravimą sustabdyti"
|
||||
"director.iris_world_manager" = "Iris pasaulių tvarkyklė"
|
||||
"director.get_loaded_tectonicplates_count" = "Gauti įkeltų TectonicPlates skaičių"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "Apskaičiuoti fiksuotos srities sugeneruotų blokų išvesties maišą determinizmo / tapatumo bandymams"
|
||||
@@ -1640,6 +1642,14 @@ progress = "§e{world} pakeitimas: {stage} (praėjo {elapsed}s)"
|
||||
"stage.cleanup" = "Valomi nepavykusio pakeitimo duomenys"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "Stabdoma"
|
||||
"bossbar.stopped" = "§6{title} §eSUSTABDYTA§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §eSustabdyta§7 | §f{summary}"
|
||||
stopped = "§6{title} sustabdyta: {summary}"
|
||||
already_running = "{title} jau vykdoma pasaulyje {world}: {applied}/{total} chunkų"
|
||||
stop_hint = "Sustabdykite komanda {command}"
|
||||
stopping = "Stabdoma {title} pasaulyje {world}; vykdomi chunkai bus užbaigti"
|
||||
none_running = "Pasaulyje {world} nevykdoma jokia {title}"
|
||||
"title.regen" = "Regeneravimas"
|
||||
"title.delete" = "Trinti"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2131,3 +2141,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}"
|
||||
@@ -1119,6 +1119,8 @@ replace_installed_types = "Geïnstalleerde pakketten: {value}"
|
||||
"export.invalid" = "Ongeldige argumenten voor datapack-export: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "Stop de regen die in een wereld draait"
|
||||
"param.world_regen_stop" = "De wereld waarvan de regen moet stoppen"
|
||||
"director.iris_world_manager" = "Iris-wereldbeheer"
|
||||
"director.get_loaded_tectonicplates_count" = "Aantal geladen TectonicPlates opvragen"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "Hash van de gegenereerde blokuitvoer van een vast gebied voor determinisme-/identiteitstests"
|
||||
@@ -1635,6 +1637,14 @@ progress = "§eVervanging van {world}: {stage} ({elapsed}s verstreken)"
|
||||
"stage.cleanup" = "Mislukte vervanging opruimen"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "Stoppen"
|
||||
"bossbar.stopped" = "§6{title} §eGESTOPT§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §eGestopt§7 | §f{summary}"
|
||||
stopped = "§6{title} gestopt: {summary}"
|
||||
already_running = "{title} draait al in {world}: {applied}/{total} chunks"
|
||||
stop_hint = "Stop het met {command}"
|
||||
stopping = "{title} in {world} wordt gestopt; chunks die bezig zijn worden eerst afgemaakt"
|
||||
none_running = "Er draait geen {title} in {world}"
|
||||
"title.regen" = "Regeneratie"
|
||||
"title.delete" = "Verwijderen"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2126,3 +2136,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"
|
||||
@@ -1124,6 +1124,8 @@ replace_installed_types = "Zainstalowane pakiety: {value}"
|
||||
"export.invalid" = "Nieprawidłowe argumenty eksportu datapacka: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "Zatrzymaj regenerację działającą w świecie"
|
||||
"param.world_regen_stop" = "Świat, w którym zatrzymać regenerację"
|
||||
"director.iris_world_manager" = "Menedżer światów Iris"
|
||||
"director.get_loaded_tectonicplates_count" = "Pobierz liczbę załadowanych TectonicPlates"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "Haszuj wygenerowane bloki stałego obszaru do testów determinizmu/tożsamości"
|
||||
@@ -1640,6 +1642,14 @@ progress = "§eZastąpienie {world}: {stage} (upłynęło {elapsed}s)"
|
||||
"stage.cleanup" = "Usuwanie pozostałości nieudanego zastąpienia"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "Zatrzymywanie"
|
||||
"bossbar.stopped" = "§6{title} §eZATRZYMANO§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §eZatrzymano§7 | §f{summary}"
|
||||
stopped = "§6{title} zatrzymano: {summary}"
|
||||
already_running = "{title} już działa w {world}: {applied}/{total} chunków"
|
||||
stop_hint = "Zatrzymaj poleceniem {command}"
|
||||
stopping = "Zatrzymywanie {title} w {world}; chunki w trakcie zostaną najpierw ukończone"
|
||||
none_running = "W {world} nie działa żaden {title}"
|
||||
"title.regen" = "Regen"
|
||||
"title.delete" = "Usuń"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2131,3 +2141,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}"
|
||||
@@ -1119,6 +1119,8 @@ replace_installed_types = "Pacotes instalados: {value}"
|
||||
"export.invalid" = "Argumentos de exportação do datapack inválidos: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "Parar a regeneração em execução num mundo"
|
||||
"param.world_regen_stop" = "O mundo cuja regeneração deve parar"
|
||||
"director.iris_world_manager" = "Gestor de mundos Iris"
|
||||
"director.get_loaded_tectonicplates_count" = "Obter a contagem de TectonicPlates carregadas"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "Calcular o hash da saída de blocos gerada numa área fixa para testes de determinismo/identidade"
|
||||
@@ -1635,6 +1637,14 @@ progress = "§eSubstituição de {world}: {stage} ({elapsed}s decorridos)"
|
||||
"stage.cleanup" = "A limpar a substituição falhada"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "A parar"
|
||||
"bossbar.stopped" = "§6{title} §ePARADO§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §eParado§7 | §f{summary}"
|
||||
stopped = "§6{title} parado: {summary}"
|
||||
already_running = "{title} já está em execução em {world}: {applied}/{total} chunks"
|
||||
stop_hint = "Pare-o com {command}"
|
||||
stopping = "A parar {title} em {world}; os chunks em curso terminam primeiro"
|
||||
none_running = "Nenhum {title} em execução em {world}"
|
||||
"title.regen" = "Regen"
|
||||
"title.delete" = "Apagar"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2126,3 +2136,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}"
|
||||
@@ -1124,6 +1124,8 @@ replace_installed_types = "Установленные пакеты: {value}"
|
||||
"export.invalid" = "Недопустимые аргументы экспорта датапака: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "Остановить регенерацию, запущенную в мире"
|
||||
"param.world_regen_stop" = "Мир, в котором остановить регенерацию"
|
||||
"director.iris_world_manager" = "Менеджер миров Iris"
|
||||
"director.get_loaded_tectonicplates_count" = "Получить количество загруженных TectonicPlates"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "Хешировать сгенерированные блоки фиксированной области для проверки детерминизма/идентичности"
|
||||
@@ -1640,6 +1642,14 @@ progress = "§eЗамена {world}: {stage} (прошло {elapsed}с)"
|
||||
"stage.cleanup" = "Очистка данных неудавшейся замены"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "Остановка"
|
||||
"bossbar.stopped" = "§6{title} §eОСТАНОВЛЕНО§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §eОстановлено§7 | §f{summary}"
|
||||
stopped = "§6{title} остановлено: {summary}"
|
||||
already_running = "{title} уже выполняется в {world}: {applied}/{total} чанков"
|
||||
stop_hint = "Остановить: {command}"
|
||||
stopping = "Остановка {title} в {world}; чанки в работе будут завершены"
|
||||
none_running = "В {world} нет запущенного {title}"
|
||||
"title.regen" = "Регенерация"
|
||||
"title.delete" = "Удаление"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2131,3 +2141,7 @@ open = "Открыть: {url}"
|
||||
open-description = "Открыть загруженный диагностический отчёт."
|
||||
copy-path = "Скопировать локальный путь"
|
||||
copy-path-description = "Скопировать путь к локальному отчёту."
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "ещё {count}"
|
||||
click_to_insert = "Нажмите, чтобы вставить {command}"
|
||||
@@ -1124,6 +1124,8 @@ replace_installed_types = "Yüklü paketler: {value}"
|
||||
"export.invalid" = "Geçersiz datapack dışa aktarma argümanları: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "Bir dünyada çalışan yeniden oluşturmayı durdur"
|
||||
"param.world_regen_stop" = "Yeniden oluşturması durdurulacak dünya"
|
||||
"director.iris_world_manager" = "Iris Dünya Yöneticisi"
|
||||
"director.get_loaded_tectonicplates_count" = "Yüklü TectonicPlates sayısını al"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "Belirlenimcilik/kimlik testi için sabit bir alanın oluşturulan blok çıktısını hash'le"
|
||||
@@ -1640,6 +1642,14 @@ progress = "§e{world} değişimi: {stage} ({elapsed} saniye geçti)"
|
||||
"stage.cleanup" = "Başarısız değişim temizleniyor"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "Durduruluyor"
|
||||
"bossbar.stopped" = "§6{title} §eDURDURULDU§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §eDurduruldu§7 | §f{summary}"
|
||||
stopped = "§6{title} durduruldu: {summary}"
|
||||
already_running = "{title} zaten {world} içinde çalışıyor: {applied}/{total} chunk"
|
||||
stop_hint = "{command} ile durdurun"
|
||||
stopping = "{world} içindeki {title} durduruluyor; işlemdeki chunk'lar önce tamamlanır"
|
||||
none_running = "{world} içinde çalışan {title} yok"
|
||||
"title.regen" = "Regen"
|
||||
"title.delete" = "Silme"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2131,3 +2141,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"
|
||||
@@ -1122,6 +1122,8 @@ replace_installed_types = "Các gói đã cài đặt: {value}"
|
||||
"export.invalid" = "Đối số xuất datapack không hợp lệ: {reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "Dừng quá trình tái tạo đang chạy trong một thế giới"
|
||||
"param.world_regen_stop" = "Thế giới cần dừng tái tạo"
|
||||
"director.iris_world_manager" = "Trình quản lý thế giới Iris"
|
||||
"director.get_loaded_tectonicplates_count" = "Lấy số lượng TectonicPlates đã tải"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "Băm kết quả khối được tạo của một vùng cố định để kiểm thử tính tất định/đồng nhất"
|
||||
@@ -1638,6 +1640,14 @@ progress = "§eThay thế {world}: {stage} (đã qua {elapsed} giây)"
|
||||
"stage.cleanup" = "Đang dọn dẹp bản thay thế bị lỗi"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "Đang dừng"
|
||||
"bossbar.stopped" = "§6{title} §eĐÃ DỪNG§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §eĐã dừng§7 | §f{summary}"
|
||||
stopped = "§6{title} đã dừng: {summary}"
|
||||
already_running = "{title} đang chạy trong {world}: {applied}/{total} chunk"
|
||||
stop_hint = "Dừng bằng {command}"
|
||||
stopping = "Đang dừng {title} trong {world}; các chunk đang xử lý sẽ hoàn tất trước"
|
||||
none_running = "Không có {title} nào đang chạy trong {world}"
|
||||
"title.regen" = "Tái tạo"
|
||||
"title.delete" = "Xoá"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2129,3 +2139,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}"
|
||||
@@ -1122,6 +1122,8 @@ replace_installed_types = "已安装的包:{value}"
|
||||
"export.invalid" = "数据包导出参数无效:{reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "停止世界中正在运行的重新生成"
|
||||
"param.world_regen_stop" = "要停止重新生成的世界"
|
||||
"director.iris_world_manager" = "Iris 世界管理器"
|
||||
"director.get_loaded_tectonicplates_count" = "获取已加载的 TectonicPlates 数量"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "对固定区域生成的方块输出进行哈希,用于确定性/一致性测试"
|
||||
@@ -1638,6 +1640,14 @@ progress = "§e替换 {world}:{stage}(已用时 {elapsed} 秒)"
|
||||
"stage.cleanup" = "正在清理失败的替换内容"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "正在停止"
|
||||
"bossbar.stopped" = "§6{title} §e已停止§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §e已停止§7 | §f{summary}"
|
||||
stopped = "§6{title} 已停止:{summary}"
|
||||
already_running = "{world} 中已有 {title} 正在运行:{applied}/{total} 个区块"
|
||||
stop_hint = "使用 {command} 停止"
|
||||
stopping = "正在停止 {world} 中的 {title};正在处理的区块会先完成"
|
||||
none_running = "{world} 中没有正在运行的 {title}"
|
||||
"title.regen" = "重新生成"
|
||||
"title.delete" = "删除"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2129,3 +2139,7 @@ open = "打开:{url}"
|
||||
open-description = "打开已上传的诊断报告。"
|
||||
copy-path = "复制本地路径"
|
||||
copy-path-description = "复制本地报告的路径。"
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "另有 {count} 项"
|
||||
click_to_insert = "点击插入 {command}"
|
||||
@@ -1122,6 +1122,8 @@ replace_installed_types = "已安裝的包:{value}"
|
||||
"export.invalid" = "資料包匯出參數無效:{reason}"
|
||||
|
||||
[iris.director.commanddeveloper]
|
||||
"director.stop_regen_running_world" = "停止世界中正在執行的重新生成"
|
||||
"param.world_regen_stop" = "要停止重新生成的世界"
|
||||
"director.iris_world_manager" = "Iris 世界管理器"
|
||||
"director.get_loaded_tectonicplates_count" = "取得已載入的 TectonicPlates 數量"
|
||||
"director.hash_generated_block_output_fixed_area_determinism_identity_testing" = "對固定區域生成的方塊輸出進行雜湊,以進行確定性/一致性測試"
|
||||
@@ -1638,6 +1640,14 @@ progress = "§e替換 {world}:{stage}(已耗時 {elapsed} 秒)"
|
||||
"stage.cleanup" = "正在清理失敗的替換內容"
|
||||
|
||||
[iris.runtime.chunk_job]
|
||||
"stage.stopping" = "正在停止"
|
||||
"bossbar.stopped" = "§6{title} §e已停止§7 §e{summary}"
|
||||
"action.stopped" = "{bar}§7 §e已停止§7 | §f{summary}"
|
||||
stopped = "§6{title} 已停止:{summary}"
|
||||
already_running = "{world} 中已有 {title} 正在執行:{applied}/{total} 個區塊"
|
||||
stop_hint = "使用 {command} 停止"
|
||||
stopping = "正在停止 {world} 中的 {title};處理中的區塊會先完成"
|
||||
none_running = "{world} 中沒有正在執行的 {title}"
|
||||
"title.regen" = "重新生成"
|
||||
"title.delete" = "刪除"
|
||||
"title.golden_hash" = "GoldenHash"
|
||||
@@ -2129,3 +2139,7 @@ open = "開啟:{url}"
|
||||
open-description = "開啟已上傳的診斷報告。"
|
||||
copy-path = "複製本機路徑"
|
||||
copy-path-description = "複製本機報告的路徑。"
|
||||
|
||||
[iris.runtime.report]
|
||||
more = "另有 {count} 項"
|
||||
click_to_insert = "點擊插入 {command}"
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.volmlib.util.director.exceptions.DirectorParsingException;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
public class FixedChoiceHandlerTest {
|
||||
@Test
|
||||
public void exportModeSuggestsAndCanonicalizesEveryMode() throws Exception {
|
||||
ExportModeHandler handler = new ExportModeHandler();
|
||||
assertEquals(List.of("preset", "dimension", "overworld"), handler.getPossibilities());
|
||||
assertEquals("preset", handler.parse(" PRESET ", false));
|
||||
assertThrows(DirectorParsingException.class, () -> handler.parse("nether", false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exportFormatSuggestsAndCanonicalizesAliases() throws Exception {
|
||||
ExportFormatHandler handler = new ExportFormatHandler();
|
||||
assertEquals(List.of("zip", "directory"), handler.getPossibilities());
|
||||
assertEquals("directory", handler.parse("folder", false));
|
||||
assertThrows(DirectorParsingException.class, () -> handler.parse("tar", false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void previewApplyModeSuggestsAndRejectsUnknownModes() throws Exception {
|
||||
PreviewApplyModeHandler handler = new PreviewApplyModeHandler();
|
||||
assertEquals(List.of("preview", "apply"), handler.getPossibilities());
|
||||
assertEquals("apply", handler.parse("Apply", false));
|
||||
assertThrows(DirectorParsingException.class, () -> handler.parse("delete", false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exportVersionKeepsBlankAsLatestAndRejectsOlderTargets() throws Exception {
|
||||
ExportVersionHandler handler = new ExportVersionHandler();
|
||||
assertEquals(List.of("26.3"), handler.getPossibilities());
|
||||
assertEquals("", handler.parse("", false));
|
||||
assertEquals("26.3", handler.parse("26.3.0", false));
|
||||
assertThrows(DirectorParsingException.class, () -> handler.parse("26.2", false));
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class OpenSuggestionHandlerTest {
|
||||
@Test
|
||||
public void subterrainSuggestsFamiliesButAcceptsFeatureIds() {
|
||||
SubterrainFeatureHandler handler = new SubterrainFeatureHandler();
|
||||
assertEquals(List.of("tectonic_fault", "cenote", "lava_tube", "travertine_terraces"), handler.getPossibilities());
|
||||
assertEquals("my_feature:room", handler.parse(" my_feature:room ", false));
|
||||
assertEquals("", handler.parse(null, false));
|
||||
}
|
||||
}
|
||||
@@ -11,34 +11,66 @@ import static org.junit.Assert.assertFalse;
|
||||
|
||||
public class IrisSplashComposerTest {
|
||||
@Test
|
||||
public void packLinesShowUpdatesAndKeepCustomPacks() {
|
||||
public void updateLinesNameOnlyOutdatedPacks() {
|
||||
List<IrisSplashPackScanner.SplashPackMetadata> packs = List.of(
|
||||
new IrisSplashPackScanner.SplashPackMetadata("custom", "7"),
|
||||
new IrisSplashPackScanner.SplashPackMetadata("overworld", "4009"),
|
||||
new IrisSplashPackScanner.SplashPackMetadata("underworld", "1012"));
|
||||
assertEquals(List.of("Custom Dimensions: 3", " custom v7", " overworld v4009 -> v4010 available",
|
||||
" underworld v1012", "Update overworld: /iris download pack=overworld overwrite=true"),
|
||||
IrisSplashComposer.composePackLines(packs, Map.of(
|
||||
assertEquals(List.of(
|
||||
" Pack overworld v4010 is available. You have v4009.",
|
||||
"└ Update it:",
|
||||
" /iris download pack=overworld overwrite=true"),
|
||||
IrisSplashComposer.composeUpdateLines(packs, Map.of(
|
||||
"overworld", new BuiltInPackUpdates.Update("4010"),
|
||||
"underworld", new BuiltInPackUpdates.Update("1012"))));
|
||||
"underworld", new BuiltInPackUpdates.Update("1012"))).stream()
|
||||
.map(line -> line.replaceAll("§.", ""))
|
||||
.toList());
|
||||
assertEquals("custom v7, overworld v4009, underworld v1012", IrisSplashComposer.packSummary(packs));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void detailRowsFillTheSpareSplashRows() {
|
||||
String[] info = IrisSplashComposer.composeInfo("4.0.0-26.2", "Paper 26.2", IrisSplashComposer.InfoStyle.PLAIN,
|
||||
List.of(List.of(new IrisSplashComposer.Detail("SIMD", "256-bit"),
|
||||
new IrisSplashComposer.Detail("Injection", "deferred"))));
|
||||
|
||||
assertEquals(11, info.length);
|
||||
assertEquals(" SIMD 256-bit Injection deferred", info[7]);
|
||||
assertEquals("", info[10]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void composeInfoUsesCurrentVersionWithoutStaleReleaseTag() {
|
||||
String[] info = IrisSplashComposer.composeInfo("4.0.0-26.2", "Paper 26.2", IrisSplashComposer.InfoStyle.PLAIN);
|
||||
|
||||
assertEquals(" Iris, Dimension Engine [4.0]", info[1]);
|
||||
assertEquals(" Version: 4.0.0-26.2", info[2]);
|
||||
assertEquals(" Iris, Dimension Engine [4.0]", info[0]);
|
||||
assertEquals(" Version 4.0.0-26.2", info[1]);
|
||||
assertFalse(String.join("\n", info).contains("RC.1.1.6"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onlyHeadlineFactsGetTheHeadlineValueStyle() {
|
||||
IrisSplashComposer.InfoStyle marksHeadlines = new IrisSplashComposer.InfoStyle() {
|
||||
@Override
|
||||
public String headlineValue(String text) {
|
||||
return "*" + text;
|
||||
}
|
||||
};
|
||||
|
||||
String[] info = IrisSplashComposer.composeInfo("4.0.0-26.2", "Paper 26.2", marksHeadlines);
|
||||
|
||||
assertEquals(" Version *4.0.0-26.2", info[1]);
|
||||
assertEquals(" Web volmitsoftware.com", info[3]);
|
||||
assertEquals(" Server *Paper 26.2", info[4]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void composeInfoShowsWebsiteAndKeepsSplashHeight() {
|
||||
String[] info = IrisSplashComposer.composeInfo("4.0.0-26.2", "Paper 26.2", IrisSplashComposer.InfoStyle.PLAIN);
|
||||
|
||||
assertEquals(11, info.length);
|
||||
assertEquals(" By: Volmit Software (Arcane Arts)", info[3]);
|
||||
assertEquals(" Web: VolmitSoftware.com", info[4]);
|
||||
assertEquals(" Server: Paper 26.2", info[5]);
|
||||
assertEquals(" By Volmit Software (Arcane Arts)", info[2]);
|
||||
assertEquals(" Web volmitsoftware.com", info[3]);
|
||||
assertEquals(" Server Paper 26.2", info[4]);
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package art.arcane.iris.generation.runtime;
|
||||
|
||||
import art.arcane.iris.world.history.RegistryRestartRequiredException;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public final class StudioRestartRequirementTest {
|
||||
@Test
|
||||
public void noDeferredBiomesMeansNothingIsPending() {
|
||||
StudioRestartRequirement requirement = StudioRestartRequirement.deferring(List.of());
|
||||
|
||||
assertFalse(requirement.isPending());
|
||||
assertFalse(requirement.blocksHotload());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void summaryListsBlockingBiomesFirstAndCountsTheRest() {
|
||||
StudioRestartRequirement requirement = StudioRestartRequirement.blockedBy(
|
||||
new RegistryRestartRequiredException(List.of("ash"), List.of("mist", "dunes", "fog", "ash")));
|
||||
|
||||
assertTrue(requirement.isPending());
|
||||
assertTrue(requirement.blocksHotload());
|
||||
assertEquals("ash, mist, dunes +1", requirement.biomeSummary());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deferredBiomesHotloadWithoutBlocking() {
|
||||
StudioRestartRequirement requirement = StudioRestartRequirement.deferring(List.of("mist"));
|
||||
|
||||
assertTrue(requirement.isPending());
|
||||
assertFalse(requirement.blocksHotload());
|
||||
assertEquals("mist", requirement.biomeSummary());
|
||||
}
|
||||
}
|
||||
+10
@@ -208,6 +208,16 @@ public class IrisDepositModifierOrderingTest {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLog() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeaves() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoliagePlantable() {
|
||||
return false;
|
||||
|
||||
+10
@@ -466,6 +466,16 @@ public class IrisDepositModifierParityTest {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLog() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeaves() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoliagePlantable() {
|
||||
return false;
|
||||
|
||||
+10
@@ -339,6 +339,16 @@ public class IrisPerfectionModifierColumnTest {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLog() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeaves() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoliagePlantable() {
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
package art.arcane.iris.localization;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ChatReportTest {
|
||||
private static final String REMOVED_FIELD_TAIL =
|
||||
" caveProfile.allowWater was removed; use caveProfile.allowFluid. Cave aquifers use the dimension fluidPalette.";
|
||||
|
||||
@Test
|
||||
public void reasonsSharingAllButTheSubjectCollapseIntoOneEntry() {
|
||||
List<String> plain = plainLines(ChatReport.of(ChatReport.Tone.ERROR, "Can't open Studio")
|
||||
.items(List.of(
|
||||
"Biome 'dev'" + REMOVED_FIELD_TAIL,
|
||||
"Biome 'vanilla/grove'" + REMOVED_FIELD_TAIL,
|
||||
"Biome 'vanilla/ice_spikes'" + REMOVED_FIELD_TAIL,
|
||||
"Missing dimensions/ folder."))
|
||||
.build());
|
||||
|
||||
assertEquals(List.of(
|
||||
"Can't open Studio",
|
||||
" » 3 biomes: caveProfile.allowWater was removed; use caveProfile.allowFluid. Cave aquifers use the dimension fluidPalette.",
|
||||
" dev, vanilla/grove, vanilla/ice_spikes",
|
||||
" » Missing dimensions/ folder."), plain);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void groupedSubjectsAreCappedWithAMoreTail() {
|
||||
List<String> reasons = List.of("a", "b", "c", "d", "e", "f").stream()
|
||||
.map(subject -> "Biome '" + subject + "'" + REMOVED_FIELD_TAIL)
|
||||
.toList();
|
||||
|
||||
List<String> plain = plainLines(ChatReport.of(ChatReport.Tone.ERROR, "t").items(reasons).build());
|
||||
|
||||
assertEquals(" a, b, c, d +2 more", plain.get(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aLoneSubjectReasonKeepsItsOriginalWording() {
|
||||
List<String> plain = plainLines(ChatReport.of(ChatReport.Tone.WARNING, "t")
|
||||
.items(List.of("Biome 'dev'" + REMOVED_FIELD_TAIL))
|
||||
.build());
|
||||
|
||||
assertEquals(" » Biome 'dev'" + REMOVED_FIELD_TAIL, plain.get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bodyHighlightsNamesAndDimsTheExplanation() {
|
||||
String styled = ReportText.body("Biome 'dev' uses create:limestone at wall.palette[0]. Install the mod.");
|
||||
|
||||
assertTrue(styled.contains(C.WHITE + "'dev'" + C.GRAY));
|
||||
assertTrue(styled.contains(C.AQUA + "create:limestone" + C.GRAY));
|
||||
assertTrue(styled.contains(C.AQUA + "wall.palette[0]" + C.GRAY));
|
||||
assertTrue(styled.endsWith(C.DARK_GRAY + "Install the mod."));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void apostrophesAreNotTreatedAsQuotedNames() {
|
||||
String styled = ReportText.title(ChatReport.Tone.ERROR, "Can't open Studio for 'uitest'");
|
||||
|
||||
assertTrue(styled.contains("Can't open Studio for " + C.WHITE + "'uitest'"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void titlesStayRegularWeight() {
|
||||
String styled = ReportText.title(ChatReport.Tone.ERROR, "Can't open Studio for 'uitest'");
|
||||
|
||||
assertFalse(styled.contains(C.BOLD.toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void boldCodesSurviveTheMarkupConversion() {
|
||||
String markup = C.mini(C.RED.toString() + C.BOLD + "Title" + C.GRAY + " rest");
|
||||
|
||||
assertTrue(markup, markup.contains("<bold>Title<reset><gray> rest"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hintCanShowAShorterCommandThanItRuns() {
|
||||
ChatReport.Line hint = ChatReport.of(ChatReport.Tone.INFO, "t")
|
||||
.hint("Stop it with /iris std regen-stop", "/iris std regen-stop", "/iris std regen-stop world=w")
|
||||
.build()
|
||||
.lines()
|
||||
.getLast();
|
||||
|
||||
assertEquals("Stop it with /iris std regen-stop", hint.text().replaceAll("§.", ""));
|
||||
assertEquals("/iris std regen-stop world=w", hint.command());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void chatBodySeparatesTheHintButTheCompactLayoutDoesNot() {
|
||||
ChatReport report = ChatReport.of(ChatReport.Tone.ERROR, "t")
|
||||
.item("Missing dimensions/ folder.")
|
||||
.hint("Run /iris pack validate p", "/iris pack validate p")
|
||||
.build();
|
||||
|
||||
assertEquals(List.of(report.bodyLines(false).get(0), ChatReport.SPACER, report.bodyLines(false).get(1)),
|
||||
report.bodyLines(true));
|
||||
assertEquals(3, report.lines().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void chatShowsANextStepAsOneClickableLine() {
|
||||
ChatReport.Line step = ChatReport.of(ChatReport.Tone.ERROR, "t")
|
||||
.nextStep("See every issue", "/iris pack validate p")
|
||||
.build()
|
||||
.lines()
|
||||
.getLast();
|
||||
|
||||
assertEquals("See every issue: /iris pack validate p", step.text().replaceAll("§.", ""));
|
||||
assertEquals("/iris pack validate p", step.command());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consoleLayoutDrawsTheBodyAsATreeWithNextStepsOnTheirOwnLines() {
|
||||
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.ERROR, "Pack 'uitest' failed validation")
|
||||
.items(List.of(
|
||||
"Biome 'dev'" + REMOVED_FIELD_TAIL,
|
||||
"Biome 'vanilla/grove'" + REMOVED_FIELD_TAIL,
|
||||
"Missing dimensions/ folder."))
|
||||
.nextStep("See every issue", "/iris pack validate uitest")
|
||||
.build());
|
||||
|
||||
assertEquals(List.of(
|
||||
ConsoleGlyphs.CROSS + " Pack 'uitest' failed validation",
|
||||
ConsoleGlyphs.BRANCH + " 2 biomes: caveProfile.allowWater was removed; use caveProfile.allowFluid. Cave aquifers use the dimension fluidPalette.",
|
||||
ConsoleGlyphs.BAR + " dev, vanilla/grove",
|
||||
ConsoleGlyphs.BRANCH + " Missing dimensions/ folder.",
|
||||
ConsoleGlyphs.LAST_BRANCH + " See every issue:",
|
||||
" /iris pack validate uitest"), console);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consoleLayoutKeepsTheReportHighlights() {
|
||||
List<String> console = ChatReport.of(ChatReport.Tone.WARNING, "Pack 'uitest' has 1 warning")
|
||||
.item("Biome 'dev' uses create:limestone at wall.palette[0]. Install the mod.")
|
||||
.build()
|
||||
.consoleLines();
|
||||
|
||||
assertTrue(console.get(0), console.get(0).contains(C.WHITE + "'uitest'" + C.GOLD));
|
||||
assertTrue(console.get(1), console.get(1).contains(C.WHITE + "'dev'" + C.GRAY));
|
||||
assertTrue(console.get(1), console.get(1).contains(C.AQUA + "create:limestone" + C.GRAY));
|
||||
assertTrue(console.get(1), console.get(1).endsWith(C.DARK_GRAY + "Install the mod."));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consoleLayoutKeepsInfoTitlesOnABlankGutter() {
|
||||
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.INFO, "Worlds").item("world").build());
|
||||
|
||||
assertEquals(List.of(" Worlds", ConsoleGlyphs.LAST_BRANCH + " world"), console);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consoleLayoutAlignsLabelledEntries() {
|
||||
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.SUCCESS, "Exported pack 'uitest'")
|
||||
.entry("Folder", "exports/uitest")
|
||||
.entry("Datapack Folder Path", "world/datapacks/iris")
|
||||
.build());
|
||||
|
||||
assertEquals(List.of(
|
||||
ConsoleGlyphs.CHECK + " Exported pack 'uitest'",
|
||||
ConsoleGlyphs.BRANCH + " Folder exports/uitest",
|
||||
ConsoleGlyphs.LAST_BRANCH + " Datapack Folder Path",
|
||||
" world/datapacks/iris"), console);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consoleHintEndingInItsCommandBecomesANextStep() {
|
||||
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.SUCCESS, "Created Studio project 'uitest'")
|
||||
.hint("Restart the server, then run /iris studio open uitest", "/iris studio open uitest")
|
||||
.build());
|
||||
|
||||
assertEquals(List.of(
|
||||
ConsoleGlyphs.CHECK + " Created Studio project 'uitest'",
|
||||
ConsoleGlyphs.LAST_BRANCH + " Restart the server, then run:",
|
||||
" /iris studio open uitest"), console);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consoleNextStepShowsTheCommandAClickWouldRun() {
|
||||
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.INFO, "Regen started")
|
||||
.hint("Stop it with /iris std regen-stop", "/iris std regen-stop", "/iris std regen-stop world=w")
|
||||
.build());
|
||||
|
||||
assertEquals(List.of(" Regen started", ConsoleGlyphs.LAST_BRANCH + " Stop it with:",
|
||||
" /iris std regen-stop world=w"), console);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consoleHintWithoutACommandStaysOneBranch() {
|
||||
List<String> console = plainConsoleLines(ChatReport.of(ChatReport.Tone.WARNING, "Regen is running")
|
||||
.hint("The console has the full refusal notice", null)
|
||||
.build());
|
||||
|
||||
assertEquals(List.of(ConsoleGlyphs.WARNING + " Regen is running", ConsoleGlyphs.LAST_BRANCH + " The console has the full refusal notice"), console);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void logLinesWithoutAGutterGetTheirTonesMark() {
|
||||
assertEquals(ConsoleGlyphs.WARNING + " Default pack is missing",
|
||||
ConsoleLayout.onGutter(ChatReport.Tone.WARNING, "Default pack is missing").replaceAll("§.", ""));
|
||||
assertEquals(" Loading packs",
|
||||
ConsoleLayout.onGutter(ChatReport.Tone.INFO, "Loading packs").replaceAll("§.", ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void logLinesAlreadyOnTheGutterStayAsTheyAre() {
|
||||
String marked = ChatReport.Tone.ERROR.marked("Pack failed");
|
||||
String row = ConsoleLayout.row("Fix the errors above.");
|
||||
String branch = C.RED + ConsoleGlyphs.BRANCH + " " + C.GRAY + "Missing dimensions/ folder.";
|
||||
|
||||
assertEquals(marked, ConsoleLayout.onGutter(ChatReport.Tone.ERROR, marked));
|
||||
assertEquals(row, ConsoleLayout.onGutter(ChatReport.Tone.ERROR, row));
|
||||
assertEquals(branch, ConsoleLayout.onGutter(ChatReport.Tone.ERROR, branch));
|
||||
}
|
||||
|
||||
private static List<String> plainLines(ChatReport report) {
|
||||
return report.lines().stream().map(line -> line.text().replaceAll("§.", "")).toList();
|
||||
}
|
||||
|
||||
private static List<String> plainConsoleLines(ChatReport report) {
|
||||
return report.consoleLines().stream().map(line -> line.replaceAll("§.", "")).toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package art.arcane.iris.localization;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ConsoleGlyphsTest {
|
||||
private static final String REPORT_LINE = " \u00bb Biome \u2039caves\u203a";
|
||||
|
||||
@Test
|
||||
public void utf8ConsoleKeepsGlyphs() {
|
||||
assertEquals(REPORT_LINE, ConsoleGlyphs.forCharset(StandardCharsets.UTF_8).fit(REPORT_LINE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asciiConsoleGetsAsciiGlyphs() {
|
||||
assertEquals(" > Biome [caves]", ConsoleGlyphs.forCharset(StandardCharsets.US_ASCII).fit(REPORT_LINE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asciiConsoleGetsAsciiGlyphsThatKeepTheGutterWidth() {
|
||||
String gutter = ConsoleGlyphs.CROSS + " failed\n" + ConsoleGlyphs.BRANCH + " item\n" + ConsoleGlyphs.BAR + " more\n"
|
||||
+ ConsoleGlyphs.LAST_BRANCH + " Loading" + ConsoleGlyphs.ELLIPSIS + "\n" + ConsoleGlyphs.CHECK + " done\n"
|
||||
+ ConsoleGlyphs.WARNING + " careful";
|
||||
|
||||
assertEquals("x failed\n| item\n| more\n` Loading...\n+ done\n! careful",
|
||||
ConsoleGlyphs.forCharset(StandardCharsets.US_ASCII).fit(gutter));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void latin1ConsoleKeepsWhatItCanEncode() {
|
||||
assertEquals(" \u00bb Biome [caves]", ConsoleGlyphs.forCharset(StandardCharsets.ISO_8859_1).fit(REPORT_LINE));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package art.arcane.iris.pack.loading;
|
||||
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class UnknownFieldReportTest {
|
||||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
private static final File SOURCE_PACK = new File("/server/plugins/Iris/packs/cavetest");
|
||||
private static final File EPOCH_PACK = new File("/server/world/dimensions/iris/cavetest/iris/generation/epochs/"
|
||||
+ "ba9f3038756c38bc3f3a3174f3e7c575b766f76f422a129d6e8eb98380c33b8b/pack");
|
||||
|
||||
@Before
|
||||
public void reset() {
|
||||
UnknownFieldReport.resetForTests();
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanUp() {
|
||||
UnknownFieldReport.resetForTests();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void epochCopyAndRepeatedLoadsCollapseIntoOneEntry() {
|
||||
recordBiomeCaves(SOURCE_PACK, "biomes/carving/volcanic.json", 144);
|
||||
recordBiomeCaves(EPOCH_PACK, "biomes/carving/volcanic.json", 144);
|
||||
recordBiomeCaves(SOURCE_PACK, "biomes/carving/volcanic.json", 144);
|
||||
|
||||
List<String> lines = plain(UnknownFieldReport.drainReports());
|
||||
|
||||
assertEquals(List.of(
|
||||
"▲ Pack 'cavetest' has 1 unknown field. Iris ignores it.",
|
||||
"└ Biome 'caves' 1 file biomes/carving/volcanic.json:144"
|
||||
), lines);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void manyFilesWithTheSameFieldShowOneExampleAndACount() {
|
||||
recordBiomeCaves(SOURCE_PACK, "biomes/carving/deep-ravine.json", 157);
|
||||
recordBiomeCaves(SOURCE_PACK, "biomes/carving/ice-ravine.json", 149);
|
||||
recordBiomeCaves(SOURCE_PACK, "biomes/carving/volcanic.json", 144);
|
||||
UnknownFieldReport.record(SOURCE_PACK, new File(SOURCE_PACK, "dimensions/cavetest.json"), "Dimension", "caves", 856, null);
|
||||
|
||||
List<String> lines = plain(UnknownFieldReport.drainReports());
|
||||
|
||||
assertEquals(List.of(
|
||||
"▲ Pack 'cavetest' has 2 unknown fields. Iris ignores them.",
|
||||
"├ Biome 'caves' 3 files e.g. biomes/carving/deep-ravine.json:157",
|
||||
"└ Dimension 'caves' 1 file dimensions/cavetest.json:856"
|
||||
), lines);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void typoKeepsItsSuggestion() {
|
||||
UnknownFieldReport.record(SOURCE_PACK, new File(SOURCE_PACK, "biomes/x.json"), "Biome", "carvng", 12, "carving");
|
||||
|
||||
List<String> lines = plain(UnknownFieldReport.drainReports());
|
||||
|
||||
assertTrue(lines.get(1).endsWith("biomes/x.json:12 Did you mean 'carving'?"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alreadyReportedFieldsStayQuietInLaterBatches() {
|
||||
recordBiomeCaves(SOURCE_PACK, "biomes/carving/volcanic.json", 144);
|
||||
UnknownFieldReport.drainReports();
|
||||
|
||||
recordBiomeCaves(EPOCH_PACK, "biomes/carving/volcanic.json", 144);
|
||||
|
||||
assertEquals(List.of(), UnknownFieldReport.drainReports());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void studioEpochIsLabelledByItsDimensionNotItsWorldFolder() throws Exception {
|
||||
Path epoch = temporaryFolder.getRoot().toPath()
|
||||
.resolve("world/dimensions/iris/iris-d4521eb8/iris/generation/epochs/d826fe90");
|
||||
Files.createDirectories(epoch.resolve("pack"));
|
||||
Files.writeString(epoch.resolve("epoch.json"), "{\"dimensionContract\":{\"dimensionKey\":\"cavetest\"}}");
|
||||
File studioPack = epoch.resolve("pack").toFile();
|
||||
|
||||
recordBiomeCaves(SOURCE_PACK, "biomes/carving/volcanic.json", 144);
|
||||
recordBiomeCaves(studioPack, "biomes/carving/volcanic.json", 144);
|
||||
|
||||
assertEquals(2, plain(UnknownFieldReport.drainReports()).size());
|
||||
}
|
||||
|
||||
private static void recordBiomeCaves(File pack, String relativePath, int line) {
|
||||
UnknownFieldReport.record(pack, new File(pack, relativePath), "Biome", "caves", line, null);
|
||||
}
|
||||
|
||||
private static List<String> plain(List<ChatReport> reports) {
|
||||
return reports.stream()
|
||||
.flatMap(report -> report.consoleLines().stream())
|
||||
.map(line -> line.replaceAll("(?i)\u00a7[0-9a-fk-orx]|<[^>]+>", ""))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -252,6 +252,16 @@ final class CompatFixtures {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLog() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeaves() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoliagePlantable() {
|
||||
return false;
|
||||
|
||||
+5
-1
@@ -119,8 +119,12 @@ public class BukkitPersistedBlockStateTest {
|
||||
IrisCustomData custom = IrisCustomData.of(carrier, Identifier.fromString(key));
|
||||
ExternalDataSVC provider = mock(ExternalDataSVC.class);
|
||||
when(provider.getBlockData(Identifier.fromString(key))).thenReturn(Optional.of(custom));
|
||||
try (MockedStatic<IrisServices> services = mockStatic(IrisServices.class)) {
|
||||
when(provider.withoutDecay(custom)).thenReturn(custom);
|
||||
IrisSettings configuration = new IrisSettings();
|
||||
try (MockedStatic<IrisServices> services = mockStatic(IrisServices.class);
|
||||
MockedStatic<IrisSettings> settings = mockStatic(IrisSettings.class)) {
|
||||
services.when(() -> IrisServices.get(ExternalDataSVC.class)).thenReturn(provider);
|
||||
settings.when(IrisSettings::get).thenReturn(configuration);
|
||||
NativeBlockState decoded = registries.decodeBlockState(key);
|
||||
assertEquals(key, decoded.key());
|
||||
assertEquals(key, decoded.deferredPlacementKey());
|
||||
|
||||
Loaded 100 of 146 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user