mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-03 19:51:49 +00:00
Compare commits
39
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9413e2ff5f | ||
|
|
8893432b6f | ||
|
|
df31f1e2e3 | ||
|
|
0fa1e01cd3 | ||
|
|
53376816d7 | ||
|
|
aa78a380fd | ||
|
|
3048f6e2bf | ||
|
|
73b3d4a899 | ||
|
|
1c9f62a84c | ||
|
|
46b5c33cf1 | ||
|
|
6fb25fb53e | ||
|
|
3b9cb4ce91 | ||
|
|
7c31231a77 | ||
|
|
5f70643446 | ||
|
|
415aee9f4d | ||
|
|
5a9abb2756 | ||
|
|
01874b1e6f | ||
|
|
b545500abe | ||
|
|
673dda2860 | ||
|
|
2f82ad34a3 | ||
|
|
7b2e28d439 | ||
|
|
38ec1752c1 | ||
|
|
10463d58cc | ||
|
|
a1bf501c30 | ||
|
|
cdb4e68708 | ||
|
|
8531fcf103 | ||
|
|
1144032d62 | ||
|
|
561ec4e0db | ||
|
|
6dd22fa34e | ||
|
|
496bdab2c3 | ||
|
|
b5072e4266 | ||
|
|
36e7e6a337 | ||
|
|
8c9f3bd73d | ||
|
|
ac4bc6b96a | ||
|
|
ebf3ca85cc | ||
|
|
6b1e1e55cb | ||
|
|
4d0063dd7d | ||
|
|
8b98e2a61c | ||
|
|
e0aeabd520 |
No files matched your search
-262
@@ -1,262 +0,0 @@
|
||||
package art.arcane.iris.probe;
|
||||
|
||||
import art.arcane.volmlib.nativelib.common.block.GroundSurvival;
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.modded.ModdedBlockState;
|
||||
import art.arcane.volmlib.nativelib.block.SurvivalAnswer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/** Both platforms ask the server's own canSurvive rule where a plant may stand, against the real block tags. */
|
||||
public final class HeadlessGroundSurvivalTest {
|
||||
private static final Logger NATIVE_LOG = Logger.getLogger("VolmLib-Native");
|
||||
|
||||
@BeforeClass
|
||||
public static void bootstrap() {
|
||||
HeadlessNativeBootstrap.initialize();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void grassStandsOnSoilButNotOnStone() {
|
||||
assertPlacement(true, Blocks.SHORT_GRASS, Blocks.GRASS_BLOCK);
|
||||
assertPlacement(true, Blocks.SHORT_GRASS, Blocks.PODZOL);
|
||||
assertPlacement(false, Blocks.SHORT_GRASS, Blocks.STONE);
|
||||
assertPlacement(false, Blocks.POPPY, Blocks.STONE);
|
||||
assertPlacement(false, Blocks.FERN, Blocks.OAK_LEAVES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cactusNeedsSandOrCactus() {
|
||||
for (Block ground : new Block[]{Blocks.CACTUS, Blocks.SAND, Blocks.RED_SAND}) {
|
||||
assertPlacement(true, Blocks.CACTUS, ground);
|
||||
}
|
||||
assertPlacement(false, Blocks.CACTUS, Blocks.STONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sugarCaneNeedsItsSubstrate() {
|
||||
for (Block ground : new Block[]{Blocks.SUGAR_CANE, Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.COARSE_DIRT,
|
||||
Blocks.PODZOL, Blocks.MYCELIUM, Blocks.ROOTED_DIRT, Blocks.MOSS_BLOCK, Blocks.PALE_MOSS_BLOCK,
|
||||
Blocks.MUD, Blocks.MUDDY_MANGROVE_ROOTS, Blocks.SAND, Blocks.RED_SAND, Blocks.SUSPICIOUS_SAND}) {
|
||||
assertPlacement(true, Blocks.SUGAR_CANE, ground);
|
||||
}
|
||||
for (Block ground : new Block[]{Blocks.STONE, Blocks.GRAVEL, Blocks.CLAY, Blocks.DIRT_PATH,
|
||||
Blocks.FARMLAND, Blocks.AIR, Blocks.WATER}) {
|
||||
assertPlacement(false, Blocks.SUGAR_CANE, ground);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void netherGroundCoverAcceptsNyliumAndSoulSoilButRejectsBarrenBlocks() {
|
||||
for (Block plant : new Block[]{Blocks.CRIMSON_ROOTS, Blocks.WARPED_ROOTS, Blocks.NETHER_SPROUTS}) {
|
||||
for (Block ground : new Block[]{Blocks.CRIMSON_NYLIUM, Blocks.WARPED_NYLIUM, Blocks.SOUL_SOIL}) {
|
||||
assertPlacement(true, plant, ground);
|
||||
}
|
||||
for (Block ground : new Block[]{Blocks.NETHERRACK, Blocks.STONE, Blocks.GRAVEL, Blocks.AIR}) {
|
||||
assertPlacement(false, plant, ground);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void blocksThatRestOnNoGroundStillFit() {
|
||||
assertPlacement(true, Blocks.WALL_TORCH, Blocks.STONE);
|
||||
assertPlacement(true, Blocks.VINE, Blocks.SAND);
|
||||
assertPlacement(true, Blocks.COCOA, Blocks.STONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deadBushStaysOffGrassAsPacksExpect() {
|
||||
assertPlacement(true, Blocks.DEAD_BUSH, Blocks.SAND);
|
||||
assertPlacement(false, Blocks.DEAD_BUSH, Blocks.GRASS_BLOCK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nothingStandsOnAir() {
|
||||
assertPlacement(false, Blocks.VINE, Blocks.AIR);
|
||||
assertPlacement(false, Blocks.SHORT_GRASS, Blocks.CAVE_AIR);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void plantsThatReadMoreOfTheLevelAreAnsweredByTheirOwnRule() {
|
||||
List<LogRecord> warnings = warningsDuring(() -> {
|
||||
assertPlacement(true, Blocks.BAMBOO, Blocks.GRASS_BLOCK);
|
||||
assertPlacement(false, Blocks.BAMBOO, Blocks.STONE);
|
||||
assertPlacement(true, Blocks.KELP, Blocks.STONE);
|
||||
assertPlacement(false, Blocks.KELP, Blocks.MAGMA_BLOCK);
|
||||
assertPlacement(true, Blocks.SEAGRASS, Blocks.SAND);
|
||||
assertPlacement(false, Blocks.SEAGRASS, Blocks.MAGMA_BLOCK);
|
||||
assertPlacement(true, Blocks.LILY_PAD, Blocks.WATER);
|
||||
assertPlacement(false, Blocks.LILY_PAD, Blocks.STONE);
|
||||
assertPlacement(true, Blocks.SWEET_BERRY_BUSH, Blocks.GRASS_BLOCK);
|
||||
assertPlacement(false, Blocks.SWEET_BERRY_BUSH, Blocks.STONE);
|
||||
assertPlacement(true, Blocks.BROWN_MUSHROOM, Blocks.STONE);
|
||||
assertPlacement(true, Blocks.RED_MUSHROOM, Blocks.MYCELIUM);
|
||||
assertPlacement(false, Blocks.BROWN_MUSHROOM, Blocks.GLASS);
|
||||
assertPlacement(true, Blocks.CRIMSON_FUNGUS, Blocks.CRIMSON_NYLIUM);
|
||||
assertPlacement(false, Blocks.WARPED_FUNGUS, Blocks.NETHERRACK);
|
||||
assertPlacement(true, Blocks.WHEAT, Blocks.FARMLAND);
|
||||
assertPlacement(false, Blocks.CARROTS, Blocks.DIRT);
|
||||
});
|
||||
assertEquals(messages(warnings), 0, warnings.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void everyVanillaBlockIsAnsweredWithoutFailingOpen() {
|
||||
GroundSurvival survival = new GroundSurvival();
|
||||
List<LogRecord> warnings = warningsDuring(() -> {
|
||||
for (Block plant : BuiltInRegistries.BLOCK) {
|
||||
if (needsARunningPaperServer(plant)) {
|
||||
continue;
|
||||
}
|
||||
for (Block ground : new Block[]{Blocks.GRASS_BLOCK, Blocks.STONE, Blocks.WATER}) {
|
||||
survival.canSurviveOn(plant.defaultBlockState(), ground.defaultBlockState());
|
||||
}
|
||||
}
|
||||
});
|
||||
assertEquals(messages(warnings), 0, warnings.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aRuleThatThrowsIsLeftUnansweredAndWarnsOncePerBlock() {
|
||||
BlockState firstState = throwingStateOf(Blocks.SHORT_GRASS);
|
||||
BlockState secondState = throwingStateOf(Blocks.SHORT_GRASS);
|
||||
GroundSurvival survival = new GroundSurvival();
|
||||
List<LogRecord> warnings = warningsDuring(() -> {
|
||||
for (BlockState plant : new BlockState[]{firstState, secondState}) {
|
||||
for (Block ground : new Block[]{Blocks.STONE, Blocks.SAND, Blocks.GRASS_BLOCK}) {
|
||||
assertEquals(SurvivalAnswer.UNANSWERED, survival.canSurviveOn(plant, ground.defaultBlockState()));
|
||||
}
|
||||
}
|
||||
});
|
||||
assertEquals(messages(warnings), 1, warnings.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aRuleThatThrowsFallsBackToThePlacementTable() {
|
||||
ModdedBlockState grass = ModdedBlockState.deferred(throwingStateOf(Blocks.SHORT_GRASS), Map.of(), "iris:test");
|
||||
warningsDuring(() -> {
|
||||
assertTrue(grass.canPlaceOnto(wrap(Blocks.GRASS_BLOCK)));
|
||||
assertFalse(grass.canPlaceOnto(wrap(Blocks.STONE)));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aRuleThatOnlyAnswersForSomeGroundsDoesNotPassAsAWallBlock() {
|
||||
BlockState plant = mock(BlockState.class);
|
||||
when(plant.getBlock()).thenReturn(Blocks.SHORT_GRASS);
|
||||
when(plant.canSurvive(any(), any())).thenAnswer(asked -> {
|
||||
LevelReader level = asked.getArgument(0);
|
||||
BlockPos plantPos = asked.getArgument(1);
|
||||
if (level.getBlockState(plantPos.below()).is(Blocks.STONE)) {
|
||||
return false;
|
||||
}
|
||||
throw new IllegalStateException("custom rule failed");
|
||||
});
|
||||
GroundSurvival survival = new GroundSurvival();
|
||||
warningsDuring(() -> assertEquals(SurvivalAnswer.UNANSWERED,
|
||||
survival.canSurviveOn(plant, Blocks.STONE.defaultBlockState())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generatorThreadsAskingAtOnceGetTheSameAnswers() {
|
||||
Block[] plants = {Blocks.SHORT_GRASS, Blocks.CACTUS, Blocks.SUGAR_CANE, Blocks.VINE, Blocks.BROWN_MUSHROOM};
|
||||
Block[] grounds = {Blocks.GRASS_BLOCK, Blocks.SAND, Blocks.STONE, Blocks.WATER};
|
||||
GroundSurvival alone = new GroundSurvival();
|
||||
GroundSurvival shared = new GroundSurvival();
|
||||
List<Integer> threads = Arrays.asList(new Integer[16]);
|
||||
threads.parallelStream().forEach(ignored -> {
|
||||
for (Block plant : plants) {
|
||||
for (Block ground : grounds) {
|
||||
assertEquals(plant + " on " + ground,
|
||||
alone.canSurviveOn(plant.defaultBlockState(), ground.defaultBlockState()),
|
||||
shared.canSurviveOn(plant.defaultBlockState(), ground.defaultBlockState()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Paper's chorus plant reads Paper's global configuration, which only a running server loads.
|
||||
private static boolean needsARunningPaperServer(Block plant) {
|
||||
return plant == Blocks.CHORUS_PLANT;
|
||||
}
|
||||
|
||||
private static BlockState throwingStateOf(Block block) {
|
||||
BlockState state = mock(BlockState.class);
|
||||
when(state.getBlock()).thenReturn(block);
|
||||
when(state.isSingletonState()).thenReturn(true);
|
||||
when(state.canSurvive(any(), any())).thenThrow(new IllegalStateException("custom rule failed"));
|
||||
return state;
|
||||
}
|
||||
|
||||
private static void assertPlacement(boolean expected, Block plant, Block ground) {
|
||||
String pair = plant + " on " + ground;
|
||||
assertEquals("modded " + pair, expected, moddedPlacement(plant, ground));
|
||||
assertEquals("bukkit native " + pair, expected ? SurvivalAnswer.SURVIVES : SurvivalAnswer.FAILS,
|
||||
new GroundSurvival().canSurviveOn(plant.defaultBlockState(), ground.defaultBlockState()));
|
||||
}
|
||||
|
||||
private static boolean moddedPlacement(Block plant, Block ground) {
|
||||
return wrap(plant).canPlaceOnto(wrap(ground));
|
||||
}
|
||||
|
||||
private static ModdedBlockState wrap(Block block) {
|
||||
return ModdedBlockState.deferred(block.defaultBlockState(), Map.of(), "iris:test");
|
||||
}
|
||||
|
||||
private static List<LogRecord> warningsDuring(Runnable checks) {
|
||||
List<LogRecord> warnings = new CopyOnWriteArrayList<>();
|
||||
Handler capture = new Handler() {
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
if (record.getLevel().intValue() >= Level.WARNING.intValue()) {
|
||||
warnings.add(record);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
};
|
||||
NATIVE_LOG.addHandler(capture);
|
||||
try {
|
||||
checks.run();
|
||||
} finally {
|
||||
NATIVE_LOG.removeHandler(capture);
|
||||
}
|
||||
return warnings;
|
||||
}
|
||||
|
||||
private static String messages(List<LogRecord> warnings) {
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (LogRecord warning : warnings) {
|
||||
text.append(warning.getMessage()).append(" (").append(warning.getThrown()).append(")\n");
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
}
|
||||
@@ -40,12 +40,20 @@ final class IrisBootstrapSequence {
|
||||
requireUsableWorldStorage(startupPaths);
|
||||
ProvisionResult provisioned = provision(context, startupPaths);
|
||||
Path datapackRoot = provisioned.datapackRoot();
|
||||
context.getLogger().info("Iris startup datapack is {} at {}", provisioned.status(), datapackRoot);
|
||||
context.getLogger().info("{} {}", provisionOutcome(provisioned.status()), datapackRoot);
|
||||
} catch (Throwable failure) {
|
||||
armStartupFailure(context, failure);
|
||||
}
|
||||
}
|
||||
|
||||
private static String provisionOutcome(DefaultPackBootstrapProvisioner.ProvisionStatus status) {
|
||||
return switch (status) {
|
||||
case INSTALLED -> "Installed the startup datapack at";
|
||||
case UPDATED -> "Updated the startup datapack at";
|
||||
case UNCHANGED -> "The startup datapack is already up to date at";
|
||||
};
|
||||
}
|
||||
|
||||
private static void loadRuntimeLibraries(BootstrapContext context) {
|
||||
SlimJar.loadBootstrap(
|
||||
context.getDataDirectory().resolve("cache").resolve("libraries"),
|
||||
|
||||
@@ -22,8 +22,12 @@ import art.arcane.iris.api.terrain.IrisTerrainService;
|
||||
import art.arcane.iris.command.CommandSVC;
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.configuration.SettingsHotloadWatch;
|
||||
import art.arcane.iris.diagnostics.BuildChannel;
|
||||
import art.arcane.iris.diagnostics.DiagnosticsReport;
|
||||
import art.arcane.iris.diagnostics.LogFilterSVC;
|
||||
import art.arcane.iris.diagnostics.splash.IrisSplashComposer;
|
||||
import art.arcane.iris.diagnostics.splash.IrisSplashPackScanner;
|
||||
import art.arcane.iris.pack.DefaultPackBootstrapProvisioner;
|
||||
import art.arcane.iris.generation.concurrent.MultiBurst;
|
||||
import art.arcane.iris.generation.decoration.tree.TreeBlockMaterial;
|
||||
import art.arcane.iris.generation.runtime.BlockEditAccess;
|
||||
@@ -47,6 +51,9 @@ import art.arcane.iris.integration.IrisPapiState;
|
||||
import art.arcane.iris.integration.MultiverseCoreLink;
|
||||
import art.arcane.iris.integration.MultiverseSVC;
|
||||
import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.localization.ConsoleGlyphs;
|
||||
import art.arcane.iris.localization.ConsoleLayout;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.pack.datapack.DatapackIngestService;
|
||||
import art.arcane.iris.pack.datapack.DatapackIngestService.StartupValidationOutcome;
|
||||
@@ -58,7 +65,6 @@ import art.arcane.iris.platform.agent.AttachSignal;
|
||||
import art.arcane.iris.platform.bootstrap.Bindings;
|
||||
import art.arcane.iris.platform.bootstrap.ServerProperties;
|
||||
import art.arcane.iris.platform.bootstrap.SlimJar;
|
||||
import art.arcane.iris.platform.bukkit.BlockRulesSVC;
|
||||
import art.arcane.iris.platform.bukkit.BoardSVC;
|
||||
import art.arcane.iris.platform.bukkit.BukkitPlatform;
|
||||
import art.arcane.iris.platform.bukkit.api.IrisApiEventSVC;
|
||||
@@ -142,9 +148,11 @@ import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -260,7 +268,7 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
||||
if (current == null) {
|
||||
Iris plugin = Iris.instance;
|
||||
current = new VolmitSender(Bukkit.getConsoleSender());
|
||||
current.setTag(plugin == null ? IrisSafeguard.mode().tag("") : plugin.getTag());
|
||||
current.setTag(logPrefix());
|
||||
sender = current;
|
||||
}
|
||||
return current;
|
||||
@@ -307,17 +315,22 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
||||
static void msg(String string) {
|
||||
try {
|
||||
Iris plugin = Iris.instance;
|
||||
String markup = ConsoleGlyphs.console().fit(ConsoleLayout.onGutter(ChatReport.Tone.INFO, string));
|
||||
if (shadesConsole()) {
|
||||
logShaded(Level.INFO, logPrefix() + markup);
|
||||
return;
|
||||
}
|
||||
ComponentLog.logMarkup(
|
||||
plugin,
|
||||
Logger.getLogger("Iris"),
|
||||
logPrefix(plugin),
|
||||
logPrefix(),
|
||||
Level.INFO,
|
||||
string,
|
||||
markup,
|
||||
null);
|
||||
} catch (Throwable e) {
|
||||
try {
|
||||
Iris plugin = Iris.instance;
|
||||
String plainPrefix = ComponentText.legacy(logPrefix(plugin)).plain();
|
||||
String plainPrefix = ComponentText.legacy(logPrefix()).plain();
|
||||
Logger.getLogger("Iris").log(Level.INFO, plainPrefix + IrisLogging.clean(string));
|
||||
} catch (Throwable inner) {
|
||||
System.err.println("[Iris] Failed to emit log message: " + inner.getMessage());
|
||||
@@ -400,11 +413,11 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
||||
}
|
||||
|
||||
static void success(String string) {
|
||||
Iris.msg(C.IRIS + string);
|
||||
Iris.msg(ChatReport.Tone.SUCCESS.marked(ChatReport.Tone.SUCCESS.consolePaint(string)));
|
||||
}
|
||||
|
||||
static void info(String format, Object... args) {
|
||||
Iris.msg(C.WHITE + safeFormat(format, args));
|
||||
Iris.msg(safeFormat(format, args));
|
||||
}
|
||||
|
||||
private static String safeFormat(String format, Object... args) {
|
||||
@@ -598,20 +611,41 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
||||
};
|
||||
}
|
||||
|
||||
private static void diagnostic(Level level, String message) {
|
||||
String line = IrisLogging.clean(message);
|
||||
private static void diagnostic(Level level, String rawMessage) {
|
||||
String message = ConsoleGlyphs.console().fit(ConsoleLayout.onGutter(diagnosticTone(level), rawMessage));
|
||||
if (shadesConsole()) {
|
||||
logShaded(level, logPrefix() + C.escapeTags(message));
|
||||
return;
|
||||
}
|
||||
Iris plugin = Iris.instance;
|
||||
ComponentLog.log(
|
||||
ComponentLog.logLegacy(
|
||||
plugin,
|
||||
Logger.getLogger("Iris"),
|
||||
logPrefix(plugin),
|
||||
logPrefix(),
|
||||
level,
|
||||
ComponentText.literal(line),
|
||||
message,
|
||||
null);
|
||||
}
|
||||
|
||||
private static String logPrefix(Iris plugin) {
|
||||
return plugin == null ? ComponentLog.discriminator("Iris", "&a") : plugin.getTag();
|
||||
private static ChatReport.Tone diagnosticTone(Level level) {
|
||||
if (level == Level.SEVERE) {
|
||||
return ChatReport.Tone.ERROR;
|
||||
}
|
||||
return level == Level.WARNING ? ChatReport.Tone.WARNING : ChatReport.Tone.INFO;
|
||||
}
|
||||
|
||||
private static boolean shadesConsole() {
|
||||
return IrisSettings.get().getGeneral().isUseConsoleCustomColors();
|
||||
}
|
||||
|
||||
private static void logShaded(Level level, String prefixedLine) {
|
||||
IrisSettings.IrisSettingsGeneral general = IrisSettings.get().getGeneral();
|
||||
String shaded = C.aura(prefixedLine, general.getSpinh(), general.getSpins(), general.getSpinb());
|
||||
ComponentLog.logMarkup(Iris.instance, Logger.getLogger("Iris"), "", level, shaded, null);
|
||||
}
|
||||
|
||||
private static String logPrefix() {
|
||||
return ConsoleGlyphs.console().fit(IrisSafeguard.mode().logTag());
|
||||
}
|
||||
|
||||
static int irisVersion(String input) {
|
||||
@@ -682,7 +716,6 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
||||
new GlobalCacheSVC(),
|
||||
new LogFilterSVC(),
|
||||
new ExternalDataSVC(),
|
||||
new BlockRulesSVC(),
|
||||
new EditSVC(),
|
||||
new ObjectSVC(),
|
||||
new ObjectStudioSaveService(),
|
||||
@@ -718,7 +751,7 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
||||
timings.mark("datapacks");
|
||||
IrisSafeguard.execute();
|
||||
timings.mark("safeguard");
|
||||
getSender().setTag(plugin.getTag());
|
||||
getSender().setTag(logPrefix());
|
||||
// A cosmetic banner must never abort the bootstrap.
|
||||
J.attempt(this::splash);
|
||||
IrisSafeguard.printReports();
|
||||
@@ -809,27 +842,34 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
||||
timings.mark("startupTasks");
|
||||
IrisLanguage.checkUpstream();
|
||||
timings.report();
|
||||
if (BuildChannel.current().isDevelopment()) {
|
||||
J.attempt(IrisRuntime::printDiagnostics);
|
||||
}
|
||||
}
|
||||
|
||||
private static void printDiagnostics() {
|
||||
DiagnosticsReport.sections(IrisWorldGeneratorResolver::awaitsExternalContent)
|
||||
.forEach(section -> section.report().consoleLines().forEach(IrisLogging::notice));
|
||||
}
|
||||
|
||||
private static DebugDumpContributor.Report captureDebugReport() {
|
||||
String language = IrisLanguage.debugReport();
|
||||
return () -> IrisSafeguard.debugReport() + "\n" + language;
|
||||
String diagnostics = DiagnosticsReport.plainText(IrisWorldGeneratorResolver::awaitsExternalContent);
|
||||
return () -> IrisSafeguard.debugReport() + "\n" + language + "\n" + diagnostics;
|
||||
}
|
||||
|
||||
private static final class EnableTimings {
|
||||
private static final int REPORTED_SERVICES = 3;
|
||||
private static final long REPORTED_PHASE_MIN_MS = 100;
|
||||
private static final long SLOW_SERVICE_MIN_MS = 1000;
|
||||
|
||||
private final long startedAt = System.nanoTime();
|
||||
private final StringBuilder phases = new StringBuilder();
|
||||
private final Map<String, Long> phaseMillis = new LinkedHashMap<>();
|
||||
private final Map<String, Long> serviceMillis = new LinkedHashMap<>();
|
||||
private long lastMark = startedAt;
|
||||
|
||||
private void mark(String phase) {
|
||||
long now = System.nanoTime();
|
||||
if (!phases.isEmpty()) {
|
||||
phases.append(' ');
|
||||
}
|
||||
phases.append(phase).append('=').append(TimeUnit.NANOSECONDS.toMillis(now - lastMark)).append("ms");
|
||||
phaseMillis.put(phase, TimeUnit.NANOSECONDS.toMillis(now - lastMark));
|
||||
lastMark = now;
|
||||
}
|
||||
|
||||
@@ -838,16 +878,35 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
||||
}
|
||||
|
||||
private void report() {
|
||||
IrisLogging.notice("Enabled in %dms (%s)",
|
||||
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startedAt), phases);
|
||||
String slowest = serviceMillis.entrySet().stream()
|
||||
.sorted(Map.Entry.<String, Long>comparingByValue().reversed())
|
||||
.limit(REPORTED_SERVICES)
|
||||
.map(entry -> entry.getKey() + "=" + entry.getValue() + "ms")
|
||||
.collect(Collectors.joining(" "));
|
||||
if (!slowest.isBlank()) {
|
||||
IrisLogging.notice("Slowest services: %s", slowest);
|
||||
String total = seconds(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startedAt));
|
||||
ChatReport.Builder report = ChatReport.of(ChatReport.Tone.SUCCESS, "Enabled in " + total).unlimited();
|
||||
slowestFirst(phaseMillis, REPORTED_PHASE_MIN_MS)
|
||||
.forEach(phase -> report.entry(titleCase(phase.getKey()), seconds(phase.getValue())));
|
||||
String slowServices = slowestFirst(serviceMillis, SLOW_SERVICE_MIN_MS).stream()
|
||||
.map(service -> service.getKey() + " " + seconds(service.getValue()))
|
||||
.collect(Collectors.joining(", "));
|
||||
if (!slowServices.isEmpty()) {
|
||||
report.entry("Slow Services", slowServices);
|
||||
}
|
||||
report.build().consoleLines().forEach(IrisLogging::notice);
|
||||
}
|
||||
|
||||
private static List<Map.Entry<String, Long>> slowestFirst(Map<String, Long> millisByName, long minimumMillis) {
|
||||
return millisByName.entrySet().stream()
|
||||
.filter(entry -> entry.getValue() >= minimumMillis)
|
||||
.sorted(Map.Entry.<String, Long>comparingByValue().reversed())
|
||||
.toList();
|
||||
}
|
||||
|
||||
private static String titleCase(String camelCaseName) {
|
||||
String spaced = camelCaseName.replaceAll("(?<=[a-z])(?=[A-Z])", " ");
|
||||
return Arrays.stream(spaced.split(" "))
|
||||
.map(word -> word.isEmpty() ? word : Character.toUpperCase(word.charAt(0)) + word.substring(1))
|
||||
.collect(Collectors.joining(" "));
|
||||
}
|
||||
|
||||
private static String seconds(long millis) {
|
||||
return String.format(Locale.ROOT, "%.1fs", millis / 1000.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -932,7 +991,7 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
||||
Iris.debug("Starting up auto Studio!");
|
||||
try {
|
||||
Player r = new KList<>(plugin.getServer().getOnlinePlayers()).getRandom();
|
||||
Iris.service(StudioSVC.class).open(r != null ? new VolmitSender(r) : getSender(), 1337, IrisSettings.get().getGenerator().getDefaultWorldType(), (w) -> {
|
||||
Iris.service(StudioSVC.class).open(r != null ? new VolmitSender(r, plugin.getTag()) : getSender(), 1337, IrisSettings.get().getGenerator().getDefaultWorldType(), (w) -> {
|
||||
J.s(() -> {
|
||||
final Location spawn = w.getSpawnLocation();
|
||||
for (Player i : plugin.getServer().getOnlinePlayers()) {
|
||||
@@ -1492,15 +1551,38 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
||||
}
|
||||
|
||||
private void splash() {
|
||||
Iris.info("Custom Biomes: " + INMS.get().countCustomBiomes());
|
||||
printPacks();
|
||||
|
||||
IrisSafeguard.mode().trySplash();
|
||||
File packFolder = Iris.service(StudioSVC.class).getWorkspaceFolder();
|
||||
List<IrisSplashPackScanner.SplashPackMetadata> packs = IrisSplashPackScanner.collect(packFolder, Iris::reportError);
|
||||
List<List<IrisSplashComposer.Detail>> startupFacts = startupFacts(packs);
|
||||
if (IrisSettings.get().getGeneral().isSplashLogoStartup()) {
|
||||
printWithoutLogPrefix(IrisSafeguard.mode().composeSplash(startupFacts));
|
||||
} else {
|
||||
startupFacts.forEach(row -> Iris.info(IrisSplashComposer.plainRow(row)));
|
||||
}
|
||||
announcePackUpdates(packs);
|
||||
}
|
||||
|
||||
private void printPacks() {
|
||||
File packFolder = Iris.service(StudioSVC.class).getWorkspaceFolder();
|
||||
IrisSplashComposer.composePackLines(packFolder, Iris::reportError).thenAccept(lines -> {
|
||||
private void printWithoutLogPrefix(String text) {
|
||||
if (shadesConsole()) {
|
||||
ComponentLog.logMarkup(plugin, Logger.getLogger("Iris"), "", Level.INFO, C.mini(C.escapeTags(text)), null);
|
||||
return;
|
||||
}
|
||||
ComponentLog.logLegacy(plugin, Logger.getLogger("Iris"), "", Level.INFO, text, null);
|
||||
}
|
||||
|
||||
private static List<List<IrisSplashComposer.Detail>> startupFacts(List<IrisSplashPackScanner.SplashPackMetadata> packs) {
|
||||
boolean eagerInjection = IrisSettings.get().getGeneral().isEagerRuntimeInjection();
|
||||
boolean datapackFromBootstrap = DefaultPackBootstrapProvisioner.wasProvisionedThisStartup();
|
||||
return List.of(
|
||||
List.of(IrisSplashComposer.Detail.headline("Packs", IrisSplashComposer.packSummary(packs))),
|
||||
List.of(new IrisSplashComposer.Detail("Custom biomes", String.valueOf(INMS.get().countCustomBiomes()))),
|
||||
List.of(new IrisSplashComposer.Detail("SIMD", SimdSupport.shortStatus()),
|
||||
new IrisSplashComposer.Detail("Datapack", datapackFromBootstrap ? "bootstrap" : "startup install"),
|
||||
new IrisSplashComposer.Detail("Injection", eagerInjection ? "eager" : "deferred")));
|
||||
}
|
||||
|
||||
private void announcePackUpdates(List<IrisSplashPackScanner.SplashPackMetadata> packs) {
|
||||
IrisSplashComposer.composeUpdateLines(packs).thenAccept(lines -> {
|
||||
if (plugin.isEnabled()) {
|
||||
lines.forEach(Iris::info);
|
||||
}
|
||||
|
||||
@@ -18,11 +18,16 @@
|
||||
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.ExportVersionHandler;
|
||||
import art.arcane.iris.command.specialhandlers.InstalledDatapackHandler;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.command.handlers.DimensionHandler;
|
||||
import art.arcane.iris.command.specialhandlers.ExportFormatHandler;
|
||||
import art.arcane.iris.command.specialhandlers.ExportModeHandler;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.localization.BukkitCommandMessages;
|
||||
import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.localization.DirectorCommandMessages;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.pack.datapack.DataVersion;
|
||||
@@ -46,12 +51,14 @@ import art.arcane.volmlib.util.localization.LanguageAudience;
|
||||
import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
import art.arcane.volmlib.util.localization.TextKey;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Director(name = "datapack", aliases = {"datapacks", "dp"}, description = "Download & manage external datapack imports", descriptionKey = "iris.director.commanddatapack.director.download_manage_external_datapack_imports_modrinth")
|
||||
public class CommandDatapack implements DirectorExecutor {
|
||||
private static final int RESOURCE_REPORTS = 4;
|
||||
private static final int EXPORT_DIAGNOSTIC_LIMIT = 10;
|
||||
|
||||
@Director(description = "Download/update every datapack listed in a pack dimension's 'datapackImports' and install it into the world so its structures register like vanilla", descriptionKey = "iris.director.commanddatapack.director.download_update_every_datapack_listed_pack_dimension_s_datapackimports_install_it_into", aliases = {"pull"})
|
||||
public void ingest(
|
||||
@@ -69,24 +76,27 @@ public class CommandDatapack implements DirectorExecutor {
|
||||
KList<String> configured = DatapackIngestService.collectConfiguredImports();
|
||||
List<DatapackIngestService.Entry> installed = DatapackIngestService.installed();
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_CONFIGURED_DATAPACK_IMPORTS, MessageArgument.untrusted("value", configured.size())));
|
||||
for (String url : configured) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_MESSAGE, MessageArgument.untrusted("url", url)));
|
||||
}
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_INSTALLED_DATAPACKS, MessageArgument.untrusted("value", installed.size())));
|
||||
for (DatapackIngestService.Entry entry : installed) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_MESSAGE_2, MessageArgument.untrusted("value", entry.id), MessageArgument.untrusted("value2", (entry.versionNumber == null ? "?" : entry.versionNumber))));
|
||||
}
|
||||
|
||||
ChatReport.Builder imports = ChatReport.of(ChatReport.Tone.INFO,
|
||||
IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_CONFIGURED_DATAPACK_IMPORTS, MessageArgument.untrusted("value", configured.size())))
|
||||
.unlimited()
|
||||
.items(configured);
|
||||
if (configured.isEmpty()) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_ADD_MODRINTH_URLS_DIMENSION_S_DATAPACKIMPORTS_LIST_THEN_RUN_IRIS));
|
||||
imports.hint(IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_ADD_MODRINTH_URLS_DIMENSION_S_DATAPACKIMPORTS_LIST_THEN_RUN_IRIS), null);
|
||||
}
|
||||
sender.sendReport(imports.build());
|
||||
|
||||
ChatReport.Builder installedReport = ChatReport.of(ChatReport.Tone.INFO,
|
||||
IrisLanguage.text(BukkitCommandMessages.COMMAND_DATAPACK_INSTALLED_DATAPACKS, MessageArgument.untrusted("value", installed.size())))
|
||||
.unlimited();
|
||||
for (DatapackIngestService.Entry entry : installed) {
|
||||
installedReport.entry(entry.id, entry.versionNumber == null ? "?" : entry.versionNumber);
|
||||
}
|
||||
sender.sendReport(installedReport.build());
|
||||
}
|
||||
|
||||
@Director(description = "Remove an installed datapack by id (also delete its URL from datapackImports to keep it gone)", descriptionKey = "iris.director.commanddatapack.director.remove_installed_datapack_by_id_also_delete_its_url_from_datapackimports_keep", aliases = {"rm"})
|
||||
public void remove(
|
||||
@Param(description = "The datapack id (folder name) shown by /iris datapack list", descriptionKey = "iris.director.commanddatapack.param.datapack_id_folder_name_shown_by_iris_datapack_list")
|
||||
@Param(description = "The datapack id (folder name) shown by /iris datapack list", descriptionKey = "iris.director.commanddatapack.param.datapack_id_folder_name_shown_by_iris_datapack_list", customHandler = InstalledDatapackHandler.class)
|
||||
String id
|
||||
) {
|
||||
DatapackIngestService.remove(sender(), id);
|
||||
@@ -96,15 +106,15 @@ public class CommandDatapack implements DirectorExecutor {
|
||||
public void export(
|
||||
@Param(name = "dimension", description = "The dimension to export", descriptionKey = "iris.director.commanddatapack.param.export_dimension", customHandler = DimensionHandler.class)
|
||||
IrisDimension dimension,
|
||||
@Param(name = "version", description = "Target Minecraft version, 26.3 or later (blank uses the latest)", descriptionKey = "iris.director.commanddatapack.param.export_version", defaultValue = "")
|
||||
@Param(name = "version", description = "Target Minecraft version, 26.3 or later (blank uses the latest)", descriptionKey = "iris.director.commanddatapack.param.export_version", defaultValue = "", customHandler = ExportVersionHandler.class)
|
||||
String version,
|
||||
@Param(name = "mode", description = "Output mode: preset, dimension, or overworld", descriptionKey = "iris.director.commanddatapack.param.export_mode", defaultValue = WorldgenExportRequest.DEFAULT_MODE)
|
||||
@Param(name = "mode", description = "Output mode: preset, dimension, or overworld", descriptionKey = "iris.director.commanddatapack.param.export_mode", defaultValue = WorldgenExportRequest.DEFAULT_MODE, customHandler = ExportModeHandler.class)
|
||||
String mode,
|
||||
@Param(name = "namespace", description = "Namespace for the exported resources", descriptionKey = "iris.director.commanddatapack.param.export_namespace", defaultValue = WorldgenExportRequest.DEFAULT_NAMESPACE)
|
||||
String namespace,
|
||||
@Param(name = "output", description = "Output name in the datapack exports folder (blank uses the dimension and version)", descriptionKey = "iris.director.commanddatapack.param.export_output", defaultValue = "")
|
||||
String output,
|
||||
@Param(name = "format", description = "zip or directory", descriptionKey = "iris.director.commanddatapack.param.export_format", defaultValue = WorldgenExportRequest.DEFAULT_FORMAT)
|
||||
@Param(name = "format", description = "zip or directory", descriptionKey = "iris.director.commanddatapack.param.export_format", defaultValue = WorldgenExportRequest.DEFAULT_FORMAT, customHandler = ExportFormatHandler.class)
|
||||
String format,
|
||||
@Param(name = "objects", description = "Include objects as structure templates", descriptionKey = "iris.director.commanddatapack.param.export_objects", defaultValue = "true")
|
||||
boolean objects,
|
||||
@@ -158,17 +168,33 @@ public class CommandDatapack implements DirectorExecutor {
|
||||
}
|
||||
|
||||
private static void reportExport(ExportFeedback feedback, WorldgenExportResult result) {
|
||||
for (ExportDiagnostic diagnostic : result.diagnostics()) {
|
||||
feedback.send(diagnosticColor(diagnostic.severity()), IrisLanguage.text(DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_DIAGNOSTIC, MessageArgument.untrusted("key", diagnosticLabel(diagnostic)), MessageArgument.untrusted("message", diagnostic.message())));
|
||||
ChatReport.Builder report = ChatReport.of(exportTone(result), exportTitle(result)).limit(EXPORT_DIAGNOSTIC_LIMIT);
|
||||
result.diagnostics().stream()
|
||||
.sorted(Comparator.comparingInt((ExportDiagnostic diagnostic) -> diagnostic.severity().ordinal()).reversed())
|
||||
.forEach(diagnostic -> report.styledItem(diagnosticColor(diagnostic.severity())
|
||||
+ ChatReport.clean(IrisLanguage.text(DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_DIAGNOSTIC,
|
||||
MessageArgument.untrusted("key", diagnosticLabel(diagnostic)),
|
||||
MessageArgument.untrusted("message", diagnostic.message())))));
|
||||
feedback.report(report.build());
|
||||
}
|
||||
|
||||
private static ChatReport.Tone exportTone(WorldgenExportResult result) {
|
||||
if (!result.isSuccess()) {
|
||||
return ChatReport.Tone.ERROR;
|
||||
}
|
||||
boolean warned = result.diagnostics().stream()
|
||||
.anyMatch(diagnostic -> diagnostic.severity() != ExportDiagnostic.Severity.INFO);
|
||||
return warned ? ChatReport.Tone.WARNING : ChatReport.Tone.SUCCESS;
|
||||
}
|
||||
|
||||
private static String exportTitle(WorldgenExportResult result) {
|
||||
if (result.isSuccess()) {
|
||||
feedback.send(C.GREEN, IrisLanguage.text(DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_EXPORTED, MessageArgument.untrusted("path", result.output())));
|
||||
return;
|
||||
return IrisLanguage.text(DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_EXPORTED, MessageArgument.untrusted("path", result.output()));
|
||||
}
|
||||
TextKey outcome = result.status() == WorldgenExportResult.Status.REJECTED
|
||||
? DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_REJECTED
|
||||
: DirectorCommandMessages.COMMAND_DATAPACK_EXPORT_FAILED;
|
||||
feedback.send(C.RED, IrisLanguage.text(outcome, MessageArgument.untrusted("reason", result.message())));
|
||||
return IrisLanguage.text(outcome, MessageArgument.untrusted("reason", result.message()));
|
||||
}
|
||||
|
||||
private static C diagnosticColor(ExportDiagnostic.Severity severity) {
|
||||
@@ -208,11 +234,19 @@ public class CommandDatapack implements DirectorExecutor {
|
||||
|
||||
private void send(C color, String message) {
|
||||
String line = color + message;
|
||||
deliver(() -> sender.sendMessage(line));
|
||||
}
|
||||
|
||||
private void report(ChatReport report) {
|
||||
deliver(() -> sender.sendReport(report));
|
||||
}
|
||||
|
||||
private void deliver(Runnable delivery) {
|
||||
if (sender.isPlayer()) {
|
||||
J.runEntity(sender.player(), () -> sender.sendMessage(line));
|
||||
J.runEntity(sender.player(), delivery);
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(line);
|
||||
delivery.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,12 @@ package art.arcane.iris.command;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.IrisRuntime;
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.diagnostics.DiagnosticsReport;
|
||||
import art.arcane.iris.localization.BukkitCommandMessagesExtended;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.command.DirectorExecutor;
|
||||
import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
|
||||
import art.arcane.iris.world.IrisWorldGeneratorResolver;
|
||||
import art.arcane.volmlib.util.director.annotations.Director;
|
||||
import art.arcane.volmlib.util.director.annotations.Param;
|
||||
import art.arcane.volmlib.util.director.help.DirectorMiniMenu;
|
||||
@@ -29,6 +32,13 @@ public final class CommandDebug implements DirectorExecutor {
|
||||
"Iris", Iris.instance.getDescription().getVersion(), DirectorMiniMenu.Theme.irisGreen()));
|
||||
}
|
||||
|
||||
@Director(sync = true, description = "Print build and system facts", descriptionKey = "iris.director.commanddebug.director.info")
|
||||
public void info() {
|
||||
VolmitSender sender = sender();
|
||||
DiagnosticsReport.sections(IrisWorldGeneratorResolver::awaitsExternalContent)
|
||||
.forEach(section -> sender.sendReport(section.report()));
|
||||
}
|
||||
|
||||
@Director(description = "Toggle debug", descriptionKey = "iris.director.commandiris.director.toggle_debug")
|
||||
public void toggle() {
|
||||
boolean enabled = !IrisSettings.get().getGeneral().isDebug();
|
||||
|
||||
@@ -24,7 +24,6 @@ import art.arcane.iris.pack.datapack.ServerConfigurator;
|
||||
import art.arcane.iris.pack.datapack.DataVersion;
|
||||
import art.arcane.iris.world.runtime.ChunkClearer;
|
||||
import art.arcane.iris.generation.validation.GoldenHashScanner;
|
||||
import art.arcane.iris.world.runtime.InPlaceChunkRegenerator;
|
||||
import art.arcane.iris.generation.runtime.IrisEngineSVC;
|
||||
import art.arcane.iris.pack.IrisPackBenchmarking;
|
||||
import art.arcane.iris.world.IrisToolbelt;
|
||||
@@ -66,10 +65,10 @@ import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.localization.BukkitCommandMessages;
|
||||
import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
import art.arcane.iris.localization.BukkitCommandMessagesExtended;
|
||||
@Director(name = "Developer", origin = DirectorOrigin.BOTH, description = "Iris World Manager", descriptionKey = "iris.director.commanddeveloper.director.iris_world_manager", aliases = {"dev"})
|
||||
@Director(name = "developer",origin = DirectorOrigin.BOTH, description = "Iris World Manager", descriptionKey = "iris.director.commanddeveloper.director.iris_world_manager", aliases = {"dev"})
|
||||
public class CommandDeveloper implements DirectorExecutor {
|
||||
@Director(description = "Get Loaded TectonicPlates Count", descriptionKey = "iris.director.commanddeveloper.director.get_loaded_tectonicplates_count", origin = DirectorOrigin.BOTH, sync = true)
|
||||
public void EngineStatus() {
|
||||
@Director(name = "engine-status", description = "Get Loaded TectonicPlates Count",descriptionKey = "iris.director.commanddeveloper.director.get_loaded_tectonicplates_count", origin = DirectorOrigin.BOTH, sync = true)
|
||||
public void engineStatus() {
|
||||
Iris.service(IrisEngineSVC.class)
|
||||
.engineStatus(sender());
|
||||
}
|
||||
@@ -80,9 +79,9 @@ public class CommandDeveloper implements DirectorExecutor {
|
||||
World world,
|
||||
@Param(description = "Radius in chunks around the center", descriptionKey = "iris.director.commanddeveloper.param.radius_chunks_around_center", defaultValue = "4")
|
||||
int radius,
|
||||
@Param(description = "Center chunk X", descriptionKey = "iris.director.commanddeveloper.param.center_chunk_x", defaultValue = "0")
|
||||
@Param(name = "center-x", description = "Center chunk X", descriptionKey = "iris.director.commanddeveloper.param.center_chunk_x", defaultValue = "0")
|
||||
int centerX,
|
||||
@Param(description = "Center chunk Z", descriptionKey = "iris.director.commanddeveloper.param.center_chunk_z", defaultValue = "0")
|
||||
@Param(name = "center-z", description = "Center chunk Z", descriptionKey = "iris.director.commanddeveloper.param.center_chunk_z", defaultValue = "0")
|
||||
int centerZ) {
|
||||
if (world == null) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_WORLD_IS_NULL));
|
||||
@@ -215,7 +214,7 @@ public class CommandDeveloper implements DirectorExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Director(description = "Test", descriptionKey = "iris.director.commanddeveloper.director.test_2")
|
||||
@Director(name = "pack-benchmark", description = "Test", descriptionKey = "iris.director.commanddeveloper.director.test_2")
|
||||
public void packBenchmark(
|
||||
@Param(description = "The pack to bench", descriptionKey = "iris.director.commanddeveloper.param.pack_bench", aliases = {"pack"}, defaultValue = "overworld")
|
||||
IrisDimension dimension,
|
||||
@@ -305,51 +304,6 @@ public class CommandDeveloper implements DirectorExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Regen ---
|
||||
|
||||
@Director(name = "regen", aliases = {"rg"}, description = "Delete and regenerate nearby chunks in place using Iris generation", descriptionKey = "iris.director.commanddeveloper.director.delete_regenerate_nearby_chunks_place_using_iris_generation", origin = DirectorOrigin.PLAYER)
|
||||
public void regen(
|
||||
@Param(name = "radius", description = "The radius of nearby chunks", descriptionKey = "iris.director.commanddeveloper.param.radius_nearby_chunks", defaultValue = "5")
|
||||
int radius
|
||||
) {
|
||||
if (radius < 0) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_RADIUS_MUST_BE_0_GREATER_2));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = player();
|
||||
VolmitSender commandSender = sender();
|
||||
World world = player.getWorld();
|
||||
if (!IrisToolbelt.isIrisWorld(world)) {
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_YOU_MUST_BE_IRIS_WORLD_USE_REGEN));
|
||||
return;
|
||||
}
|
||||
|
||||
Engine engine = IrisToolbelt.access(world).getEngine();
|
||||
if (engine == null) {
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_ENGINE_ACCESS_THIS_WORLD_IS_NULL_GENERATE_NEARBY_CHUNKS_FIRST));
|
||||
return;
|
||||
}
|
||||
|
||||
int chunks = (radius * 2 + 1) * (radius * 2 + 1);
|
||||
|
||||
// The player position must be read on the thread owning the player; the regenerator hops per chunk itself.
|
||||
if (!J.runEntity(player, () -> {
|
||||
int centerX = player.getLocation().getBlockX() >> 4;
|
||||
int centerZ = player.getLocation().getBlockZ() >> 4;
|
||||
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_REGEN_STARTED_CHUNK_S_AROUND_DELETING_REGENERATING_PLACE, MessageArgument.untrusted("chunks", chunks), MessageArgument.untrusted("centerX", centerX), MessageArgument.untrusted("centerZ", centerZ)));
|
||||
Iris.info("Regen run start: world=" + world.getName()
|
||||
+ " center=" + centerX + "," + centerZ
|
||||
+ " radius=" + radius
|
||||
+ " chunks=" + chunks);
|
||||
|
||||
new InPlaceChunkRegenerator(world, engine, commandSender, centerX, centerZ, radius).start();
|
||||
})) {
|
||||
Iris.warn("Could not schedule regen on the thread owning " + player.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@Director(name = "goldenhash", aliases = {"gold"}, description = "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.", descriptionKey = "iris.director.commanddeveloper.director.generate_chunks_into_buffers_no_world_writes_hash_blocks_biomes_captures_golden", origin = DirectorOrigin.BOTH)
|
||||
public void goldenhash(
|
||||
@Param(description = "The world to scan", descriptionKey = "iris.director.commanddeveloper.param.world_scan", contextual = true, contextualOverride = true)
|
||||
|
||||
@@ -65,7 +65,7 @@ public class CommandEdit implements DirectorExecutor {
|
||||
|
||||
|
||||
@Director(description = "Edit the biome you specified", descriptionKey = "iris.director.commandedit.director.edit_biome_you_specified", aliases = {"b"}, origin = DirectorOrigin.PLAYER)
|
||||
public void biome(@Param(contextual = false, description = "The biome to edit", descriptionKey = "iris.director.commandedit.param.biome_edit") IrisBiome biome) {
|
||||
public void biome(@Param(contextual = true, contextualOverride = true, description = "The biome to edit", descriptionKey = "iris.director.commandedit.param.biome_edit") IrisBiome biome) {
|
||||
if (noStudio()) {
|
||||
return;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class CommandEdit implements DirectorExecutor {
|
||||
}
|
||||
|
||||
@Director(description = "Edit the region you specified", descriptionKey = "iris.director.commandedit.director.edit_region_you_specified", aliases = {"r"}, origin = DirectorOrigin.PLAYER)
|
||||
public void region(@Param(contextual = false, description = "The region to edit", descriptionKey = "iris.director.commandedit.param.region_edit") IrisRegion region) {
|
||||
public void region(@Param(contextual = true, contextualOverride = true, description = "The region to edit", descriptionKey = "iris.director.commandedit.param.region_edit") IrisRegion region) {
|
||||
if (noStudio()) {
|
||||
return;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class CommandEdit implements DirectorExecutor {
|
||||
}
|
||||
|
||||
@Director(description = "Edit the dimension you specified", descriptionKey = "iris.director.commandedit.director.edit_dimension_you_specified", aliases = {"d"}, origin = DirectorOrigin.PLAYER)
|
||||
public void dimension(@Param(contextual = false, description = "The dimension to edit", descriptionKey = "iris.director.commandedit.param.dimension_edit") IrisDimension dimension) {
|
||||
public void dimension(@Param(contextual = true, contextualOverride = true, description = "The dimension to edit", descriptionKey = "iris.director.commandedit.param.dimension_edit") IrisDimension dimension) {
|
||||
if (noStudio()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.SubterrainFeatureHandler;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.localization.BukkitCommandMessages;
|
||||
import art.arcane.iris.localization.BukkitCommandMessagesExtended;
|
||||
@@ -93,7 +94,7 @@ public class CommandFind implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Find an authored underground feature by id or geometry family", sync = true)
|
||||
public void subterrain(
|
||||
@Param(description = "Feature definition id or family: tectonic_fault, cenote, lava_tube, travertine_terraces")
|
||||
@Param(description = "Feature definition id or family: tectonic_fault, cenote, lava_tube, travertine_terraces", customHandler = SubterrainFeatureHandler.class)
|
||||
String feature,
|
||||
@Param(description = "Search radius in blocks", defaultValue = "8192")
|
||||
int radius,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.OpenSuggestionHandler;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.IrisRuntime;
|
||||
import art.arcane.iris.world.BukkitWorldReconciler;
|
||||
@@ -47,6 +48,8 @@ import art.arcane.volmlib.util.director.annotations.Param;
|
||||
import art.arcane.volmlib.util.director.exceptions.DirectorParsingException;
|
||||
import art.arcane.iris.command.specialhandlers.NullablePlayerHandler;
|
||||
import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.BukkitRuntimeMessages;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
|
||||
import art.arcane.iris.world.task.J;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -58,6 +61,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -82,6 +87,7 @@ public class CommandIris implements DirectorExecutor {
|
||||
private static final String NO_DOWNLOAD_SOURCE = "__none__";
|
||||
private static final String PRESERVE_REPLACEMENT_SEED = "preserve";
|
||||
private static final long WORLD_UNLOAD_TIMEOUT_SECONDS = 150L;
|
||||
private static final int METRICS_DETAIL_LIMIT = 12;
|
||||
|
||||
private CommandStudio studio;
|
||||
private CommandPregen pregen;
|
||||
@@ -196,7 +202,8 @@ public class CommandIris implements DirectorExecutor {
|
||||
name = "target",
|
||||
aliases = "world-name",
|
||||
description = "The exact existing world slot to replace",
|
||||
descriptionKey = "iris.director.commandiris.param.replace_exact_existing_world_slot_next_restart"
|
||||
descriptionKey = "iris.director.commandiris.param.replace_exact_existing_world_slot_next_restart",
|
||||
customHandler = WorldSlotHandler.class
|
||||
)
|
||||
String target,
|
||||
@Param(
|
||||
@@ -340,26 +347,18 @@ public class CommandIris implements DirectorExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
if (sender().isPlayer()) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_IRIS_WORLDS));
|
||||
for (World IrisWorld : IrisWorlds.copy()) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_MESSAGE, MessageArgument.untrusted("value", IrisWorld.getName())));
|
||||
}
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_BUKKIT_WORLDS));
|
||||
for (World BukkitWorld : BukkitWorlds.copy()) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_MESSAGE_2, MessageArgument.untrusted("value", BukkitWorld.getName())));
|
||||
}
|
||||
} else {
|
||||
Iris.info(C.BLUE + "Iris Worlds: ");
|
||||
for (World IrisWorld : IrisWorlds.copy()) {
|
||||
Iris.info(C.IRIS + "- " +IrisWorld.getName());
|
||||
}
|
||||
Iris.info(C.GOLD + "Bukkit Worlds: ");
|
||||
for (World BukkitWorld : BukkitWorlds.copy()) {
|
||||
Iris.info(C.GRAY + "- " +BukkitWorld.getName());
|
||||
}
|
||||
|
||||
sender().sendReport(worldListReport(ChatReport.Tone.SUCCESS,
|
||||
IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_IRIS_WORLDS), IrisWorlds));
|
||||
sender().sendReport(worldListReport(ChatReport.Tone.INFO,
|
||||
IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_BUKKIT_WORLDS), BukkitWorlds));
|
||||
}
|
||||
|
||||
private static ChatReport worldListReport(ChatReport.Tone tone, String title, List<World> worlds) {
|
||||
ChatReport.Builder report = ChatReport.of(tone, title).unlimited();
|
||||
for (World world : worlds) {
|
||||
report.item(world.getName());
|
||||
}
|
||||
return report.build();
|
||||
}
|
||||
|
||||
@Director(description = "Remove an Iris world", descriptionKey = "iris.director.commandiris.director.remove_iris_world", aliases = {"rm"}, sync = true)
|
||||
@@ -465,8 +464,22 @@ public class CommandIris implements DirectorExecutor {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_YOU_MUST_BE_IRIS_WORLD));
|
||||
return;
|
||||
}
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_SENDING_METRICS));
|
||||
engine().printMetrics(sender()::sendMessage);
|
||||
List<String> lines = new ArrayList<>();
|
||||
engine().printMetrics(lines::add);
|
||||
String detailsHeader = IrisLanguage.text(BukkitRuntimeMessages.IRIS_ENGINE_DETAILS);
|
||||
int detailsIndex = lines.indexOf(detailsHeader);
|
||||
List<String> totals = detailsIndex < 0 ? lines : lines.subList(0, detailsIndex);
|
||||
sender().sendReport(ChatReport.of(ChatReport.Tone.SUCCESS,
|
||||
IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_IRIS_SENDING_METRICS))
|
||||
.items(totals)
|
||||
.unlimited()
|
||||
.build());
|
||||
if (detailsIndex >= 0) {
|
||||
sender().sendReport(ChatReport.of(ChatReport.Tone.INFO, detailsHeader)
|
||||
.items(lines.subList(detailsIndex + 1, lines.size()))
|
||||
.limit(METRICS_DETAIL_LIMIT)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
@Director(description = "Reload configuration file (this is also done automatically)", descriptionKey = "iris.director.commandiris.director.reload_configuration_file_this_is_also_done_automatically")
|
||||
@@ -489,7 +502,7 @@ public class CommandIris implements DirectorExecutor {
|
||||
}
|
||||
|
||||
|
||||
@Director(description = "Unload an Iris World", descriptionKey = "iris.director.commandiris.director.unload_iris_world", origin = DirectorOrigin.PLAYER, sync = true)
|
||||
@Director(name = "unload-world", description = "Unload an Iris World", descriptionKey = "iris.director.commandiris.director.unload_iris_world", origin = DirectorOrigin.PLAYER, sync = true)
|
||||
public void unloadWorld(
|
||||
@Param(description = "The world to unload", descriptionKey = "iris.director.commandiris.param.world_unload")
|
||||
World world
|
||||
@@ -609,7 +622,7 @@ public class CommandIris implements DirectorExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Director(description = "Load an Iris World", descriptionKey = "iris.director.commandiris.director.load_iris_world", origin = DirectorOrigin.PLAYER, sync = true, aliases = {"import"})
|
||||
@Director(name = "load-world", description = "Load an Iris World", descriptionKey = "iris.director.commandiris.director.load_iris_world", origin = DirectorOrigin.PLAYER, sync = true, aliases = {"import"})
|
||||
public void loadWorld(
|
||||
@Param(
|
||||
description = "The name of the world to load",
|
||||
@@ -711,6 +724,13 @@ public class CommandIris implements DirectorExecutor {
|
||||
).isPresent();
|
||||
}
|
||||
|
||||
public static final class WorldSlotHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
return Bukkit.getWorlds().stream().map(world -> world.getKey().toString()).toList();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ManagedWorldNameHandler implements DirectorParameterHandler<String> {
|
||||
@Override
|
||||
public KList<String> getPossibilities() {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.OpenSuggestionHandler;
|
||||
import art.arcane.iris.command.specialhandlers.RegisteredStructureKeyHandler;
|
||||
import art.arcane.iris.command.specialhandlers.ExportFormatHandler;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.studio.object.StudioOpenCoordinator;
|
||||
@@ -52,7 +55,10 @@ import org.bukkit.entity.Player;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -145,7 +151,7 @@ public class CommandJigsaw implements DirectorExecutor {
|
||||
aliases = {"import", "import-vanilla"}, sync = true, origin = DirectorOrigin.PLAYER)
|
||||
public void convert(
|
||||
@Param(description = "Pack dimension") IrisDimension dimension,
|
||||
@Param(description = "Registered structure key such as minecraft:village_plains") String source,
|
||||
@Param(description = "Registered structure key such as minecraft:village_plains", customHandler = RegisteredStructureKeyHandler.class) String source,
|
||||
@Param(description = "New Iris structure key, or auto", defaultValue = "auto") String target,
|
||||
@Param(description = "Studio world seed", defaultValue = "1337") long seed
|
||||
) {
|
||||
@@ -366,7 +372,7 @@ public class CommandJigsaw implements DirectorExecutor {
|
||||
@Director(description = "Flush the automatic save for a workcell now", sync = true,
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void save(
|
||||
@Param(description = "Workcell ID or selected", defaultValue = "selected") String bay
|
||||
@Param(description = "Workcell ID or selected", defaultValue = "selected", customHandler = JigsawWorkcellOrSelectedHandler.class) String bay
|
||||
) {
|
||||
ActiveContext context = requireActive();
|
||||
if (context == null) {
|
||||
@@ -387,7 +393,7 @@ public class CommandJigsaw implements DirectorExecutor {
|
||||
@Director(name = "goto", aliases = "teleport", description = "Select and teleport to a Studio workcell",
|
||||
sync = true, origin = DirectorOrigin.PLAYER)
|
||||
public void gotoBay(
|
||||
@Param(description = "Workcell ID") String bay
|
||||
@Param(description = "Workcell ID", customHandler = JigsawWorkcellHandler.class) String bay
|
||||
) {
|
||||
if (requireActive() != null) {
|
||||
JigsawStudioService.get().teleportTo(player(), bay);
|
||||
@@ -410,7 +416,7 @@ public class CommandJigsaw implements DirectorExecutor {
|
||||
@Param(description = "Datapack namespace", defaultValue = "iris") String namespace,
|
||||
@Param(description = "Output name under the Studio exports folder", defaultValue = "jigsaw-export")
|
||||
String output,
|
||||
@Param(description = "directory or zip", defaultValue = "zip") String format,
|
||||
@Param(description = "directory or zip", defaultValue = "zip", customHandler = ExportFormatHandler.class) String format,
|
||||
@Param(description = "Replace an existing export", defaultValue = "false") boolean replace
|
||||
) {
|
||||
ActiveContext context = requireActive();
|
||||
@@ -815,4 +821,27 @@ public class CommandJigsaw implements DirectorExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
public static class JigsawWorkcellHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
ActiveContext context = active(player());
|
||||
if (context == null) {
|
||||
return List.of();
|
||||
}
|
||||
return context.session().layout().bays().stream().map(JigsawStudioBay::stableId).toList();
|
||||
}
|
||||
}
|
||||
|
||||
public static final class JigsawWorkcellOrSelectedHandler extends JigsawWorkcellHandler {
|
||||
private static final String SELECTED_WORKCELL = "selected";
|
||||
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
List<String> options = new ArrayList<>();
|
||||
options.add(SELECTED_WORKCELL);
|
||||
options.addAll(super.suggestions());
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.IrisStructureHandler;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.structure.authoring.StructureKey;
|
||||
@@ -45,7 +46,7 @@ public class CommandJigsawAdopt implements DirectorExecutor {
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void inspect(
|
||||
@Param(description = "Pack dimension") IrisDimension dimension,
|
||||
@Param(description = "Existing Iris structure key") String source,
|
||||
@Param(description = "Existing Iris structure key", customHandler = IrisStructureHandler.class) String source,
|
||||
@Param(description = "New owned Iris key, or auto", defaultValue = "auto") String target,
|
||||
@Param(description = "auto, in-place, or clone", defaultValue = "auto",
|
||||
customHandler = JigsawAdoptionStrategyHandler.class) String strategy
|
||||
@@ -94,7 +95,7 @@ public class CommandJigsawAdopt implements DirectorExecutor {
|
||||
@Director(description = "Apply one inspected adoption plan without overwriting", sync = true,
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void apply(
|
||||
@Param(description = "Plan UUID returned by adopt inspect",
|
||||
@Param(name = "plan-id", description = "Plan UUID returned by adopt inspect",
|
||||
customHandler = JigsawAdoptionPlanHandler.class) String planId
|
||||
) {
|
||||
VolmitSender commandSender = sender();
|
||||
|
||||
+5
-5
@@ -25,8 +25,8 @@ public class CommandJigsawPiece implements DirectorExecutor {
|
||||
@Director(description = "Create an owned piece from the selected Studio topology", sync = true,
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void create(
|
||||
@Param(description = "Owned pool resource key") String poolKey,
|
||||
@Param(description = "New owned piece and object key") String pieceKey,
|
||||
@Param(name = "pool-key", description = "Owned pool resource key") String poolKey,
|
||||
@Param(name = "piece-key", description = "New owned piece and object key") String pieceKey,
|
||||
@Param(description = "Positive selection weight", defaultValue = "1") int weight
|
||||
) {
|
||||
CommandJigsaw.ActiveContext context = CommandJigsaw.active(player());
|
||||
@@ -81,8 +81,8 @@ public class CommandJigsawPiece implements DirectorExecutor {
|
||||
@Director(description = "Add an existing jigsaw piece to an owned pool transactionally", sync = true,
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void add(
|
||||
@Param(description = "Owned pool resource key") String poolKey,
|
||||
@Param(description = "Existing jigsaw piece key") String pieceKey,
|
||||
@Param(name = "pool-key", description = "Owned pool resource key") String poolKey,
|
||||
@Param(name = "piece-key", description = "Existing jigsaw piece key") String pieceKey,
|
||||
@Param(description = "Positive selection weight", defaultValue = "1") int weight
|
||||
) {
|
||||
CommandJigsaw.ActiveContext context = CommandJigsaw.active(player());
|
||||
@@ -153,7 +153,7 @@ public class CommandJigsawPiece implements DirectorExecutor {
|
||||
@Director(description = "Remove the selected piece from an owned pool transactionally", sync = true,
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void remove(
|
||||
@Param(description = "Owned pool resource key") String poolKey
|
||||
@Param(name = "pool-key", description = "Owned pool resource key") String poolKey
|
||||
) {
|
||||
CommandJigsaw.ActiveContext context = CommandJigsaw.active(player());
|
||||
if (context == null) {
|
||||
|
||||
@@ -10,8 +10,8 @@ public class CommandJigsawPool implements DirectorExecutor {
|
||||
@Director(description = "Create an empty owned jigsaw pool", sync = true,
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void create(
|
||||
@Param(description = "New owned pool resource key") String poolKey,
|
||||
@Param(description = "Owned fallback pool key, or none", defaultValue = "none")
|
||||
@Param(name = "pool-key", description = "New owned pool resource key") String poolKey,
|
||||
@Param(name = "fallback-pool-key", description = "Owned fallback pool key, or none", defaultValue = "none")
|
||||
String fallbackPoolKey
|
||||
) {
|
||||
CommandJigsaw.ActiveContext context = CommandJigsaw.active(player());
|
||||
|
||||
+6
-6
@@ -13,8 +13,8 @@ public class CommandJigsawRules implements DirectorExecutor {
|
||||
@Director(description = "Set maximum expansion depth and horizontal radius", sync = true,
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void limits(
|
||||
@Param(description = "Maximum expansion depth") int maxDepth,
|
||||
@Param(description = "Maximum radius in chunks") int maxSizeChunks
|
||||
@Param(name = "max-depth", description = "Maximum expansion depth") int maxDepth,
|
||||
@Param(name = "max-size-chunks", description = "Maximum radius in chunks") int maxSizeChunks
|
||||
) {
|
||||
CommandJigsaw.ActiveContext context = CommandJigsaw.active(player());
|
||||
if (context == null) {
|
||||
@@ -36,16 +36,16 @@ public class CommandJigsawRules implements DirectorExecutor {
|
||||
context,
|
||||
"",
|
||||
"",
|
||||
"Persisted jigsaw limits: maxDepth=" + maxDepth
|
||||
+ ", maxSizeChunks=" + maxSizeChunks + ".");
|
||||
"Persisted jigsaw limits: max-depth=" + maxDepth
|
||||
+ ", max-size-chunks=" + maxSizeChunks + ".");
|
||||
});
|
||||
}
|
||||
|
||||
@Director(description = "Set or clear one owned pool's direct fallback", sync = true,
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void fallback(
|
||||
@Param(description = "Owned pool resource key") String poolKey,
|
||||
@Param(description = "Owned fallback pool key, or none") String fallbackPoolKey
|
||||
@Param(name = "pool-key", description = "Owned pool resource key") String poolKey,
|
||||
@Param(name = "fallback-pool-key", description = "Owned fallback pool key, or none") String fallbackPoolKey
|
||||
) {
|
||||
CommandJigsaw.ActiveContext context = CommandJigsaw.active(player());
|
||||
if (context == null) {
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@ public class CommandJigsawVariant implements DirectorExecutor {
|
||||
@Director(description = "Set the selected piece weight in a pool", sync = true,
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void weight(
|
||||
@Param(description = "Pool resource key") String poolKey,
|
||||
@Param(name = "pool-key", description = "Pool resource key") String poolKey,
|
||||
@Param(description = "Positive selection weight") int weight
|
||||
) {
|
||||
CommandJigsaw.ActiveContext context = CommandJigsaw.active(player());
|
||||
@@ -85,7 +85,7 @@ public class CommandJigsawVariant implements DirectorExecutor {
|
||||
@Director(description = "Set the active variant's author-facing label", sync = true,
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void label(
|
||||
@Param(description = "Display label; quote labels containing spaces") String displayName
|
||||
@Param(name = "display-name", description = "Display label; quote labels containing spaces") String displayName
|
||||
) {
|
||||
CommandJigsaw.ActiveContext context = CommandJigsaw.active(player());
|
||||
if (context == null) {
|
||||
@@ -147,7 +147,7 @@ public class CommandJigsawVariant implements DirectorExecutor {
|
||||
description = "Duplicate every enabled workcell's active variant as one coherent family",
|
||||
sync = true, origin = DirectorOrigin.PLAYER)
|
||||
public void duplicateFamily(
|
||||
@Param(description = "Family key or next", defaultValue = "next") String themeKey
|
||||
@Param(name = "theme-key", description = "Family key or next", defaultValue = "next") String themeKey
|
||||
) {
|
||||
CommandJigsaw.ActiveContext context = CommandJigsaw.active(player());
|
||||
if (context == null) {
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class CommandJigsawWorkcell implements DirectorExecutor {
|
||||
@Director(description = "Set the selected workcell's author-facing label", sync = true,
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void label(
|
||||
@Param(description = "Display label; quote labels containing spaces") String displayName
|
||||
@Param(name = "display-name", description = "Display label; quote labels containing spaces") String displayName
|
||||
) {
|
||||
CommandJigsaw.ActiveContext context = CommandJigsaw.active(player());
|
||||
if (context == null) {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.PackFolderHandler;
|
||||
import art.arcane.iris.pack.PackFingerprints;
|
||||
|
||||
import art.arcane.iris.Iris;
|
||||
@@ -32,8 +33,10 @@ import art.arcane.iris.studio.StudioSVC;
|
||||
import art.arcane.iris.world.IrisToolbelt;
|
||||
import art.arcane.iris.world.lifecycle.LifecycleOperationCoordinator;
|
||||
import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.command.handlers.DimensionHandler;
|
||||
import art.arcane.iris.command.specialhandlers.PreviewApplyModeHandler;
|
||||
import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
|
||||
import art.arcane.volmlib.util.director.annotations.Director;
|
||||
import art.arcane.volmlib.util.director.annotations.Param;
|
||||
@@ -45,8 +48,10 @@ import org.bukkit.World;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.localization.BukkitCommandMessages;
|
||||
@@ -54,6 +59,9 @@ import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
import art.arcane.iris.localization.BukkitRuntimeMessages;
|
||||
@Director(name = "pack", aliases = {"pk"}, description = "Pack validation and maintenance", descriptionKey = "iris.director.commandpack.director.pack_validation_maintenance")
|
||||
public class CommandPack implements DirectorExecutor {
|
||||
private static final int PATH_REPORT_LIMIT = 10;
|
||||
private static final Pattern LEADING_COLOR = Pattern.compile("^§[0-9a-fk-or]");
|
||||
|
||||
@Director(name = "update-world", description = "Stage an installed pack for a world and request a clean restart", descriptionKey = "iris.director.commanddeveloper.director.stage_world_generation_update")
|
||||
public void updateWorld(
|
||||
@Param(description = "The world to update", descriptionKey = "iris.director.commanddeveloper.param.world_update", contextual = true, contextualOverride = true)
|
||||
@@ -101,7 +109,7 @@ public class CommandPack implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Validate a pack (or all packs) and re-publish results", descriptionKey = "iris.director.commandpack.director.validate_pack_all_packs_re_publish_results", aliases = {"v"})
|
||||
public void validate(
|
||||
@Param(description = "The pack folder name to validate, or * for every pack", descriptionKey = "iris.director.commandpack.param.pack_folder_name_validate_leave_empty_all", defaultValue = "*")
|
||||
@Param(description = "The pack folder name to validate; omit for every pack", descriptionKey = "iris.director.commandpack.param.pack_folder_name_validate_leave_empty_all", defaultValue = "*", customHandler = PackFolderHandler.class)
|
||||
String pack
|
||||
) {
|
||||
VolmitSender s = sender();
|
||||
@@ -119,13 +127,15 @@ public class CommandPack implements DirectorExecutor {
|
||||
}
|
||||
int broken = 0;
|
||||
for (File dir : dirs) {
|
||||
PackValidationResult result = runValidate(s, dir);
|
||||
if (result != null && !result.isLoadable()) {
|
||||
PackValidationResult result = runValidate(dir);
|
||||
if (!result.isLoadable()) {
|
||||
broken++;
|
||||
reportResult(s, result);
|
||||
}
|
||||
}
|
||||
persistValidationCache(packsRoot);
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_VALIDATION_COMPLETE_BROKEN_PACKS, MessageArgument.untrusted("broken", String.valueOf(broken)), MessageArgument.untrusted("value", String.valueOf(dirs.size()))));
|
||||
ChatReport.Tone summaryTone = broken == 0 ? ChatReport.Tone.SUCCESS : ChatReport.Tone.ERROR;
|
||||
s.sendMessage(summaryTone.paint(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_VALIDATION_COMPLETE_BROKEN_PACKS, MessageArgument.untrusted("broken", String.valueOf(broken)), MessageArgument.untrusted("value", String.valueOf(dirs.size())))));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -134,7 +144,7 @@ public class CommandPack implements DirectorExecutor {
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_PACK_NOT_FOUND_UNDER_PACKS, MessageArgument.untrusted("pack", String.valueOf(pack))));
|
||||
return;
|
||||
}
|
||||
runValidate(s, target);
|
||||
reportResult(s, runValidate(target));
|
||||
persistValidationCache(packsRoot);
|
||||
}
|
||||
|
||||
@@ -152,9 +162,9 @@ public class CommandPack implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Preview or apply unused-resource cleanup", descriptionKey = "iris.director.commandpack.director.preview_apply_unused_resource_cleanup", aliases = {"c"})
|
||||
public void cleanup(
|
||||
@Param(description = "The pack folder name to clean", descriptionKey = "iris.director.commandpack.param.pack_folder_name_clean")
|
||||
@Param(description = "The pack folder name to clean", descriptionKey = "iris.director.commandpack.param.pack_folder_name_clean", customHandler = PackFolderHandler.class)
|
||||
String pack,
|
||||
@Param(description = "preview or apply", descriptionKey = "iris.director.commandpack.param.preview_apply", defaultValue = "preview")
|
||||
@Param(description = "preview or apply", descriptionKey = "iris.director.commandpack.param.preview_apply", defaultValue = "preview", customHandler = PreviewApplyModeHandler.class)
|
||||
String mode
|
||||
) {
|
||||
VolmitSender s = sender();
|
||||
@@ -165,19 +175,18 @@ public class CommandPack implements DirectorExecutor {
|
||||
if ("apply".equalsIgnoreCase(mode)) {
|
||||
PackResourceCleanup.ApplyResult result = PackResourceCleanup.apply(packFolder);
|
||||
if (!result.success()) {
|
||||
s.sendMessage(IrisLanguage.text(
|
||||
reportPaths(s, ChatReport.Tone.ERROR, IrisLanguage.text(
|
||||
BukkitRuntimeMessages.COMMAND_PACK_CLEANUP_FAILED,
|
||||
MessageArgument.untrusted("error", String.valueOf(result.error()))
|
||||
));
|
||||
reportPaths(s, result.quarantinedPaths(), BukkitRuntimeMessages.COMMAND_PACK_PATH_STILL_QUARANTINED);
|
||||
), result.quarantinedPaths(), BukkitRuntimeMessages.COMMAND_PACK_PATH_STILL_QUARANTINED);
|
||||
return;
|
||||
}
|
||||
if (!result.changed()) {
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_NO_CLEANUP_CANDIDATES_FOUND_PACK, MessageArgument.untrusted("pack", String.valueOf(pack))));
|
||||
return;
|
||||
}
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_QUARANTINED_CLEANUP_CANDIDATE_S_UNDER, MessageArgument.untrusted("size", String.valueOf(result.quarantinedPaths().size())), MessageArgument.untrusted("quarantinePath", String.valueOf(result.quarantinePath()))));
|
||||
reportPaths(s, result.quarantinedPaths(), BukkitRuntimeMessages.COMMAND_PACK_PATH_QUARANTINED);
|
||||
reportPaths(s, ChatReport.Tone.SUCCESS, IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_QUARANTINED_CLEANUP_CANDIDATE_S_UNDER, MessageArgument.untrusted("size", String.valueOf(result.quarantinedPaths().size())), MessageArgument.untrusted("quarantinePath", String.valueOf(result.quarantinePath()))),
|
||||
result.quarantinedPaths(), BukkitRuntimeMessages.COMMAND_PACK_PATH_QUARANTINED);
|
||||
return;
|
||||
}
|
||||
if (!"preview".equalsIgnoreCase(mode)) {
|
||||
@@ -196,16 +205,16 @@ public class CommandPack implements DirectorExecutor {
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_NO_CLEANUP_CANDIDATES_FOUND_PACK_2, MessageArgument.untrusted("pack", String.valueOf(pack))));
|
||||
return;
|
||||
}
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_CLEANUP_PREVIEW_PACK_CANDIDATE_S_NO_FILES_WERE_CHANGED, MessageArgument.untrusted("pack", String.valueOf(pack)), MessageArgument.untrusted("size", String.valueOf(preview.candidatePaths().size()))));
|
||||
reportPaths(s, preview.candidatePaths(), BukkitRuntimeMessages.COMMAND_PACK_PATH_CANDIDATE);
|
||||
reportPaths(s, ChatReport.Tone.INFO, IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_CLEANUP_PREVIEW_PACK_CANDIDATE_S_NO_FILES_WERE_CHANGED, MessageArgument.untrusted("pack", String.valueOf(pack)), MessageArgument.untrusted("size", String.valueOf(preview.candidatePaths().size()))),
|
||||
preview.candidatePaths(), BukkitRuntimeMessages.COMMAND_PACK_PATH_CANDIDATE);
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_RUN_IRIS_PACK_CLEANUP_MODE_APPLY_QUARANTINE_THESE_CANDIDATES_AFTER_FRESH_SCAN, MessageArgument.untrusted("pack", String.valueOf(pack))));
|
||||
}
|
||||
|
||||
@Director(description = "Preview or apply restoration of the latest quarantine", descriptionKey = "iris.director.commandpack.director.preview_apply_restoration_latest_quarantine", aliases = {"r"})
|
||||
public void restore(
|
||||
@Param(description = "The pack folder name to restore", descriptionKey = "iris.director.commandpack.param.pack_folder_name_restore")
|
||||
@Param(description = "The pack folder name to restore", descriptionKey = "iris.director.commandpack.param.pack_folder_name_restore", customHandler = PackFolderHandler.class)
|
||||
String pack,
|
||||
@Param(description = "preview or apply", descriptionKey = "iris.director.commandpack.param.preview_apply_2", defaultValue = "preview")
|
||||
@Param(description = "preview or apply", descriptionKey = "iris.director.commandpack.param.preview_apply_2", defaultValue = "preview", customHandler = PreviewApplyModeHandler.class)
|
||||
String mode
|
||||
) {
|
||||
VolmitSender s = sender();
|
||||
@@ -216,8 +225,8 @@ public class CommandPack implements DirectorExecutor {
|
||||
if ("apply".equalsIgnoreCase(mode)) {
|
||||
PackResourceCleanup.RestoreResult result = PackResourceCleanup.restoreLatest(packFolder);
|
||||
if (!result.conflicts().isEmpty()) {
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_RESTORE_REFUSED_BECAUSE_DESTINATION_S_ALREADY_EXIST, MessageArgument.untrusted("size", String.valueOf(result.conflicts().size()))));
|
||||
reportPaths(s, result.conflicts(), BukkitRuntimeMessages.COMMAND_PACK_PATH_CONFLICT);
|
||||
reportPaths(s, ChatReport.Tone.ERROR, IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_RESTORE_REFUSED_BECAUSE_DESTINATION_S_ALREADY_EXIST, MessageArgument.untrusted("size", String.valueOf(result.conflicts().size()))),
|
||||
result.conflicts(), BukkitRuntimeMessages.COMMAND_PACK_PATH_CONFLICT);
|
||||
return;
|
||||
}
|
||||
if (!result.success()) {
|
||||
@@ -231,8 +240,8 @@ public class CommandPack implements DirectorExecutor {
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_NOTHING_RESTORE_PACK, MessageArgument.untrusted("pack", String.valueOf(pack))));
|
||||
return;
|
||||
}
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_RESTORED_FILE_S_FROM, MessageArgument.untrusted("size", String.valueOf(result.restoredPaths().size())), MessageArgument.untrusted("dumpPath", String.valueOf(result.dumpPath()))));
|
||||
reportPaths(s, result.restoredPaths(), BukkitRuntimeMessages.COMMAND_PACK_PATH_RESTORED);
|
||||
reportPaths(s, ChatReport.Tone.SUCCESS, IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_RESTORED_FILE_S_FROM, MessageArgument.untrusted("size", String.valueOf(result.restoredPaths().size())), MessageArgument.untrusted("dumpPath", String.valueOf(result.dumpPath()))),
|
||||
result.restoredPaths(), BukkitRuntimeMessages.COMMAND_PACK_PATH_RESTORED);
|
||||
return;
|
||||
}
|
||||
if (!"preview".equalsIgnoreCase(mode)) {
|
||||
@@ -251,11 +260,11 @@ public class CommandPack implements DirectorExecutor {
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_NOTHING_RESTORE_PACK_2, MessageArgument.untrusted("pack", String.valueOf(pack))));
|
||||
return;
|
||||
}
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_RESTORE_PREVIEW_FILE_S_NO_FILES_WERE_CHANGED, MessageArgument.untrusted("dumpPath", String.valueOf(preview.dumpPath())), MessageArgument.untrusted("size", String.valueOf(preview.filePaths().size()))));
|
||||
reportPaths(s, preview.filePaths(), BukkitRuntimeMessages.COMMAND_PACK_PATH_FILE);
|
||||
reportPaths(s, ChatReport.Tone.INFO, IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_RESTORE_PREVIEW_FILE_S_NO_FILES_WERE_CHANGED, MessageArgument.untrusted("dumpPath", String.valueOf(preview.dumpPath())), MessageArgument.untrusted("size", String.valueOf(preview.filePaths().size()))),
|
||||
preview.filePaths(), BukkitRuntimeMessages.COMMAND_PACK_PATH_FILE);
|
||||
if (!preview.conflicts().isEmpty()) {
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_RESTORE_IS_BLOCKED_BY_EXISTING_DESTINATION_S, MessageArgument.untrusted("size", String.valueOf(preview.conflicts().size()))));
|
||||
reportPaths(s, preview.conflicts(), BukkitRuntimeMessages.COMMAND_PACK_PATH_CONFLICT);
|
||||
reportPaths(s, ChatReport.Tone.ERROR, IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_RESTORE_IS_BLOCKED_BY_EXISTING_DESTINATION_S, MessageArgument.untrusted("size", String.valueOf(preview.conflicts().size()))),
|
||||
preview.conflicts(), BukkitRuntimeMessages.COMMAND_PACK_PATH_CONFLICT);
|
||||
return;
|
||||
}
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_RUN_IRIS_PACK_RESTORE_MODE_APPLY_RESTORE_AFTER_FRESH_CONFLICT_CHECK, MessageArgument.untrusted("pack", String.valueOf(pack))));
|
||||
@@ -263,7 +272,7 @@ public class CommandPack implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Show cached validation status for a pack", descriptionKey = "iris.director.commandpack.director.show_cached_validation_status_pack", aliases = {"s"})
|
||||
public void status(
|
||||
@Param(description = "The pack folder name, or * for every pack", descriptionKey = "iris.director.commandpack.param.pack_folder_name", defaultValue = "*")
|
||||
@Param(description = "The pack folder name; omit for every pack", descriptionKey = "iris.director.commandpack.param.pack_folder_name", defaultValue = "*", customHandler = PackFolderHandler.class)
|
||||
String pack
|
||||
) {
|
||||
VolmitSender s = sender();
|
||||
@@ -272,17 +281,13 @@ public class CommandPack implements DirectorExecutor {
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_NO_VALIDATION_RESULTS_RECORDED_RUN_IRIS_PACK_VALIDATE_FIRST));
|
||||
return;
|
||||
}
|
||||
PackValidationRegistry.snapshot().forEach((name, result) -> {
|
||||
TextKey key = result.isLoadable()
|
||||
? BukkitRuntimeMessages.COMMAND_PACK_STATUS_OK
|
||||
: BukkitRuntimeMessages.COMMAND_PACK_STATUS_BROKEN;
|
||||
s.sendMessage(IrisLanguage.text(
|
||||
key,
|
||||
MessageArgument.untrusted("pack", name),
|
||||
MessageArgument.trusted("blocking", result.getBlockingErrors().size()),
|
||||
MessageArgument.trusted("warnings", result.getWarnings().size())
|
||||
));
|
||||
});
|
||||
ChatReport.Builder report = ChatReport.of(ChatReport.Tone.INFO, "Pack validation status").unlimited();
|
||||
PackValidationRegistry.snapshot().entrySet().stream()
|
||||
.sorted(Comparator.comparing((Map.Entry<String, PackValidationResult> entry) -> statusTone(entry.getValue()).ordinal())
|
||||
.reversed()
|
||||
.thenComparing(Map.Entry::getKey))
|
||||
.forEach(entry -> report.styledItem(statusLine(entry.getKey(), entry.getValue())));
|
||||
s.sendReport(report.build());
|
||||
return;
|
||||
}
|
||||
PackValidationResult result = PackValidationRegistry.get(pack);
|
||||
@@ -295,7 +300,7 @@ public class CommandPack implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Show pack content that cannot generate on this Minecraft version", descriptionKey = "iris.director.commandpack.director.show_content_cannot_generate_this_minecraft_version", aliases = {"cp"})
|
||||
public void compat(
|
||||
@Param(description = "The pack folder name to report on, or * for every pack", descriptionKey = "iris.director.commandpack.param.pack_folder_name_compat", defaultValue = "*")
|
||||
@Param(description = "The pack folder name to report on; omit for every pack", descriptionKey = "iris.director.commandpack.param.pack_folder_name_compat", defaultValue = "*", customHandler = PackFolderHandler.class)
|
||||
String pack
|
||||
) {
|
||||
VolmitSender s = sender();
|
||||
@@ -306,15 +311,11 @@ public class CommandPack implements DirectorExecutor {
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<String, PackValidationResult> entry : snapshot.entrySet()) {
|
||||
for (String line : compatOutput(entry.getKey(), entry.getValue())) {
|
||||
s.sendMessage(line);
|
||||
}
|
||||
s.sendReport(compatReport(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (String line : compatOutput(pack, PackValidationRegistry.get(pack))) {
|
||||
s.sendMessage(line);
|
||||
}
|
||||
s.sendReport(compatReport(pack, PackValidationRegistry.get(pack)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,33 +323,31 @@ public class CommandPack implements DirectorExecutor {
|
||||
* printed with every subject; the boot listing is the capped form of the same data.
|
||||
*/
|
||||
static List<String> compatOutput(String pack, PackValidationResult result) {
|
||||
List<String> lines = new ArrayList<>();
|
||||
return compatReport(pack, result).lines().stream().map(ChatReport.Line::text).toList();
|
||||
}
|
||||
|
||||
static ChatReport compatReport(String pack, PackValidationResult result) {
|
||||
if (result == null) {
|
||||
lines.add(IrisLanguage.text(
|
||||
return ChatReport.of(ChatReport.Tone.WARNING, IrisLanguage.text(
|
||||
BukkitRuntimeMessages.COMMAND_PACK_NO_VALIDATION_RESULT_RUN_IRIS_PACK_VALIDATE,
|
||||
MessageArgument.untrusted("pack", String.valueOf(pack)),
|
||||
MessageArgument.untrusted("pack2", String.valueOf(pack))));
|
||||
return lines;
|
||||
MessageArgument.untrusted("pack2", String.valueOf(pack)))).build();
|
||||
}
|
||||
String version = compatVersion(result);
|
||||
if (result.getCompatFindings().isEmpty()) {
|
||||
lines.add(IrisLanguage.text(
|
||||
return ChatReport.of(ChatReport.Tone.SUCCESS, IrisLanguage.text(
|
||||
BukkitRuntimeMessages.COMMAND_PACK_COMPAT_NONE,
|
||||
MessageArgument.untrusted("pack", pack),
|
||||
MessageArgument.untrusted("version", version)));
|
||||
return lines;
|
||||
MessageArgument.untrusted("version", version))).build();
|
||||
}
|
||||
lines.add(IrisLanguage.text(
|
||||
BukkitRuntimeMessages.COMMAND_PACK_COMPAT_HEADER,
|
||||
MessageArgument.untrusted("pack", pack),
|
||||
MessageArgument.untrusted("version", version)));
|
||||
for (String line : PackCompatReport.of(result.getCompatFindings()).keyLines(0)) {
|
||||
lines.add(IrisLanguage.text(
|
||||
BukkitRuntimeMessages.COMMAND_PACK_MESSAGE_2,
|
||||
MessageArgument.untrusted("value", line)));
|
||||
}
|
||||
lines.add(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_COMPAT_REMEDY));
|
||||
return lines;
|
||||
return ChatReport.of(ChatReport.Tone.WARNING, IrisLanguage.text(
|
||||
BukkitRuntimeMessages.COMMAND_PACK_COMPAT_HEADER,
|
||||
MessageArgument.untrusted("pack", pack),
|
||||
MessageArgument.untrusted("version", version)))
|
||||
.items(PackCompatReport.of(result.getCompatFindings()).keyLines(0))
|
||||
.unlimited()
|
||||
.hint(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_COMPAT_REMEDY), null)
|
||||
.build();
|
||||
}
|
||||
|
||||
/** The live Minecraft version, falling back to the one the validation ran against. */
|
||||
@@ -363,7 +362,7 @@ public class CommandPack implements DirectorExecutor {
|
||||
return persisted == null || persisted.isBlank() ? "unknown" : persisted;
|
||||
}
|
||||
|
||||
PackValidationResult runValidate(VolmitSender s, File packFolder) {
|
||||
PackValidationResult runValidate(File packFolder) {
|
||||
PackValidationRegistry.ValidationTicket ticket =
|
||||
PackValidationRegistry.tryBeginValidation(packFolder.toPath());
|
||||
PackValidationResult result;
|
||||
@@ -399,7 +398,6 @@ public class CommandPack implements DirectorExecutor {
|
||||
result = new PackValidationResult(packFolder.getName(),
|
||||
List.of("Pack content changed during validation."), List.of(), System.currentTimeMillis());
|
||||
}
|
||||
reportResult(s, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -443,24 +441,46 @@ public class CommandPack implements DirectorExecutor {
|
||||
}
|
||||
|
||||
private void reportResult(VolmitSender s, PackValidationResult result) {
|
||||
if (result.isLoadable()) {
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_PACK_IS_LOADABLE_WARNINGS, MessageArgument.untrusted("packName", String.valueOf(result.getPackName())), MessageArgument.untrusted("size", String.valueOf(result.getWarnings().size()))));
|
||||
} else {
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_PACK_IS_BROKEN, MessageArgument.untrusted("packName", String.valueOf(result.getPackName()))));
|
||||
for (String reason : result.getBlockingErrors()) {
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_MESSAGE, MessageArgument.untrusted("reason", String.valueOf(reason))));
|
||||
}
|
||||
}
|
||||
int wMax = Math.min(10, result.getWarnings().size());
|
||||
for (int i = 0; i < wMax; i++) {
|
||||
s.sendMessage(IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_MESSAGE_2, MessageArgument.untrusted("value", String.valueOf(result.getWarnings().get(i)))));
|
||||
}
|
||||
if (result.getWarnings().size() > wMax) {
|
||||
s.sendMessage(IrisLanguage.text(
|
||||
BukkitRuntimeMessages.COMMAND_PACK_MORE_WARNING_S,
|
||||
MessageArgument.trusted("count", result.getWarnings().size() - wMax)
|
||||
));
|
||||
s.sendReport(validationReport(result));
|
||||
}
|
||||
|
||||
private static String statusLine(String name, PackValidationResult result) {
|
||||
TextKey key = result.isLoadable()
|
||||
? BukkitRuntimeMessages.COMMAND_PACK_STATUS_OK
|
||||
: BukkitRuntimeMessages.COMMAND_PACK_STATUS_BROKEN;
|
||||
String line = IrisLanguage.text(
|
||||
key,
|
||||
MessageArgument.trusted("pack", C.WHITE + ChatReport.clean(name)),
|
||||
MessageArgument.trusted("blocking", statusCount(result.getBlockingErrors().size(), C.RED)),
|
||||
MessageArgument.trusted("warnings", statusCount(result.getWarnings().size(), C.GOLD)));
|
||||
return LEADING_COLOR.matcher(line).replaceFirst(statusTone(result).color().toString());
|
||||
}
|
||||
|
||||
private static ChatReport.Tone statusTone(PackValidationResult result) {
|
||||
return !result.isLoadable() ? ChatReport.Tone.ERROR
|
||||
: result.getWarnings().isEmpty() ? ChatReport.Tone.SUCCESS : ChatReport.Tone.WARNING;
|
||||
}
|
||||
|
||||
private static String statusCount(int count, C color) {
|
||||
return (count == 0 ? C.DARK_GRAY : color) + String.valueOf(count) + C.GRAY;
|
||||
}
|
||||
|
||||
static ChatReport validationReport(PackValidationResult result) {
|
||||
String packName = String.valueOf(result.getPackName());
|
||||
if (!result.isLoadable()) {
|
||||
String revalidate = "/iris pack validate " + packName;
|
||||
return ChatReport.of(ChatReport.Tone.ERROR, IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_PACK_IS_BROKEN,
|
||||
MessageArgument.untrusted("packName", packName)))
|
||||
.items(result.getBlockingErrors())
|
||||
.hint("Fix the pack, then run " + revalidate, revalidate)
|
||||
.build();
|
||||
}
|
||||
ChatReport.Tone tone = result.getWarnings().isEmpty() ? ChatReport.Tone.SUCCESS : ChatReport.Tone.WARNING;
|
||||
return ChatReport.of(tone, IrisLanguage.text(BukkitRuntimeMessages.COMMAND_PACK_PACK_IS_LOADABLE_WARNINGS,
|
||||
MessageArgument.untrusted("packName", packName),
|
||||
MessageArgument.untrusted("size", String.valueOf(result.getWarnings().size()))))
|
||||
.items(result.getWarnings())
|
||||
.build();
|
||||
}
|
||||
|
||||
private File findPack(VolmitSender sender, String pack) {
|
||||
@@ -476,17 +496,12 @@ public class CommandPack implements DirectorExecutor {
|
||||
return packFolder;
|
||||
}
|
||||
|
||||
private void reportPaths(VolmitSender sender, List<String> paths, TextKey label) {
|
||||
int max = Math.min(10, paths.size());
|
||||
for (int i = 0; i < max; i++) {
|
||||
sender.sendMessage(IrisLanguage.text(
|
||||
BukkitCommandMessages.COMMAND_PACK_MESSAGE,
|
||||
MessageArgument.untrusted("label", IrisLanguage.text(label)),
|
||||
MessageArgument.untrusted("value", paths.get(i))
|
||||
));
|
||||
}
|
||||
if (paths.size() > max) {
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_PACK_MORE, MessageArgument.untrusted("value", (paths.size() - max))));
|
||||
private void reportPaths(VolmitSender sender, ChatReport.Tone tone, String header, List<String> paths, TextKey label) {
|
||||
ChatReport.Builder report = ChatReport.of(tone, header).limit(PATH_REPORT_LIMIT);
|
||||
String labelText = IrisLanguage.plain(label);
|
||||
for (String path : paths) {
|
||||
report.entry(labelText, path);
|
||||
}
|
||||
sender.sendReport(report.build());
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import art.arcane.iris.world.IrisToolbelt;
|
||||
import art.arcane.volmlib.util.director.annotations.Director;
|
||||
import art.arcane.volmlib.util.director.annotations.Param;
|
||||
import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.volmlib.util.format.Form;
|
||||
import art.arcane.volmlib.util.math.Position2;
|
||||
import org.bukkit.World;
|
||||
@@ -82,9 +83,13 @@ public class CommandPregen implements DirectorExecutor {
|
||||
} else {
|
||||
IrisToolbelt.pregenerate(task, world);
|
||||
}
|
||||
String msg = C.GREEN + "Pregen started in " + C.GOLD + world.getName() + C.GREEN + " of " + C.GOLD + (radius * 2) + C.GREEN + " by " + C.GOLD + (radius * 2) + C.GREEN + " blocks from " + C.GOLD + center.getX() + "," + center.getZ();
|
||||
String msg = C.GRAY + "Pregen started in " + ChatReport.highlight(world.getName())
|
||||
+ " over " + ChatReport.highlight((radius * 2) + "×" + (radius * 2)) + " blocks around "
|
||||
+ ChatReport.highlight(center.getBlockX() + ", " + center.getBlockZ());
|
||||
sender().sendMessage(msg);
|
||||
Iris.info(msg);
|
||||
if (sender().isPlayer()) {
|
||||
Iris.info(msg);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_PREGEN_FAILED_START_PREGENERATION_SEE_CONSOLE_DETAILS));
|
||||
Iris.reportError(e);
|
||||
@@ -94,9 +99,11 @@ public class CommandPregen implements DirectorExecutor {
|
||||
@Director(description = "Stop the active pregeneration task", descriptionKey = "iris.director.commandpregen.director.stop_active_pregeneration_task", aliases = "x")
|
||||
public void stop() {
|
||||
if (PregeneratorJob.shutdownInstance()) {
|
||||
String message = C.BLUE + "Pregen stop requested; finishing active work before cancellation.";
|
||||
sender().sendMessage(message);
|
||||
Iris.info(message);
|
||||
String message = "Pregen stop requested; finishing active work before cancellation.";
|
||||
sender().sendInfo(message);
|
||||
if (sender().isPlayer()) {
|
||||
Iris.info(message);
|
||||
}
|
||||
} else {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_PREGEN_NO_ACTIVE_PREGENERATION_TASKS_STOP));
|
||||
}
|
||||
@@ -120,8 +127,10 @@ public class CommandPregen implements DirectorExecutor {
|
||||
}
|
||||
|
||||
String world = progress.worldName() == null ? "?" : progress.worldName();
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_PREGEN_PREGEN, MessageArgument.untrusted("world", world), MessageArgument.untrusted("value", Form.f(progress.generated())), MessageArgument.untrusted("value2", Form.f(progress.totalChunks())), MessageArgument.untrusted("value3", String.format("%.1f", progress.percent())), MessageArgument.untrusted("value4", (progress.paused() ? C.YELLOW + " PAUSED" : ""))));
|
||||
sender().sendMessage(IrisLanguage.text(
|
||||
ChatReport.Tone tone = progress.failed() > 0 ? ChatReport.Tone.WARNING
|
||||
: progress.paused() ? ChatReport.Tone.INFO : ChatReport.Tone.SUCCESS;
|
||||
String headline = IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_PREGEN_PREGEN, MessageArgument.untrusted("world", world), MessageArgument.untrusted("value", Form.f(progress.generated())), MessageArgument.untrusted("value2", Form.f(progress.totalChunks())), MessageArgument.untrusted("value3", String.format("%.1f", progress.percent())), MessageArgument.untrusted("value4", (progress.paused() ? " PAUSED" : "")));
|
||||
sender().sendReport(ChatReport.of(tone, headline).item(IrisLanguage.text(
|
||||
BukkitCommandMessagesExtended.COMMAND_PREGEN_SPEED_S_ETA_ELAPSED_METHOD,
|
||||
MessageArgument.untrusted("overall", Form.f(progress.overallChunksPerSecond(), 1)),
|
||||
MessageArgument.untrusted("tenSecond", Form.f(progress.chunksPerSecond(), 1)),
|
||||
@@ -130,6 +139,6 @@ public class CommandPregen implements DirectorExecutor {
|
||||
MessageArgument.untrusted("eta", Form.duration(progress.eta(), 2)),
|
||||
MessageArgument.untrusted("elapsed", Form.duration(progress.elapsed(), 2)),
|
||||
MessageArgument.untrusted("method", progress.method()),
|
||||
MessageArgument.untrusted("failures", progress.failed() > 0 ? C.RED + " Failed: " + Form.f(progress.failed()) : "")));
|
||||
MessageArgument.untrusted("failures", progress.failed() > 0 ? " Failed: " + Form.f(progress.failed()) : ""))).build());
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.platform.bukkit.plugin.IrisService;
|
||||
import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
|
||||
import art.arcane.iris.world.task.J;
|
||||
@@ -190,7 +191,7 @@ public class CommandSVC implements IrisService, CommandExecutor, TabCompleter, D
|
||||
}
|
||||
if (!(args.length > 1 && args[0].equalsIgnoreCase("debug") && args[1].equalsIgnoreCase("dump"))
|
||||
&& !sender.hasPermission(ROOT_PERMISSION)) {
|
||||
ComponentMessenger.sendSection(sender, IrisLanguage.text(
|
||||
sendTaggedError(sender, IrisLanguage.text(
|
||||
IrisMessages.COMMAND_PERMISSION_DENIED,
|
||||
MessageArgument.trusted("permission", ROOT_PERMISSION)
|
||||
));
|
||||
@@ -200,6 +201,11 @@ public class CommandSVC implements IrisService, CommandExecutor, TabCompleter, D
|
||||
J.aBukkit(() -> executeCommand(sender, label, args));
|
||||
}
|
||||
|
||||
private static void sendTaggedError(CommandSender sender, String message) {
|
||||
String tag = Iris.instance == null ? "" : Iris.instance.getTag();
|
||||
ComponentMessenger.sendSection(sender, tag + ChatReport.Tone.ERROR.paint(message));
|
||||
}
|
||||
|
||||
public List<String> tabCompleteRoot(CommandSender sender, String alias, String[] args) {
|
||||
List<String> suggestions = args.length > 0 && args[0].equalsIgnoreCase("language")
|
||||
? Iris.instance.completeLanguage(sender, Arrays.copyOfRange(args, 1, args.length))
|
||||
@@ -349,10 +355,11 @@ public class CommandSVC implements IrisService, CommandExecutor, TabCompleter, D
|
||||
return sender instanceof Player;
|
||||
}
|
||||
|
||||
/** The director only reports parse and execution failures here, so they get the error style. */
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
if (message != null && !message.trim().isEmpty()) {
|
||||
ComponentMessenger.sendLiteral(sender, message);
|
||||
sendTaggedError(sender, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+65
-31
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.IrisStructureHandler;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.structure.BulkStructureImporter;
|
||||
@@ -42,6 +43,7 @@ import art.arcane.iris.structure.nativegen.NativeStructureGenerationStatus;
|
||||
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.volmlib.util.director.DirectorOrigin;
|
||||
import art.arcane.volmlib.util.director.annotations.Director;
|
||||
import art.arcane.volmlib.util.director.annotations.Param;
|
||||
@@ -61,11 +63,13 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.structure.Structure;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.localization.BukkitCommandMessages;
|
||||
@@ -73,6 +77,9 @@ import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
import art.arcane.iris.localization.BukkitCommandMessagesExtended;
|
||||
@Director(name = "structure", aliases = {"struct", "str"}, description = "Iris structure tools (index, import, info)", descriptionKey = "iris.director.commandstructure.director.iris_structure_tools_index_import_info")
|
||||
public class CommandStructure implements DirectorExecutor {
|
||||
private static final int VERIFY_ITEM_LIMIT = 15;
|
||||
private static final int UNREACHABLE_BIOMES_SHOWN = 3;
|
||||
private static final String VANILLA_NAMESPACE = "minecraft:";
|
||||
@Director(description = "Regenerate structure-index.json listing all vanilla, datapack & iris structures", descriptionKey = "iris.director.commandstructure.director.regenerate_structure_index_json_listing_all_vanilla_datapack_iris_structures", aliases = {"ls"}, origin = DirectorOrigin.BOTH)
|
||||
public void list(
|
||||
@Param(description = "The dimension whose pack to index", descriptionKey = "iris.director.commandstructure.param.dimension_whose_pack_index", aliases = "dim")
|
||||
@@ -171,7 +178,6 @@ public class CommandStructure implements DirectorExecutor {
|
||||
|
||||
private void runVerification(Engine engine, KList<String> structureKeys, int centerX, int centerZ,
|
||||
int searchRadius, VolmitSender commandSender, Player target) {
|
||||
KList<String> messages = new KList<>();
|
||||
Map<String, IrisNativeStructureDecision> decisions = new HashMap<>(structureKeys.size());
|
||||
boolean requiresNativeReachability = false;
|
||||
for (String keyName : structureKeys) {
|
||||
@@ -185,8 +191,8 @@ public class CommandStructure implements DirectorExecutor {
|
||||
try {
|
||||
reachable = StructureReachability.reachableKeys(engine);
|
||||
} catch (Throwable error) {
|
||||
messages.add(C.RED + "Structure verification could not resolve native biome reachability.");
|
||||
sendVerificationMessages(commandSender, target, messages);
|
||||
sendVerificationReport(commandSender, target, ChatReport.of(ChatReport.Tone.ERROR,
|
||||
"Structure verification could not resolve native biome reachability").build());
|
||||
Iris.reportError("Could not resolve native structure biome reachability for verification.", error);
|
||||
return;
|
||||
}
|
||||
@@ -197,6 +203,9 @@ public class CommandStructure implements DirectorExecutor {
|
||||
int unreachable = 0;
|
||||
int searchLimited = 0;
|
||||
int errors = 0;
|
||||
List<String> problems = new ArrayList<>();
|
||||
List<String> planned = new ArrayList<>();
|
||||
List<String> unreachableLines = new ArrayList<>();
|
||||
for (String keyName : structureKeys) {
|
||||
IrisNativeStructureDecision decision = decisions.get(keyName);
|
||||
if (IrisStructureLocator.isPlaced(engine, keyName)) {
|
||||
@@ -205,56 +214,81 @@ public class CommandStructure implements DirectorExecutor {
|
||||
IrisStructureLocator.locate(engine, keyName, centerX, centerZ, searchRadius);
|
||||
if (result.status() == IrisStructureLocator.LocateStatus.SEARCH_LIMIT_REACHED) {
|
||||
searchLimited++;
|
||||
messages.add(C.YELLOW + "[iris-search-limit] " + C.WHITE + keyName + C.YELLOW
|
||||
+ ": unable to complete the density search before its safety limit was reached");
|
||||
problems.add(verifyLine(C.GOLD, keyName, "density search hit its safety limit"));
|
||||
continue;
|
||||
}
|
||||
if (!result.found()) {
|
||||
messages.add(C.YELLOW + "[iris-not-found] " + C.WHITE + keyName);
|
||||
problems.add(verifyLine(C.GOLD, keyName, "not found in range"));
|
||||
continue;
|
||||
}
|
||||
located++;
|
||||
messages.add(C.AQUA + "[iris-planned] " + C.WHITE + keyName + C.GREEN + " @ "
|
||||
+ result.originX() + "," + result.baseY() + "," + result.originZ());
|
||||
planned.add(verifyLine(C.IRIS, keyName,
|
||||
result.originX() + ", " + result.baseY() + ", " + result.originZ()));
|
||||
} catch (Throwable error) {
|
||||
errors++;
|
||||
messages.add(C.RED + "[error] " + C.WHITE + keyName + C.RED + ": "
|
||||
+ error.getClass().getSimpleName());
|
||||
problems.add(verifyLine(C.RED, keyName, error.getClass().getSimpleName()));
|
||||
Iris.reportError("Could not verify Iris-placed structure '" + keyName + "'.", error);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!decision.generate()) {
|
||||
disabled++;
|
||||
messages.add(C.GRAY + "[disabled] " + C.WHITE + keyName);
|
||||
continue;
|
||||
}
|
||||
if (!reachable.contains(keyName.toLowerCase(Locale.ROOT))) {
|
||||
unreachable++;
|
||||
KList<String> missing = StructureReachability.missingBiomeKeys(engine, keyName);
|
||||
messages.add(C.YELLOW + "[unreachable] " + C.WHITE + keyName
|
||||
+ (missing.isEmpty() ? "" : C.YELLOW + " needs " + String.join("/", missing)));
|
||||
unreachableLines.add(unreachableLine(keyName, StructureReachability.missingBiomeKeys(engine, keyName)));
|
||||
continue;
|
||||
}
|
||||
nativeEligible++;
|
||||
messages.add(C.GREEN + "[native-eligible] " + C.WHITE + keyName);
|
||||
}
|
||||
messages.add(C.GREEN + "Structure verify: " + C.WHITE + located + C.GREEN + " Iris placement plans found, "
|
||||
+ C.WHITE + nativeEligible + C.GREEN + " native structures eligible, "
|
||||
+ C.WHITE + disabled + C.GREEN + " disabled by policy, "
|
||||
+ C.WHITE + unreachable + C.GREEN + " biome-unreachable, "
|
||||
+ C.WHITE + searchLimited + C.GREEN + " density searches safety-limited, "
|
||||
+ C.WHITE + errors + C.GREEN + " errors. Native eligibility is checked without running blocking live locates.");
|
||||
sendVerificationMessages(commandSender, target, messages);
|
||||
ChatReport.Tone tone = errors > 0 ? ChatReport.Tone.ERROR
|
||||
: problems.isEmpty() ? ChatReport.Tone.SUCCESS : ChatReport.Tone.WARNING;
|
||||
ChatReport.Builder report = ChatReport.of(tone, "Structure verify").limit(VERIFY_ITEM_LIMIT);
|
||||
report.styledItem(String.join(C.DARK_GRAY + " · ", List.of(
|
||||
verifyCount(located, "planned", C.IRIS),
|
||||
verifyCount(nativeEligible, "native", C.AQUA),
|
||||
verifyCount(problems.size() - errors - searchLimited, "not found", C.GOLD),
|
||||
verifyCount(searchLimited, "search-limited", C.GOLD),
|
||||
verifyCount(errors, "errors", C.RED),
|
||||
verifyCount(unreachable, "unreachable", C.GRAY),
|
||||
verifyCount(disabled, "disabled", C.GRAY))
|
||||
.stream().filter(count -> !count.isEmpty()).toList()));
|
||||
problems.forEach(report::styledItem);
|
||||
planned.forEach(report::styledItem);
|
||||
unreachableLines.forEach(report::styledItem);
|
||||
report.hint("Unreachable: no biome in this dimension can place it. Native eligibility is checked without blocking locates.", null);
|
||||
sendVerificationReport(commandSender, target, report.build());
|
||||
}
|
||||
|
||||
private void sendVerificationMessages(VolmitSender commandSender, Player target,
|
||||
KList<String> messages) {
|
||||
Runnable send = () -> {
|
||||
for (String message : messages) {
|
||||
commandSender.sendMessage(message);
|
||||
}
|
||||
};
|
||||
private static String verifyLine(C accent, String keyName, String detail) {
|
||||
return C.WHITE + structureName(keyName) + C.DARK_GRAY + " " + accent + ChatReport.clean(detail);
|
||||
}
|
||||
|
||||
private static String verifyCount(int count, String label, C color) {
|
||||
return count == 0 ? "" : color.toString() + count + C.GRAY + " " + label;
|
||||
}
|
||||
|
||||
private static String unreachableLine(String keyName, List<String> missingBiomes) {
|
||||
String name = C.GRAY + structureName(keyName) + C.DARK_GRAY + " ";
|
||||
if (missingBiomes.isEmpty()) {
|
||||
return name + "no biome can place it";
|
||||
}
|
||||
int shown = Math.min(UNREACHABLE_BIOMES_SHOWN, missingBiomes.size());
|
||||
String biomes = missingBiomes.subList(0, shown).stream()
|
||||
.map(CommandStructure::structureName)
|
||||
.collect(Collectors.joining(C.DARK_GRAY + ", " + C.GRAY, C.GRAY.toString(), ""));
|
||||
int hidden = missingBiomes.size() - shown;
|
||||
return name + "needs " + biomes + (hidden > 0 ? C.DARK_GRAY + " +" + hidden + " more" : "");
|
||||
}
|
||||
|
||||
private static String structureName(String key) {
|
||||
String cleaned = ChatReport.clean(key);
|
||||
return cleaned.startsWith(VANILLA_NAMESPACE) ? cleaned.substring(VANILLA_NAMESPACE.length()) : cleaned;
|
||||
}
|
||||
|
||||
private void sendVerificationReport(VolmitSender commandSender, Player target, ChatReport report) {
|
||||
Runnable send = () -> commandSender.sendReport(report);
|
||||
if (target != null) {
|
||||
J.runEntity(target, send);
|
||||
} else {
|
||||
@@ -293,7 +327,7 @@ public class CommandStructure implements DirectorExecutor {
|
||||
public void info(
|
||||
@Param(description = "The dimension whose pack holds the structure", descriptionKey = "iris.director.commandstructure.param.dimension_whose_pack_holds_structure", aliases = "dim")
|
||||
IrisDimension dimension,
|
||||
@Param(description = "The iris structure key to inspect", descriptionKey = "iris.director.commandstructure.param.iris_structure_key_inspect")
|
||||
@Param(description = "The iris structure key to inspect", descriptionKey = "iris.director.commandstructure.param.iris_structure_key_inspect", customHandler = IrisStructureHandler.class)
|
||||
String structure
|
||||
) {
|
||||
IrisData data = dimension.getLoader();
|
||||
@@ -331,7 +365,7 @@ public class CommandStructure implements DirectorExecutor {
|
||||
public void place(
|
||||
@Param(description = "The dimension whose pack holds the structure", descriptionKey = "iris.director.commandstructure.param.dimension_whose_pack_holds_structure_2", aliases = "dim")
|
||||
IrisDimension dimension,
|
||||
@Param(description = "The iris structure key to place", descriptionKey = "iris.director.commandstructure.param.iris_structure_key_place")
|
||||
@Param(description = "The iris structure key to place", descriptionKey = "iris.director.commandstructure.param.iris_structure_key_place", customHandler = IrisStructureHandler.class)
|
||||
String structure
|
||||
) {
|
||||
IrisData data = dimension.getLoader();
|
||||
|
||||
@@ -28,12 +28,16 @@ import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.studio.workspace.IrisProject;
|
||||
import art.arcane.iris.studio.workspace.IrisCodeWorkspace;
|
||||
import art.arcane.iris.localization.RuntimeUiMessages;
|
||||
import art.arcane.iris.localization.RuntimeProgressMessages;
|
||||
import art.arcane.iris.platform.bukkit.BoardSVC;
|
||||
import art.arcane.iris.studio.StudioSVC;
|
||||
import art.arcane.iris.structure.BulkStructureImporter;
|
||||
import art.arcane.iris.structure.FeatureImporter;
|
||||
import art.arcane.iris.structure.StructureImporter;
|
||||
import art.arcane.iris.world.IrisToolbelt;
|
||||
import art.arcane.iris.world.runtime.InPlaceChunkRegenerator;
|
||||
import art.arcane.iris.generation.runtime.DimensionStackContext;
|
||||
import art.arcane.iris.generation.runtime.DimensionStackLayout;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.world.loot.InventorySlotType;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
@@ -59,6 +63,7 @@ import art.arcane.volmlib.util.director.DirectorOrigin;
|
||||
import art.arcane.volmlib.util.director.annotations.Director;
|
||||
import art.arcane.volmlib.util.director.annotations.Param;
|
||||
import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.volmlib.util.format.Form;
|
||||
import art.arcane.volmlib.util.function.NoiseProvider;
|
||||
import art.arcane.volmlib.util.interpolation.InterpolationMethod;
|
||||
@@ -94,11 +99,13 @@ import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
@@ -109,9 +116,15 @@ import art.arcane.iris.localization.BukkitCommandMessagesExtended;
|
||||
@Director(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", descriptionKey = "iris.director.commandstudio.director.studio_commands")
|
||||
public class CommandStudio implements DirectorExecutor {
|
||||
private static final long CHUNK_SCAN_TIMEOUT_MS = 3_000;
|
||||
private static final String REGEN_STOP_COMMAND = "/iris std regen-stop";
|
||||
private CommandEdit edit;
|
||||
//private CommandDeepSearch deepSearch;
|
||||
|
||||
private static String regionShareLine(String region, int rarity, double share) {
|
||||
return C.WHITE + ChatReport.clean(region) + C.DARK_GRAY + ": " + C.IRIS + Form.pc(share, 1)
|
||||
+ C.DARK_GRAY + " · " + C.GRAY + "rarity " + rarity;
|
||||
}
|
||||
|
||||
public static String hrf(Duration duration) {
|
||||
return duration.toString().substring(2).replaceAll("(\\d[HMS])(?!$)", "$1 ").toLowerCase();
|
||||
}
|
||||
@@ -124,7 +137,6 @@ public class CommandStudio implements DirectorExecutor {
|
||||
long seed,
|
||||
@Param(defaultValue = "false", description = "Attempt to open Studio before a required registry restart", aliases = "f")
|
||||
boolean force) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_OPENING_STUDIO_PACK_SEED, MessageArgument.untrusted("value", dimension.getName()), MessageArgument.untrusted("seed", seed)));
|
||||
Iris.service(StudioSVC.class).open(sender(), seed, dimension.getLoadKey(), force);
|
||||
}
|
||||
|
||||
@@ -220,6 +232,88 @@ public class CommandStudio implements DirectorExecutor {
|
||||
LanguageAudience.run(audience, () -> sendHotloadResult(commandSender, failure)));
|
||||
}
|
||||
|
||||
@Director(name = "regen", aliases = {"rg"}, description = "Delete and regenerate nearby chunks in place using Iris generation", descriptionKey = "iris.director.commanddeveloper.director.delete_regenerate_nearby_chunks_place_using_iris_generation", origin = DirectorOrigin.PLAYER)
|
||||
public void regen(
|
||||
@Param(name = "radius", description = "The radius of nearby chunks", descriptionKey = "iris.director.commanddeveloper.param.radius_nearby_chunks", defaultValue = "5")
|
||||
int radius
|
||||
) {
|
||||
if (radius < 0) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_RADIUS_MUST_BE_0_GREATER_2));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = player();
|
||||
VolmitSender commandSender = sender();
|
||||
World world = player.getWorld();
|
||||
if (!IrisToolbelt.isIrisWorld(world)) {
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_YOU_MUST_BE_IRIS_WORLD_USE_REGEN));
|
||||
return;
|
||||
}
|
||||
|
||||
Engine engine = IrisToolbelt.access(world).getEngine();
|
||||
if (engine == null) {
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_ENGINE_ACCESS_THIS_WORLD_IS_NULL_GENERATE_NEARBY_CHUNKS_FIRST));
|
||||
return;
|
||||
}
|
||||
|
||||
int chunks = (radius * 2 + 1) * (radius * 2 + 1);
|
||||
|
||||
// The player position must be read on the thread owning the player; the regenerator hops per chunk itself.
|
||||
if (!J.runEntity(player, () -> {
|
||||
int centerX = player.getLocation().getBlockX() >> 4;
|
||||
int centerZ = player.getLocation().getBlockZ() >> 4;
|
||||
|
||||
InPlaceChunkRegenerator regenerator = new InPlaceChunkRegenerator(world, engine, commandSender, centerX, centerZ, radius);
|
||||
if (!regenerator.start()) {
|
||||
InPlaceChunkRegenerator.activeIn(world).ifPresent(running -> sendRegenAlreadyRunning(commandSender, world, running));
|
||||
return;
|
||||
}
|
||||
|
||||
String started = IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_DEVELOPER_REGEN_STARTED_CHUNK_S_AROUND_DELETING_REGENERATING_PLACE, MessageArgument.untrusted("chunks", chunks), MessageArgument.untrusted("centerX", centerX), MessageArgument.untrusted("centerZ", centerZ));
|
||||
commandSender.sendReport(withRegenStopHint(ChatReport.of(ChatReport.Tone.INFO, started), world).build());
|
||||
Iris.info("Regen run start: world=" + world.getName()
|
||||
+ " center=" + centerX + "," + centerZ
|
||||
+ " radius=" + radius
|
||||
+ " chunks=" + chunks);
|
||||
})) {
|
||||
Iris.warn("Could not schedule regen on the thread owning " + player.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@Director(name = "regen-stop", aliases = {"rgstop"}, description = "Stop the regen running in a world", descriptionKey = "iris.director.commanddeveloper.director.stop_regen_running_world", origin = DirectorOrigin.BOTH)
|
||||
public void regenStop(
|
||||
@Param(description = "The world whose regen to stop", descriptionKey = "iris.director.commanddeveloper.param.world_regen_stop", contextual = true, contextualOverride = true)
|
||||
World world
|
||||
) {
|
||||
String regenTitle = IrisLanguage.text(RuntimeProgressMessages.CHUNK_TITLE_REGEN);
|
||||
Optional<InPlaceChunkRegenerator> running = world == null ? Optional.empty() : InPlaceChunkRegenerator.activeIn(world);
|
||||
if (running.isEmpty()) {
|
||||
sender().sendInfo(IrisLanguage.text(RuntimeProgressMessages.CHUNK_NONE_RUNNING,
|
||||
MessageArgument.trusted("title", regenTitle),
|
||||
MessageArgument.untrusted("world", world == null ? "?" : world.getName())));
|
||||
return;
|
||||
}
|
||||
|
||||
running.get().requestStop();
|
||||
sender().sendWarning(IrisLanguage.text(RuntimeProgressMessages.CHUNK_STOPPING,
|
||||
MessageArgument.trusted("title", regenTitle),
|
||||
MessageArgument.untrusted("world", world.getName())));
|
||||
}
|
||||
|
||||
private static void sendRegenAlreadyRunning(VolmitSender sender, World world, InPlaceChunkRegenerator running) {
|
||||
String alreadyRunning = IrisLanguage.text(RuntimeProgressMessages.CHUNK_ALREADY_RUNNING,
|
||||
MessageArgument.trusted("title", IrisLanguage.text(RuntimeProgressMessages.CHUNK_TITLE_REGEN)),
|
||||
MessageArgument.untrusted("world", world.getName()),
|
||||
MessageArgument.trusted("applied", running.appliedChunks()),
|
||||
MessageArgument.trusted("total", running.totalChunks() <= 0 ? "?" : running.totalChunks()));
|
||||
sender.sendReport(withRegenStopHint(ChatReport.of(ChatReport.Tone.WARNING, alreadyRunning), world).build());
|
||||
}
|
||||
|
||||
private static ChatReport.Builder withRegenStopHint(ChatReport.Builder report, World world) {
|
||||
String hint = IrisLanguage.text(RuntimeProgressMessages.CHUNK_STOP_HINT, MessageArgument.untrusted("command", REGEN_STOP_COMMAND));
|
||||
return report.hint(hint, REGEN_STOP_COMMAND, REGEN_STOP_COMMAND + " world=" + world.getName());
|
||||
}
|
||||
|
||||
@Director(description = "Toggle your Studio debug scoreboard", descriptionKey = "iris.director.commandstudio.director.toggle_your_studio_debug_scoreboard", aliases = {"board", "sidebar", "sb"}, origin = DirectorOrigin.PLAYER)
|
||||
public void scoreboard() {
|
||||
Player target = player();
|
||||
@@ -353,6 +447,21 @@ public class CommandStudio implements DirectorExecutor {
|
||||
player().openInventory(inv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Region chances describe the pack's generator, so sample it directly; the engine's getRegion answers from saved
|
||||
* world history instead, which throws for every chunk whose history is not loaded.
|
||||
*/
|
||||
private static IrisRegion generatorRegion(Engine engine, int blockX, int blockZ) {
|
||||
DimensionStackContext stack = engine.getDimensionStackContext();
|
||||
if (stack != null) {
|
||||
DimensionStackLayout.Layer layer = stack.getLayout(blockX, blockZ).surfaceLayer();
|
||||
if (layer != null && layer.region() != null) {
|
||||
return layer.region();
|
||||
}
|
||||
}
|
||||
return engine.getComplex().getRegionStream().get(blockX, blockZ);
|
||||
}
|
||||
|
||||
@Director(description = "Calculate the chance for each region to generate", descriptionKey = "iris.director.commandstudio.director.calculate_chance_each_region_generate", origin = DirectorOrigin.PLAYER)
|
||||
public void regions(@Param(description = "The radius in chunks", descriptionKey = "iris.director.commandstudio.param.radius_chunks", defaultValue = "500") int radius) {
|
||||
var engine = engine();
|
||||
@@ -384,6 +493,7 @@ public class CommandStudio implements DirectorExecutor {
|
||||
var loc = player.getLocation();
|
||||
int totalTasks = d * d;
|
||||
AtomicInteger completedTasks = new AtomicInteger(0);
|
||||
AtomicReference<Throwable> firstFailure = new AtomicReference<>();
|
||||
progressShown = true;
|
||||
c = J.ar(() -> {
|
||||
double jobProgress = (double) completedTasks.get() / totalTasks;
|
||||
@@ -391,16 +501,32 @@ public class CommandStudio implements DirectorExecutor {
|
||||
BukkitPlatform.showProgressLane(player, "iris:job", IrisLanguage.text(RuntimeUiMessages.FINDING_REGIONS) + " " + Form.pc(jobProgress, 0), jobProgress, 4000L);
|
||||
}, 0);
|
||||
new Spiraler(d, d, (x, z) -> executor.queue(() -> {
|
||||
var region = engine.getRegion((x << 4) + 8, (z << 4) + 8);
|
||||
data.computeIfAbsent(region.getLoadKey(), (k) -> new AtomicInteger(0))
|
||||
.incrementAndGet();
|
||||
completedTasks.incrementAndGet();
|
||||
if (firstFailure.get() != null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var region = generatorRegion(engine, (x << 4) + 8, (z << 4) + 8);
|
||||
data.computeIfAbsent(region.getLoadKey(), (k) -> new AtomicInteger(0))
|
||||
.incrementAndGet();
|
||||
completedTasks.incrementAndGet();
|
||||
} catch (Throwable failure) {
|
||||
firstFailure.compareAndSet(null, failure);
|
||||
}
|
||||
})).setOffset(loc.getBlockX(), loc.getBlockZ()).drain();
|
||||
executor.complete();
|
||||
if (firstFailure.get() != null) {
|
||||
throw firstFailure.get();
|
||||
}
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_STUDIO_DONE));
|
||||
var loader = engine.getData().getRegionLoader();
|
||||
data.forEach((k, v) -> sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_STUDIO_MESSAGE, MessageArgument.untrusted("k", k), MessageArgument.untrusted("value", loader.load(k).getRarity()), MessageArgument.untrusted("value2", Form.f((double) v.get() / totalTasks * 100, 2)))));
|
||||
ChatReport.Builder report = ChatReport.of(ChatReport.Tone.SUCCESS,
|
||||
IrisLanguage.text(BukkitCommandMessages.COMMAND_STUDIO_DONE)).unlimited();
|
||||
data.entrySet().stream()
|
||||
.sorted((a, b) -> Integer.compare(b.getValue().get(), a.getValue().get()))
|
||||
.forEach(entry -> report.styledItem(regionShareLine(entry.getKey(),
|
||||
loader.load(entry.getKey()).getRarity(),
|
||||
(double) entry.getValue().get() / totalTasks)));
|
||||
sender.sendReport(report.build());
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_REGIONS_SCAN_FAILED,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.MarkerHandler;
|
||||
import art.arcane.iris.platform.bukkit.BukkitBlockResolution;
|
||||
|
||||
import art.arcane.iris.platform.bukkit.BukkitPlatform;
|
||||
@@ -203,7 +204,7 @@ public class CommandWhat implements DirectorExecutor {
|
||||
private static final int MARKER_SIGNAL_BATCH = 128;
|
||||
|
||||
@Director(description = "Show markers in chunk", descriptionKey = "iris.director.commandwhat.director.show_markers_chunk", origin = DirectorOrigin.PLAYER)
|
||||
public void markers(@Param(description = "Marker name such as cave_floor or cave_ceiling", descriptionKey = "iris.director.commandwhat.param.marker_name_such_as_cave_floor_cave_ceiling") String marker) {
|
||||
public void markers(@Param(description = "Marker name such as cave_floor or cave_ceiling", descriptionKey = "iris.director.commandwhat.param.marker_name_such_as_cave_floor_cave_ceiling", customHandler = MarkerHandler.class) String marker) {
|
||||
VolmitSender commandSender = sender();
|
||||
Player player = player();
|
||||
if (player == null) {
|
||||
|
||||
+49
-30
@@ -10,8 +10,10 @@ import art.arcane.volmlib.util.format.Form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.localization.BukkitCommandMessages;
|
||||
import art.arcane.volmlib.util.localization.TextKey;
|
||||
import art.arcane.iris.localization.RuntimeUiMessages;
|
||||
import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
final class IrisEngineStatus {
|
||||
@@ -22,36 +24,53 @@ final class IrisEngineStatus {
|
||||
CacheSummary caches = summarizeCaches();
|
||||
MaintenanceMetrics metrics = snapshot.metrics();
|
||||
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MESSAGE));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_STATUS));
|
||||
sender.sendMessage(IrisLanguage.text(
|
||||
BukkitCommandMessages.IRIS_ENGINE_STATUS_SERVICE,
|
||||
MessageArgument.trusted("value", status(snapshot.serviceRunning()))
|
||||
));
|
||||
sender.sendMessage(IrisLanguage.text(
|
||||
BukkitCommandMessages.IRIS_ENGINE_STATUS_METRICS,
|
||||
MessageArgument.trusted("value", status(snapshot.metricsRunning()))
|
||||
));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MAINTENANCE_PERIOD, MessageArgument.untrusted("value", Form.duration(snapshot.maintenancePeriodMillis()))));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_WORKER_PARALLELISM, MessageArgument.untrusted("value", snapshot.workerParallelism())));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_ACTIVE_WORLD_TASKS, MessageArgument.untrusted("value", metrics.activeTasks())));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_TECTONIC_PLATES));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_CONFIGURED_RETENTION, MessageArgument.untrusted("value", Form.duration(snapshot.retentionMillis()))));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_HEAP_USAGE, MessageArgument.untrusted("value", Form.pc(snapshot.heapUsage()))));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_RESIDENT, MessageArgument.untrusted("value", metrics.residentTectonicPlates())));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_QUEUED, MessageArgument.untrusted("value", metrics.queuedTectonicPlates())));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_AVERAGE_IDLE_DURATION, MessageArgument.untrusted("value", Form.duration(metrics.averageIdleDuration(), 2))));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MAX_IDLE_DURATION, MessageArgument.untrusted("value", Form.duration(metrics.maxIdleDuration(), 2))));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MIN_IDLE_DURATION, MessageArgument.untrusted("value", Form.duration(metrics.minIdleDuration(), 2))));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_CACHES));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_RESOURCE, MessageArgument.untrusted("value", caches.sizes()[0]), MessageArgument.untrusted("value2", caches.counts()[0])));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_2D_STREAM, MessageArgument.untrusted("value", caches.sizes()[1]), MessageArgument.untrusted("value2", caches.counts()[1])));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_3D_STREAM, MessageArgument.untrusted("value", caches.sizes()[2]), MessageArgument.untrusted("value2", caches.counts()[2])));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_OTHER, MessageArgument.untrusted("value", caches.sizes()[3]), MessageArgument.untrusted("value2", caches.counts()[3])));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_OTHER_2));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_IRIS_WORLDS, MessageArgument.untrusted("value", metrics.worlds())));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_LOADED_CHUNKS, MessageArgument.untrusted("value", metrics.loadedChunks())));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MESSAGE_2));
|
||||
sender.sendReport(section(BukkitCommandMessages.IRIS_ENGINE_STATUS_STATUS,
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_SERVICE, MessageArgument.trusted("value", status(snapshot.serviceRunning()))),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_METRICS, MessageArgument.trusted("value", status(snapshot.metricsRunning()))),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MAINTENANCE_PERIOD, MessageArgument.untrusted("value", Form.duration(snapshot.maintenancePeriodMillis()))),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_WORKER_PARALLELISM, MessageArgument.untrusted("value", snapshot.workerParallelism())),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_ACTIVE_WORLD_TASKS, MessageArgument.untrusted("value", metrics.activeTasks()))));
|
||||
sender.sendReport(section(BukkitCommandMessages.IRIS_ENGINE_STATUS_TECTONIC_PLATES,
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_CONFIGURED_RETENTION, MessageArgument.untrusted("value", Form.duration(snapshot.retentionMillis()))),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_HEAP_USAGE, MessageArgument.untrusted("value", Form.pc(snapshot.heapUsage()))),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_RESIDENT, MessageArgument.untrusted("value", metrics.residentTectonicPlates())),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_QUEUED, MessageArgument.untrusted("value", metrics.queuedTectonicPlates())),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_AVERAGE_IDLE_DURATION, MessageArgument.untrusted("value", Form.duration(metrics.averageIdleDuration(), 2))),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MAX_IDLE_DURATION, MessageArgument.untrusted("value", Form.duration(metrics.maxIdleDuration(), 2))),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_MIN_IDLE_DURATION, MessageArgument.untrusted("value", Form.duration(metrics.minIdleDuration(), 2)))));
|
||||
sender.sendReport(section(BukkitCommandMessages.IRIS_ENGINE_STATUS_CACHES,
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_RESOURCE, MessageArgument.untrusted("value", caches.sizes()[0]), MessageArgument.untrusted("value2", caches.counts()[0])),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_2D_STREAM, MessageArgument.untrusted("value", caches.sizes()[1]), MessageArgument.untrusted("value2", caches.counts()[1])),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_3D_STREAM, MessageArgument.untrusted("value", caches.sizes()[2]), MessageArgument.untrusted("value2", caches.counts()[2])),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_OTHER, MessageArgument.untrusted("value", caches.sizes()[3]), MessageArgument.untrusted("value2", caches.counts()[3]))));
|
||||
sender.sendReport(section(BukkitCommandMessages.IRIS_ENGINE_STATUS_OTHER_2,
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_IRIS_WORLDS, MessageArgument.untrusted("value", metrics.worlds())),
|
||||
IrisLanguage.text(BukkitCommandMessages.IRIS_ENGINE_STATUS_LOADED_CHUNKS, MessageArgument.untrusted("value", metrics.loadedChunks()))));
|
||||
}
|
||||
|
||||
private static ChatReport section(TextKey header, String... statLines) {
|
||||
ChatReport.Builder report = ChatReport.of(ChatReport.Tone.INFO, stripTrailingColon(IrisLanguage.text(header))).unlimited();
|
||||
for (String statLine : statLines) {
|
||||
addStat(report, statLine);
|
||||
}
|
||||
return report.build();
|
||||
}
|
||||
|
||||
/** Status keys render as {@code - Label: value}; a labelled stat becomes a report entry, anything else a plain item. */
|
||||
private static void addStat(ChatReport.Builder report, String statLine) {
|
||||
String cleaned = ChatReport.clean(statLine);
|
||||
String withoutDash = cleaned.startsWith("-") ? cleaned.substring(1).strip() : cleaned;
|
||||
int separator = withoutDash.indexOf(": ");
|
||||
if (separator < 0) {
|
||||
report.styledItem(withoutDash);
|
||||
return;
|
||||
}
|
||||
report.entry(withoutDash.substring(0, separator), withoutDash.substring(separator + 2));
|
||||
}
|
||||
|
||||
private static String stripTrailingColon(String header) {
|
||||
String cleaned = ChatReport.clean(header);
|
||||
return cleaned.endsWith(":") ? cleaned.substring(0, cleaned.length() - 1) : cleaned;
|
||||
}
|
||||
|
||||
private static String status(boolean running) {
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package art.arcane.iris.platform.bukkit;
|
||||
|
||||
import art.arcane.iris.platform.bukkit.nms.INMS;
|
||||
import art.arcane.iris.platform.bukkit.plugin.IrisService;
|
||||
import io.papermc.paper.event.server.ServerResourcesReloadedEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
/** Lets the server's placement rules apply again after a resource reload, which may have changed the block tags they read. */
|
||||
public class BlockRulesSVC implements IrisService {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onResourcesReloaded(ServerResourcesReloadedEvent event) {
|
||||
if (INMS.isBound()) {
|
||||
INMS.get().forgetBlockRules();
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-32
@@ -27,7 +27,9 @@ import art.arcane.iris.world.lifecycle.WorldLifecycleStaging;
|
||||
import art.arcane.iris.pack.validation.CompatRegistry;
|
||||
import art.arcane.iris.world.lifecycle.WorldReplacementSeed;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.pack.BrokenPackException;
|
||||
import art.arcane.iris.pack.PackBootReporter;
|
||||
import art.arcane.iris.pack.PackDownloader;
|
||||
import art.arcane.iris.pack.PackDirectoryResolver;
|
||||
import art.arcane.iris.pack.PackValidationCache;
|
||||
@@ -82,7 +84,6 @@ import java.util.stream.Stream;
|
||||
*/
|
||||
public final class IrisWorldGeneratorResolver {
|
||||
private static final int VALIDATION_STABILITY_ATTEMPTS = 2;
|
||||
private static final int COMPAT_BOOT_KEY_CAP = 3;
|
||||
private static final Object SNAPSHOT_VALIDATION_LOCK = new Object();
|
||||
private static final String IRIS_DIMENSION_NAMESPACE = "iris";
|
||||
private static final String PLOT_SQUARED_DISCOVERY_WORLD = "CheckingPlotSquaredGenerator";
|
||||
@@ -235,38 +236,16 @@ public final class IrisWorldGeneratorResolver {
|
||||
PackValidationRegistry.publish(packDirectory.toPath(), result, packFingerprint, contextFingerprint);
|
||||
}
|
||||
String minecraftVersion = IrisPlatforms.isBound() ? IrisPlatforms.get().minecraftVersion() : null;
|
||||
String compatSummary = PackValidator.compatSummary(result, minecraftVersion);
|
||||
String compatSuffix = compatSummary.isEmpty() ? "" : " " + compatSummary;
|
||||
if (!result.isLoadable()) {
|
||||
if (hasPendingExternalContent(result, IrisServices.getOrNull(ExternalDataSVC.class))
|
||||
&& packDirectory != null
|
||||
&& PackValidator.validateForDatapackBootstrap(packDirectory).isLoadable()) {
|
||||
Iris.info("Pack '" + result.getPackName() + "' is waiting for external block providers to initialize.");
|
||||
Iris.info("Waiting for external block providers before loading pack '" + result.getPackName() + "'…");
|
||||
continue;
|
||||
}
|
||||
Iris.error("Pack '" + result.getPackName()
|
||||
+ "' FAILED validation - world and Studio creation with this pack will be refused. Reasons:");
|
||||
for (String reason : result.getBlockingErrors()) {
|
||||
Iris.error(" - " + reason);
|
||||
}
|
||||
} else if (!result.getWarnings().isEmpty()) {
|
||||
Iris.info("Pack '" + result.getPackName() + "' validated ("
|
||||
+ result.getWarnings().size() + " warning(s))." + compatSuffix);
|
||||
for (String warning : result.getWarnings()) {
|
||||
Iris.warn(" [" + result.getPackName() + "] " + warning);
|
||||
}
|
||||
} else if (cached.isEmpty()) {
|
||||
if (compatSummary.isEmpty()) {
|
||||
Iris.success("Pack '" + result.getPackName() + "' validated.");
|
||||
} else {
|
||||
Iris.info("Pack '" + result.getPackName() + "' validated." + compatSuffix);
|
||||
}
|
||||
} else if (!compatSummary.isEmpty()) {
|
||||
Iris.info("Pack '" + result.getPackName() + "' validated." + compatSuffix);
|
||||
}
|
||||
// Cache hits carry the persisted findings, so the listing prints on every boot, not only after a miss.
|
||||
for (String line : PackValidator.compatBootLines(result, minecraftVersion, COMPAT_BOOT_KEY_CAP)) {
|
||||
Iris.warn(line);
|
||||
PackBootReporter.logBroken(result, minecraftVersion);
|
||||
} else {
|
||||
PackBootReporter.logValidated(result, minecraftVersion, false);
|
||||
}
|
||||
}
|
||||
IrisStartupValidation.markPacksReady();
|
||||
@@ -705,11 +684,11 @@ public final class IrisWorldGeneratorResolver {
|
||||
try {
|
||||
requireSnapshotLoadable(snapshotRoot);
|
||||
} catch (BrokenPackException exception) {
|
||||
Iris.error("Refusing to create world '" + worldName + "' using broken snapshot at '"
|
||||
+ snapshotRoot + "':");
|
||||
for (String reason : exception.getReasons()) {
|
||||
Iris.error(" - " + reason);
|
||||
}
|
||||
ChatReport.of(ChatReport.Tone.ERROR, "Refusing to create world '" + worldName
|
||||
+ "' using broken snapshot at '" + snapshotRoot + "'")
|
||||
.items(exception.getReasons())
|
||||
.build()
|
||||
.log();
|
||||
throw exception;
|
||||
}
|
||||
|
||||
@@ -731,6 +710,11 @@ public final class IrisWorldGeneratorResolver {
|
||||
return new BukkitChunkGenerator(world, false, snapshotRoot, dimension.getLoadKey(), history);
|
||||
}
|
||||
|
||||
/** Whether a pack fails validation only because a block provider plugin has not registered its blocks yet. */
|
||||
public static boolean awaitsExternalContent(PackValidationResult validation) {
|
||||
return hasPendingExternalContent(validation, IrisServices.getOrNull(ExternalDataSVC.class));
|
||||
}
|
||||
|
||||
static boolean hasPendingExternalContent(PackValidationResult validation, ExternalDataSVC external) {
|
||||
return validation != null && external != null && validation.getCompatFindings().stream()
|
||||
.anyMatch(finding -> finding.registry() == CompatRegistry.BLOCK
|
||||
|
||||
+14
-5
@@ -19,7 +19,7 @@
|
||||
package art.arcane.iris.world;
|
||||
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.world.safeguard.GenerationRefusalNotice;
|
||||
import art.arcane.volmlib.util.bukkit.WorldIdentity;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -84,8 +84,17 @@ public final class WorldRefusalReporter implements Listener {
|
||||
if (!player.isOp() && !player.hasPermission("iris.all")) {
|
||||
return;
|
||||
}
|
||||
for (String notice : operatorNotices.values()) {
|
||||
player.sendMessage(C.RED + notice);
|
||||
ChatReport report = ChatReport.of(ChatReport.Tone.ERROR, operatorNotices.size() == 1
|
||||
? "An Iris world did not load and refuses to generate"
|
||||
: operatorNotices.size() + " Iris worlds did not load and refuse to generate")
|
||||
.items(operatorNotices.values())
|
||||
.hint("The console has the full refusal notice", null)
|
||||
.build();
|
||||
String tag = Iris.instance == null ? "" : Iris.instance.getTag();
|
||||
player.sendMessage(ChatReport.SPACER.text());
|
||||
player.sendMessage(tag + report.titleLine().text());
|
||||
for (ChatReport.Line line : report.bodyLines(true)) {
|
||||
player.sendMessage(line.text());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,8 +108,8 @@ public final class WorldRefusalReporter implements Listener {
|
||||
for (String line : notice(worldName, key, failure, startupWorldsCreated)) {
|
||||
Iris.error(line);
|
||||
}
|
||||
operatorNotices.put(worldKey == null ? worldName : key, "Iris world '" + worldName + "' (" + key
|
||||
+ ") did not load and refuses to generate: " + GenerationRefusalNotice.summary(failure));
|
||||
operatorNotices.put(worldKey == null ? worldName : key, worldName + " (" + key + "): "
|
||||
+ GenerationRefusalNotice.summary(failure));
|
||||
} catch (Throwable reportingFailure) {
|
||||
System.err.println("[Iris] Iris refused to generate world '" + worldName + "' (" + key
|
||||
+ "); the refusal could not be reported: " + reportingFailure.getClass().getName());
|
||||
|
||||
@@ -27,7 +27,7 @@ export default {
|
||||
await context.step('regeneration removes target furniture and preserves neighbor ownership', async () => {
|
||||
const ready = await context.command('/iriscenative neighbor', /CE_NEIGHBOR_READY|CE_FAILED/, 30000)
|
||||
context.expect(ready.includes('CE_NEIGHBOR_READY chunk=2,0 furniture=3 target=1'), ready)
|
||||
const regenerated = await context.command('/iris developer regen radius=0', /Regen complete:|Regen failed:/, 90000)
|
||||
const regenerated = await context.command('/iris studio regen radius=0', /Regen complete:|Regen failed:/, 90000)
|
||||
context.expect(regenerated.includes('Regen complete:'), regenerated)
|
||||
const response = await context.command('/iriscenative loaded', /CE_LOADED|CE_FAILED/, 30000)
|
||||
context.expect(response.includes('CE_LOADED removed=1 untouched=1 replacement=1 wall=1 target=1'), response)
|
||||
|
||||
@@ -62,12 +62,12 @@ export default {
|
||||
})
|
||||
await context.step('unload while the player is inside and verify evacuation', async () => {
|
||||
context.expect((await playerWorld()) === storageName, 'Player must be inside the world before unload')
|
||||
await context.command(`/iris unloadWorld ${worldKey}`)
|
||||
await context.command(`/iris unload-world ${worldKey}`)
|
||||
await wait(async () => await settledStatus('loaded=false registered=true configured=true disk=true'), 'World unloaded with storage preserved')
|
||||
await assertEvacuated('Unload evacuated the player to a loaded world')
|
||||
})
|
||||
await context.step('reload the saved world and enter it again', async () => {
|
||||
await context.command(`/iris loadWorld ${worldName}`)
|
||||
await context.command(`/iris load-world ${worldName}`)
|
||||
await wait(async () => await settledStatus('loaded=true registered=true configured=true disk=true'), 'World reloaded')
|
||||
await context.command(`/iris tp ${worldKey}`)
|
||||
await assertSafeEntry()
|
||||
|
||||
+8
-3
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.pack.validation.CompatAction;
|
||||
import art.arcane.iris.pack.validation.CompatFinding;
|
||||
import art.arcane.iris.pack.validation.CompatRegistry;
|
||||
@@ -30,9 +31,13 @@ public class CommandPackCompatTest {
|
||||
return new PackValidationResult("overworld", List.of(), List.of(), 1L, findings, "26.1.2");
|
||||
}
|
||||
|
||||
private static List<String> plainCompatOutput(String pack, PackValidationResult result) {
|
||||
return CommandPack.compatOutput(pack, result).stream().map(ChatReport::clean).toList();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknownPackIsReportedWithoutAnyCompatLines() {
|
||||
List<String> lines = CommandPack.compatOutput("nope", null);
|
||||
List<String> lines = plainCompatOutput("nope", null);
|
||||
|
||||
assertEquals(1, lines.size());
|
||||
assertTrue(lines.getFirst(), lines.getFirst().contains("No validation result for 'nope'"));
|
||||
@@ -40,7 +45,7 @@ public class CommandPackCompatTest {
|
||||
|
||||
@Test
|
||||
public void packWithoutFindingsSaysSoAndNamesTheVersion() {
|
||||
List<String> lines = CommandPack.compatOutput("overworld", result(List.of()));
|
||||
List<String> lines = plainCompatOutput("overworld", result(List.of()));
|
||||
|
||||
assertEquals(1, lines.size());
|
||||
assertTrue(lines.getFirst(), lines.getFirst().contains("Pack 'overworld' uses no content"));
|
||||
@@ -49,7 +54,7 @@ public class CommandPackCompatTest {
|
||||
|
||||
@Test
|
||||
public void findingsArePrintedUncappedWithTheFallbackRemedy() {
|
||||
List<String> lines = CommandPack.compatOutput("overworld", result(List.of(
|
||||
List<String> lines = plainCompatOutput("overworld", result(List.of(
|
||||
block(CompatAction.EXCLUDED, "cave/a"),
|
||||
block(CompatAction.EXCLUDED, "cave/b"),
|
||||
block(CompatAction.EXCLUDED, "cave/c"),
|
||||
|
||||
+3
-4
@@ -7,7 +7,6 @@ import art.arcane.iris.pack.PackValidationRegistry;
|
||||
import art.arcane.iris.pack.PackValidationCache;
|
||||
import art.arcane.iris.pack.PackValidationResult;
|
||||
import art.arcane.iris.pack.PackValidator;
|
||||
import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -83,7 +82,7 @@ public class CommandPackValidationPublicationTest {
|
||||
try (MockedStatic<PackValidator> validator = mockStatic(PackValidator.class)) {
|
||||
validator.when(() -> PackValidator.validate(root)).thenReturn(valid);
|
||||
|
||||
assertSame(valid, new CommandPack().runValidate(mock(VolmitSender.class), root));
|
||||
assertSame(valid, new CommandPack().runValidate(root));
|
||||
|
||||
assertSame(valid, PackValidationRegistry.get(root.toPath()));
|
||||
assertSame(valid, PackValidationRegistry.get(root.getName()));
|
||||
@@ -101,7 +100,7 @@ public class CommandPackValidationPublicationTest {
|
||||
}
|
||||
});
|
||||
|
||||
assertFalse(new CommandPack().runValidate(mock(VolmitSender.class), root).isLoadable());
|
||||
assertFalse(new CommandPack().runValidate(root).isLoadable());
|
||||
assertNull(PackValidationRegistry.get(root.toPath()));
|
||||
assertNull(PackValidationRegistry.get(root.getName()));
|
||||
}
|
||||
@@ -119,7 +118,7 @@ public class CommandPackValidationPublicationTest {
|
||||
return new PackValidationResult(root.getName(), List.of(), List.of(), 1L);
|
||||
});
|
||||
|
||||
assertFalse(new CommandPack().runValidate(mock(VolmitSender.class), root).isLoadable());
|
||||
assertFalse(new CommandPack().runValidate(root).isLoadable());
|
||||
assertFalse(PackValidationRegistry.get(root.toPath()).isLoadable());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ repositories {
|
||||
name = 'FabricMC'
|
||||
url = uri('https://maven.fabricmc.net/')
|
||||
}
|
||||
maven { url = uri('https://repo.codemc.io/repository/maven-public/') }
|
||||
maven { url = uri('https://repo.codemc.org/repository/maven-public/') }
|
||||
maven { url = uri('https://jitpack.io') }
|
||||
maven { url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') }
|
||||
}
|
||||
@@ -331,6 +331,7 @@ tasks.named('shadowJar', ShadowJar).configure {
|
||||
if ((int) irisModTarget.java == 21) {
|
||||
exclude(java21RuntimeExclusions)
|
||||
}
|
||||
exclude('META-INF/maven/**')
|
||||
exclude('META-INF/proguard/**')
|
||||
exclude('META-INF/*.SF')
|
||||
exclude('META-INF/*.DSA')
|
||||
@@ -414,7 +415,6 @@ tasks.named('assemble').configure {
|
||||
}
|
||||
|
||||
pluginPackaging {
|
||||
nativeBoundaryChecks = true
|
||||
artifacts {
|
||||
create('distribution') {
|
||||
taskName = irisModTarget.fabricRemap ? 'remapJar' : 'shadowJar'
|
||||
|
||||
@@ -121,7 +121,7 @@ repositories {
|
||||
maven fg.forgeMaven
|
||||
maven fg.minecraftLibsMaven
|
||||
mavenCentral()
|
||||
maven { url = uri('https://repo.codemc.io/repository/maven-public/') }
|
||||
maven { url = uri('https://repo.codemc.org/repository/maven-public/') }
|
||||
maven { url = uri('https://jitpack.io') }
|
||||
maven { url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') }
|
||||
}
|
||||
@@ -320,6 +320,7 @@ tasks.named('shadowJar', ShadowJar).configure {
|
||||
if ((int) irisModTarget.java == 21) {
|
||||
exclude(java21RuntimeExclusions)
|
||||
}
|
||||
exclude('META-INF/maven/**')
|
||||
exclude('META-INF/proguard/**')
|
||||
exclude('META-INF/*.SF')
|
||||
exclude('META-INF/*.DSA')
|
||||
@@ -376,7 +377,6 @@ tasks.named('assemble').configure {
|
||||
}
|
||||
|
||||
pluginPackaging {
|
||||
nativeBoundaryChecks = true
|
||||
artifacts {
|
||||
create('distribution') {
|
||||
taskName = 'shadowJar'
|
||||
|
||||
@@ -21,6 +21,7 @@ package art.arcane.iris.modded;
|
||||
import art.arcane.iris.pack.PackFingerprints;
|
||||
|
||||
import art.arcane.iris.pack.BrokenPackException;
|
||||
import art.arcane.iris.pack.PackBootReporter;
|
||||
import art.arcane.iris.pack.PackDirectoryResolver;
|
||||
import art.arcane.iris.pack.PackDownloader;
|
||||
import art.arcane.iris.pack.PackValidationRegistry;
|
||||
@@ -43,7 +44,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public final class ModdedStartup {
|
||||
private static final int COMPAT_BOOT_KEY_CAP = 3;
|
||||
private static final AtomicBoolean PREPARED = new AtomicBoolean(false);
|
||||
private static final AtomicBoolean STARTED = new AtomicBoolean(false);
|
||||
private static final AtomicBoolean RESTORE_BEGUN = new AtomicBoolean(false);
|
||||
@@ -142,22 +142,10 @@ public final class ModdedStartup {
|
||||
try {
|
||||
PackValidationResult result = validatePack(packDir);
|
||||
String minecraftVersion = IrisPlatforms.isBound() ? IrisPlatforms.get().minecraftVersion() : null;
|
||||
String compatSummary = PackValidator.compatSummary(result, minecraftVersion);
|
||||
String compatSuffix = compatSummary.isEmpty() ? "" : " " + compatSummary;
|
||||
if (!result.isLoadable()) {
|
||||
ModdedIrisLog.error("Iris pack '{}' FAILED validation with {} blocking error(s); world/studio creation will be refused. First error: {}",
|
||||
result.getPackName(), result.getBlockingErrors().size(),
|
||||
result.getBlockingErrors().getFirst());
|
||||
} else if (!result.getWarnings().isEmpty()) {
|
||||
ModdedIrisLog.info("Iris pack '{}' validated ({} warning(s)).{}", result.getPackName(), result.getWarnings().size(), compatSuffix);
|
||||
for (String warning : result.getWarnings()) {
|
||||
ModdedIrisLog.warn(" [{}] {}", result.getPackName(), warning);
|
||||
}
|
||||
if (result.isLoadable()) {
|
||||
PackBootReporter.logValidated(result, minecraftVersion, true);
|
||||
} else {
|
||||
ModdedIrisLog.info("Iris pack '{}' validated.{}", result.getPackName(), compatSuffix);
|
||||
}
|
||||
for (String line : PackValidator.compatBootLines(result, minecraftVersion, COMPAT_BOOT_KEY_CAP)) {
|
||||
ModdedIrisLog.warn("{}", line);
|
||||
PackBootReporter.logBroken(result, minecraftVersion);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
ModdedIrisLog.error("Iris pack validation failed for '{}'", packDir.getName(), e);
|
||||
|
||||
+1
-1
@@ -73,7 +73,6 @@ final class ModdedCommandHelp {
|
||||
Entry.command("catalog", "[namespace|refresh]", ModdedCatalogMessages.HELP_CATALOG),
|
||||
Entry.group("ingest", ModdedCatalogMessages.HELP_INGEST),
|
||||
Entry.command("metrics", "", ModdedHelpMessages.COMMAND_METRICS_PRINT_GENERATION_METRICS_FOR_YOUR_CURRENT_IRIS_DIMENSION, "measure"),
|
||||
Entry.command("regen", "[radius]", ModdedHelpMessages.COMMAND_REGEN_DELETE_AND_REGENERATE_NEARBY_CHUNKS_IN_PLACE, "rg"),
|
||||
Entry.group("pregen", ModdedHelpMessages.GROUP_PREGEN_PREGENERATE_AN_IRIS_DIMENSION, "pregenerate"),
|
||||
Entry.command("wand", "", ModdedHelpMessages.COMMAND_WAND_GET_AN_IRIS_OBJECT_WAND),
|
||||
Entry.command("dust", "", ModdedHelpMessages.COMMAND_DUST_GET_DUST_THAT_REVEALS_OBJECT_PLACEMENTS, "d"),
|
||||
@@ -151,6 +150,7 @@ final class ModdedCommandHelp {
|
||||
Entry.command("tpstudio", "", ModdedHelpMessages.COMMAND_TPSTUDIO_TELEPORT_INTO_THE_OPEN_STUDIO_DIMENSION, "stp"),
|
||||
Entry.command("status", "", ModdedHelpMessages.COMMAND_STATUS_SHOW_THE_OPEN_STUDIO_DIMENSION_AND_ITS_PACK),
|
||||
Entry.command("hotload", "", ModdedHelpMessages.COMMAND_HOTLOAD_REFRESH_THE_OPEN_STUDIO, "refresh"),
|
||||
Entry.command("regen", "[radius]", ModdedHelpMessages.COMMAND_REGEN_DELETE_AND_REGENERATE_NEARBY_CHUNKS_IN_PLACE, "rg"),
|
||||
Entry.command("noise", "[generator] [seed]", ModdedHelpMessages.COMMAND_NOISE_OPEN_THE_NOISE_EXPLORER_GUI_ON_THE_SERVER_DISPLAY, "nmap"),
|
||||
Entry.command("map", "", ModdedHelpMessages.COMMAND_MAP_OPEN_THE_VISION_MAP_GUI_ON_THE_SERVER_DISPLAY, "render"),
|
||||
Entry.command("vscode", "[pack]", ModdedHelpMessages.COMMAND_VSCODE_REGENERATE_THE_CODE_WORKSPACE_FOR_A_PACK_AND_OPEN_IT_IN_YOUR, "vsc"),
|
||||
|
||||
-10
@@ -120,9 +120,6 @@ final class ModdedCommandTree {
|
||||
root.then(metricsTree("metrics"));
|
||||
root.then(metricsTree("measure"));
|
||||
|
||||
root.then(regenTree("regen"));
|
||||
root.then(regenTree("rg"));
|
||||
|
||||
root.then(pregenTree("pregen"));
|
||||
root.then(pregenTree("pregenerate"));
|
||||
|
||||
@@ -222,13 +219,6 @@ final class ModdedCommandTree {
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> IrisModdedCommands.metrics(context.getSource())));
|
||||
}
|
||||
|
||||
private static LiteralArgumentBuilder<NativeCommandSource> regenTree(String name) {
|
||||
return NativeCommandRegistration.literal(name).requires(GATE)
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> IrisModdedCommands.regen(context.getSource(), 0)))
|
||||
.then(NativeCommandRegistration.argument("radius", IntegerArgumentType.integer(0, 64))
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> IrisModdedCommands.regen(context.getSource(), IntegerArgumentType.getInteger(context, "radius")))));
|
||||
}
|
||||
|
||||
private static LiteralArgumentBuilder<NativeCommandSource> gotoTree(String name) {
|
||||
return NativeCommandRegistration.literal(name).requires(GATE)
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> ModdedCommandHelp.send(context.getSource(), name)))
|
||||
|
||||
+9
@@ -159,6 +159,8 @@ public final class ModdedStudioCommands {
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> hotload(context.getSource()))));
|
||||
root.then(NativeCommandRegistration.literal("refresh")
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> hotload(context.getSource()))));
|
||||
root.then(regenTree("regen"));
|
||||
root.then(regenTree("rg"));
|
||||
root.then(workspaceTree("vscode", true));
|
||||
root.then(workspaceTree("vsc", true));
|
||||
root.then(workspaceTree("update", false));
|
||||
@@ -210,6 +212,13 @@ public final class ModdedStudioCommands {
|
||||
STUDIOS.clear();
|
||||
}
|
||||
|
||||
private static LiteralArgumentBuilder<NativeCommandSource> regenTree(String name) {
|
||||
return NativeCommandRegistration.literal(name)
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> IrisModdedCommands.regen(context.getSource(), 0)))
|
||||
.then(NativeCommandRegistration.argument("radius", IntegerArgumentType.integer(0, 64))
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> IrisModdedCommands.regen(context.getSource(), IntegerArgumentType.getInteger(context, "radius")))));
|
||||
}
|
||||
|
||||
private static LiteralArgumentBuilder<NativeCommandSource> openTree(String name) {
|
||||
return NativeCommandRegistration.literal(name)
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> openHelp(context.getSource())))
|
||||
|
||||
+17
@@ -206,6 +206,23 @@ public class IrisModdedCommandParityTest {
|
||||
assertNotNull("pack cp", child(child(iris, "pk"), "cp").getCommand());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void regenLivesUnderStudio() {
|
||||
SharedConstants.tryDetectVersion();
|
||||
Bootstrap.bootStrap();
|
||||
CommandDispatcher<CommandSourceStack> dispatcher = new CommandDispatcher<>();
|
||||
|
||||
IrisModdedCommands.register(new NativeCommandRegistration(dispatcher));
|
||||
|
||||
CommandNode<CommandSourceStack> iris = child(dispatcher.getRoot(), "iris");
|
||||
assertNotNull("std regen", child(child(iris, "std"), "regen").getCommand());
|
||||
assertNotNull("studio rg radius", child(child(child(iris, "studio"), "rg"), "radius").getCommand());
|
||||
assertNull("top-level regen", iris.getChild("regen"));
|
||||
assertNull("top-level rg", iris.getChild("rg"));
|
||||
assertTrue(ModdedCommandHelp.consoleLines("studio").stream().anyMatch((String line) ->
|
||||
line.startsWith("/iris studio regen [radius] (rg) - ")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void consoleHelpListsEveryEntryWithInlineUsageAndDescription() {
|
||||
List<String> root = ModdedCommandHelp.consoleLines("");
|
||||
|
||||
@@ -105,7 +105,7 @@ repositories {
|
||||
name = 'NeoForged'
|
||||
url = uri('https://maven.neoforged.net/releases/')
|
||||
}
|
||||
maven { url = uri('https://repo.codemc.io/repository/maven-public/') }
|
||||
maven { url = uri('https://repo.codemc.org/repository/maven-public/') }
|
||||
maven { url = uri('https://jitpack.io') }
|
||||
maven { url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') }
|
||||
}
|
||||
@@ -304,6 +304,7 @@ tasks.named('shadowJar', ShadowJar).configure {
|
||||
if ((int) irisModTarget.java == 21) {
|
||||
exclude(java21RuntimeExclusions)
|
||||
}
|
||||
exclude('META-INF/maven/**')
|
||||
exclude('META-INF/proguard/**')
|
||||
exclude('META-INF/*.SF')
|
||||
exclude('META-INF/*.DSA')
|
||||
@@ -360,7 +361,6 @@ tasks.named('assemble').configure {
|
||||
}
|
||||
|
||||
pluginPackaging {
|
||||
nativeBoundaryChecks = true
|
||||
artifacts {
|
||||
create('distribution') {
|
||||
taskName = 'shadowJar'
|
||||
|
||||
+8
-7
@@ -1,4 +1,5 @@
|
||||
import art.arcane.volmit.packaging.PackedJar
|
||||
import art.arcane.volmit.packaging.PackagingMode
|
||||
import art.arcane.volmit.packaging.NativeDevelopmentTargets
|
||||
import io.papermc.paperweight.userdev.PaperweightUser
|
||||
import io.papermc.paperweight.userdev.PaperweightUserDependenciesExtension
|
||||
@@ -653,7 +654,7 @@ allprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = uri('https://repo.papermc.io/repository/maven-public/') }
|
||||
maven { url = uri('https://repo.codemc.io/repository/maven-public/') }
|
||||
maven { url = uri('https://repo.codemc.org/repository/maven-public/') }
|
||||
|
||||
maven {
|
||||
url = uri('https://jitpack.io')
|
||||
@@ -758,6 +759,11 @@ pluginPackaging {
|
||||
packedJarAccessors = ['art/arcane/iris/platform/bukkit/plugin/VolmitPlugin#getJarFile']
|
||||
packedPayloadOnlyPrefixes = ['iris-language-guides/', 'META-INF/iris/generation-kernels/abi-', 'iris/icons/views/', 'iris/datapack/']
|
||||
packedMaximumBootstrapClasses = 90
|
||||
stripDirectories = true
|
||||
stripLocalVariables = true
|
||||
releaseCompression = providers.gradleProperty('compactRelease')
|
||||
.map { String value -> value.toBoolean() }
|
||||
.getOrElse(!PackagingMode.resolve(providers).development())
|
||||
prunePrefixes = ['art/arcane/volmlib/']
|
||||
keepPrefixes = ['art/arcane/volmlib/util/matter/slices/', 'art/arcane/volmlib/nativelib/']
|
||||
shrinkRules = [file('packaging/shrink.pro'), nativeRuntimeRules.get().asFile]
|
||||
@@ -1004,12 +1010,7 @@ tasks.withType(PackedJar).configureEach {
|
||||
dependsOn(tasks.named('verifyBukkitArtifact'), nativeRuntime)
|
||||
nativeArtifacts.set(providers.provider { embeddedNatives() })
|
||||
doLast { PackedJar task ->
|
||||
File artifact = task.outputJar.get().asFile
|
||||
Map<String, byte[]> outer = NativeRuntimeArtifacts.entries(artifact)
|
||||
Map<String, byte[]> runtime = outer.containsKey('META-INF/volmit/runtime.properties')
|
||||
? PackedJar.readRuntime(artifact.toPath()) : outer
|
||||
NativeRuntimeArtifacts.verifyPacked(runtime, outer.get(NativeRuntimeArtifacts.MANIFEST), nativeRuntimeModules,
|
||||
embeddedNatives())
|
||||
NativeRuntimeArtifacts.verifyPacked(task.outputJar.get().asFile, nativeRuntimeModules, embeddedNatives())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ dependencies {
|
||||
implementation(gradleApi())
|
||||
implementation('org.ow2.asm:asm:9.10.1')
|
||||
implementation('org.apache.commons:commons-compress:1.28.0')
|
||||
implementation('org.tukaani:xz:1.10')
|
||||
implementation('io.papermc.paperweight:paperweight-userdev:2.0.0-beta.21')
|
||||
testImplementation('junit:junit:4.13.2')
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import org.gradle.api.GradleException;
|
||||
import org.tukaani.xz.XZInputStream;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
@@ -27,6 +28,7 @@ import java.util.zip.ZipInputStream;
|
||||
public final class NativeRuntimeArtifacts {
|
||||
public static final String MANIFEST = "META-INF/iris/native-runtime.properties";
|
||||
public static final String RESOURCES = "META-INF/iris/native/";
|
||||
private static final String PAYLOAD = "META-INF/volmit/runtime.jar.xz";
|
||||
private static final String GROUP = "com.github.VolmitSoftware.VolmLib";
|
||||
private static final String NATIVE = "art/arcane/volmlib/nativelib/";
|
||||
|
||||
@@ -97,20 +99,35 @@ public final class NativeRuntimeArtifacts {
|
||||
}
|
||||
}
|
||||
|
||||
/** Checks the native providers inside {@code runtime}, the entries the plugin runs from, against the resolved build. */
|
||||
public static void verifyPacked(Map<String, byte[]> runtime, byte[] outerManifest, List<String> modules,
|
||||
Map<String, File> natives) throws IOException {
|
||||
public static void verifyPacked(File artifact, List<String> modules, Map<String, File> natives) throws IOException {
|
||||
requireModules(natives, modules);
|
||||
byte[] manifest = runtime.get(MANIFEST);
|
||||
Map<String, byte[]> contents;
|
||||
try (JarFile jar = new JarFile(artifact)) {
|
||||
JarEntry payload = jar.getJarEntry(PAYLOAD);
|
||||
if (payload == null) {
|
||||
contents = read(Files.newInputStream(artifact.toPath()));
|
||||
} else {
|
||||
try (InputStream input = new XZInputStream(jar.getInputStream(payload))) {
|
||||
contents = read(new ByteArrayInputStream(input.readAllBytes()));
|
||||
}
|
||||
JarEntry outer = jar.getJarEntry(MANIFEST);
|
||||
byte[] embedded = contents.get(MANIFEST);
|
||||
if (outer != null && embedded != null) {
|
||||
try (InputStream input = jar.getInputStream(outer)) {
|
||||
if (!Arrays.equals(input.readAllBytes(), embedded)) {
|
||||
throw new GradleException("Packed native runtime manifests differ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
byte[] manifest = contents.get(MANIFEST);
|
||||
if (manifest == null) {
|
||||
throw new GradleException("Missing native runtime dependency manifest");
|
||||
}
|
||||
if (outerManifest != null && !Arrays.equals(outerManifest, manifest)) {
|
||||
throw new GradleException("Packed native runtime manifests differ");
|
||||
}
|
||||
verifyManifest(manifest, natives);
|
||||
for (String module : natives.keySet()) {
|
||||
byte[] provider = runtime.get(RESOURCES + module + ".jar");
|
||||
byte[] provider = contents.get(RESOURCES + module + ".jar");
|
||||
if (provider == null) {
|
||||
throw new GradleException("Missing embedded native provider: " + module);
|
||||
}
|
||||
@@ -120,18 +137,6 @@ public final class NativeRuntimeArtifacts {
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, byte[]> entries(File artifact) throws IOException {
|
||||
Map<String, byte[]> contents = new TreeMap<>();
|
||||
try (ZipInputStream archive = new ZipInputStream(Files.newInputStream(artifact.toPath()))) {
|
||||
for (ZipEntry entry = archive.getNextEntry(); entry != null; entry = archive.getNextEntry()) {
|
||||
if (!entry.isDirectory()) {
|
||||
contents.put(entry.getName(), archive.readAllBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
private static void verifyManifest(byte[] bytes, Map<String, File> natives) throws IOException {
|
||||
Properties manifest = new Properties();
|
||||
manifest.load(new ByteArrayInputStream(bytes));
|
||||
@@ -158,6 +163,18 @@ public final class NativeRuntimeArtifacts {
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String, byte[]> read(InputStream source) throws IOException {
|
||||
Map<String, byte[]> contents = new TreeMap<>();
|
||||
try (ZipInputStream archive = new ZipInputStream(source)) {
|
||||
for (ZipEntry entry = archive.getNextEntry(); entry != null; entry = archive.getNextEntry()) {
|
||||
if (!entry.isDirectory()) {
|
||||
contents.put(entry.getName(), archive.readAllBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
private static boolean implementation(String name) {
|
||||
if (!name.startsWith(NATIVE)) {
|
||||
return false;
|
||||
|
||||
@@ -33,6 +33,14 @@ public final class GenerationRevisionScope {
|
||||
"core/src/main/java/art/arcane/iris/diagnostics/splash/IrisSplashRenderer.java",
|
||||
"core/src/main/java/art/arcane/iris/diagnostics/splash/IrisSplashComposer.java",
|
||||
"core/src/main/java/art/arcane/iris/diagnostics/splash/IrisSplashPackScanner.java",
|
||||
"core/src/main/java/art/arcane/iris/diagnostics/BuildChannel.java",
|
||||
"core/src/main/java/art/arcane/iris/diagnostics/BuildIdentity.java",
|
||||
"core/src/main/java/art/arcane/iris/diagnostics/BuildFacts.java",
|
||||
"core/src/main/java/art/arcane/iris/diagnostics/SystemFacts.java",
|
||||
"core/src/main/java/art/arcane/iris/diagnostics/DiagnosticFact.java",
|
||||
"core/src/main/java/art/arcane/iris/diagnostics/DiagnosticSection.java",
|
||||
"core/src/main/java/art/arcane/iris/diagnostics/DiagnosticsReport.java",
|
||||
"core/src/main/java/art/arcane/iris/diagnostics/FactFormat.java",
|
||||
"adapters/modded-common/src/main/java/art/arcane/iris/modded/ModdedIrisSplash.java",
|
||||
"adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandDebug.java",
|
||||
"adapters/bukkit/plugin/src/main/java/art/arcane/iris/command/CommandDeveloper.java",
|
||||
|
||||
@@ -4,11 +4,13 @@ import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.tukaani.xz.LZMA2Options;
|
||||
import org.tukaani.xz.XZOutputStream;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.MessageDigest;
|
||||
@@ -20,7 +22,6 @@ import java.util.TreeMap;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
@@ -88,35 +89,15 @@ public class NativeRuntimeArtifactsTest {
|
||||
public void verifiesTheEmbeddedProviderBytesInsideThePackedRuntime() throws Exception {
|
||||
Map<String, File> natives = natives();
|
||||
Map<String, byte[]> runtime = runtime(natives, natives);
|
||||
byte[] manifest = runtime.get(NativeRuntimeArtifacts.MANIFEST);
|
||||
NativeRuntimeArtifacts.verifyPacked(runtime, manifest, MODULES, natives);
|
||||
NativeRuntimeArtifacts.verifyPacked(runtime, null, MODULES, natives);
|
||||
NativeRuntimeArtifacts.verifyPacked(packed(runtime), MODULES, natives);
|
||||
NativeRuntimeArtifacts.verifyPacked(jar("ordinary.jar", runtime), MODULES, natives);
|
||||
Map<String, File> rebuilt = new TreeMap<>(natives);
|
||||
rebuilt.put("native-v26_2_R1", provider("rebuilt.jar", "art/arcane/volmlib/util/collection/KMap"));
|
||||
assertThrows(GradleException.class, () -> NativeRuntimeArtifacts.verifyPacked(runtime(natives, rebuilt),
|
||||
manifest, MODULES, natives));
|
||||
assertThrows(GradleException.class, () -> NativeRuntimeArtifacts.verifyPacked(packed(runtime(natives, rebuilt)),
|
||||
MODULES, natives));
|
||||
Map<String, byte[]> missing = new TreeMap<>(runtime);
|
||||
missing.remove(NativeRuntimeArtifacts.RESOURCES + "native-v26_2_R1.jar");
|
||||
assertThrows(GradleException.class, () -> NativeRuntimeArtifacts.verifyPacked(missing, manifest, MODULES, natives));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsAnOuterManifestThatDiffersFromTheRuntimeOne() throws Exception {
|
||||
Map<String, File> natives = natives();
|
||||
Map<String, byte[]> runtime = runtime(natives, natives);
|
||||
byte[] outer = (new String(runtime.get(NativeRuntimeArtifacts.MANIFEST), StandardCharsets.UTF_8) + "extra=1\n")
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
assertThrows(GradleException.class, () -> NativeRuntimeArtifacts.verifyPacked(runtime, outer, MODULES, natives));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readsEveryFileEntryOfAnOrdinaryJar() throws Exception {
|
||||
Map<String, byte[]> runtime = runtime(natives(), natives());
|
||||
Map<String, byte[]> read = NativeRuntimeArtifacts.entries(jar("ordinary.jar", runtime));
|
||||
assertEquals(runtime.keySet(), read.keySet());
|
||||
for (Map.Entry<String, byte[]> entry : runtime.entrySet()) {
|
||||
assertArrayEquals(entry.getValue(), read.get(entry.getKey()));
|
||||
}
|
||||
assertThrows(GradleException.class, () -> NativeRuntimeArtifacts.verifyPacked(packed(missing), MODULES, natives));
|
||||
}
|
||||
|
||||
private Map<String, File> natives() throws IOException {
|
||||
@@ -156,6 +137,17 @@ public class NativeRuntimeArtifactsTest {
|
||||
return contents;
|
||||
}
|
||||
|
||||
private File packed(Map<String, byte[]> runtime) throws IOException {
|
||||
ByteArrayOutputStream compressed = new ByteArrayOutputStream();
|
||||
try (XZOutputStream xz = new XZOutputStream(compressed, new LZMA2Options(1))) {
|
||||
xz.write(Files.readAllBytes(jar("payload.jar", runtime).toPath()));
|
||||
}
|
||||
Map<String, byte[]> outer = new TreeMap<>();
|
||||
outer.put(NativeRuntimeArtifacts.MANIFEST, runtime.get(NativeRuntimeArtifacts.MANIFEST));
|
||||
outer.put("META-INF/volmit/runtime.jar.xz", compressed.toByteArray());
|
||||
return jar("packed.jar", outer);
|
||||
}
|
||||
|
||||
private File jar(String name, Map<String, byte[]> contents) throws IOException {
|
||||
Path file = temporary.newFolder().toPath().resolve(name);
|
||||
try (JarOutputStream jar = new JarOutputStream(Files.newOutputStream(file))) {
|
||||
|
||||
@@ -235,6 +235,18 @@ tasks.named('processResources').configure { Task resources ->
|
||||
}
|
||||
def templateSource = file('src/main/templates')
|
||||
def templateDest = layout.buildDirectory.dir('generated/sources/templates')
|
||||
def sourceHashesProvided = { -> providers.environmentVariable('MULTIPLEXOR_SOURCE_HASHES').isPresent() }
|
||||
def gitOutput = { String... arguments ->
|
||||
try {
|
||||
Process process = new ProcessBuilder(['git', '-C', rootProject.projectDir.absolutePath] + arguments.toList())
|
||||
.redirectError(ProcessBuilder.Redirect.DISCARD)
|
||||
.start()
|
||||
String output = new String(process.inputStream.readAllBytes(), StandardCharsets.UTF_8).trim()
|
||||
return process.waitFor() == 0 ? output : null
|
||||
} catch (Exception ignored) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
def generateTemplates = tasks.register('generateTemplates', Copy) {
|
||||
inputs.properties([
|
||||
environment: providers.provider {
|
||||
@@ -283,6 +295,23 @@ def generateTemplates = tasks.register('generateTemplates', Copy) {
|
||||
logger.error('Git commit hash not found', failure)
|
||||
return 'unknown'
|
||||
},
|
||||
branch: providers.provider {
|
||||
if (sourceHashesProvided()) {
|
||||
return ''
|
||||
}
|
||||
String branch = gitOutput('rev-parse', '--abbrev-ref', 'HEAD')
|
||||
if (branch == null || branch == 'HEAD') {
|
||||
return ''
|
||||
}
|
||||
return branch.replace('\\', '\\\\').replace('"', '\\"')
|
||||
},
|
||||
dirty: providers.provider {
|
||||
if (sourceHashesProvided()) {
|
||||
return false
|
||||
}
|
||||
String status = gitOutput('status', '--porcelain')
|
||||
return status != null && !status.isEmpty()
|
||||
},
|
||||
minecraftVersion: providers.gradleProperty('minecraftVersion'),
|
||||
])
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package art.arcane.iris.diagnostics;
|
||||
|
||||
import art.arcane.iris.BuildConstants;
|
||||
|
||||
public enum BuildChannel {
|
||||
RELEASE,
|
||||
DEVELOPMENT;
|
||||
|
||||
private static final String RELEASE_ENVIRONMENT = "production";
|
||||
private static final BuildChannel CURRENT = of(BuildConstants.ENVIRONMENT);
|
||||
|
||||
public static BuildChannel current() {
|
||||
return CURRENT;
|
||||
}
|
||||
|
||||
static BuildChannel of(String environment) {
|
||||
return RELEASE_ENVIRONMENT.equals(environment) ? RELEASE : DEVELOPMENT;
|
||||
}
|
||||
|
||||
public boolean isDevelopment() {
|
||||
return this == DEVELOPMENT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
package art.arcane.iris.diagnostics;
|
||||
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.generation.simd.SimdSupport;
|
||||
import art.arcane.iris.pack.PackValidationRegistry;
|
||||
import art.arcane.iris.pack.PackValidationResult;
|
||||
import art.arcane.iris.platform.bukkit.nms.INMS;
|
||||
import art.arcane.iris.platform.bukkit.nms.v1X.NMSBinding1X;
|
||||
import art.arcane.iris.world.safeguard.IrisSafeguard;
|
||||
import art.arcane.iris.world.safeguard.Mode;
|
||||
import art.arcane.volmlib.util.noise.FractalBillowSimplexNoise;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.CodeSource;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.TreeMap;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/** The build block: which jar runs, what it was built against, and what startup made of it. */
|
||||
public final class BuildFacts {
|
||||
private static final String VOLMLIB_STAMP = "META-INF/volmit/volmlib.properties";
|
||||
private static final String LOCAL_VOLMLIB_SOURCE = "local";
|
||||
private static final int SHORT_COMMIT_LENGTH = 7;
|
||||
private static final String DIRTY_MARK = "+dirty";
|
||||
private static final String NATIVE_NOISE_STATUS_PREFIX = "native";
|
||||
private static final String SCALAR_SIMD = "scalar";
|
||||
private static final Pattern IRIS_JAR_NAME = Pattern.compile("(?i)iris\\b.*\\.jar");
|
||||
private static final int SETTINGS_SHOWN = 4;
|
||||
private static final int PACKS_SHOWN = 6;
|
||||
|
||||
private BuildFacts() {
|
||||
}
|
||||
|
||||
enum TerrainProvider {
|
||||
NATIVE,
|
||||
DISABLED,
|
||||
UNBOUND
|
||||
}
|
||||
|
||||
enum PackOutcome {
|
||||
LOADABLE,
|
||||
WAITING,
|
||||
FAILED
|
||||
}
|
||||
|
||||
record Jar(String path, Optional<Duration> age, List<String> otherIrisJars) {
|
||||
}
|
||||
|
||||
record Natives(String noiseStatus, TerrainProvider terrain, String simd) {
|
||||
}
|
||||
|
||||
record PackState(String name, PackOutcome outcome, int warnings) {
|
||||
}
|
||||
|
||||
public static DiagnosticSection current(Predicate<PackValidationResult> awaitingExternalContent) {
|
||||
return DiagnosticSection.gather(title(BuildIdentity.current()), List.of(
|
||||
() -> currentJar().flatMap(BuildFacts::jar),
|
||||
() -> volmLibStamp().flatMap(BuildFacts::volmLib),
|
||||
() -> natives(currentNatives()),
|
||||
() -> settings(currentSettingChanges()),
|
||||
() -> checks(IrisSafeguard.asContext()),
|
||||
() -> packs(packStates(PackValidationRegistry.snapshot(), awaitingExternalContent))));
|
||||
}
|
||||
|
||||
static String title(BuildIdentity build) {
|
||||
if (!build.channel().isDevelopment()) {
|
||||
return "Build " + build.commitLabel();
|
||||
}
|
||||
String title = "Dev build " + build.commitLabel();
|
||||
return build.hasBranch() ? title + " on " + build.branch() : title;
|
||||
}
|
||||
|
||||
static Optional<DiagnosticFact> jar(Jar jar) {
|
||||
DiagnosticFact.Items items = new DiagnosticFact.Items().plain(jar.path());
|
||||
jar.age().ifPresent(age -> items.muted("deployed " + FactFormat.age(age) + " ago"));
|
||||
if (!jar.otherIrisJars().isEmpty()) {
|
||||
items.warning("also " + String.join(", ", jar.otherIrisJars()));
|
||||
}
|
||||
return items.fact("Jar");
|
||||
}
|
||||
|
||||
static Optional<DiagnosticFact> volmLib(Properties stamp) {
|
||||
String source = stamp.getProperty("source");
|
||||
if (source == null || source.isBlank()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
if (!LOCAL_VOLMLIB_SOURCE.equals(source)) {
|
||||
return new DiagnosticFact.Items().plain(source).fact("VolmLib");
|
||||
}
|
||||
String commit = stamp.getProperty("commit", "unknown");
|
||||
String shortCommit = commit.length() > SHORT_COMMIT_LENGTH ? commit.substring(0, SHORT_COMMIT_LENGTH) : commit;
|
||||
String dirtyMark = Boolean.parseBoolean(stamp.getProperty("dirty")) ? DIRTY_MARK : "";
|
||||
return new DiagnosticFact.Items().plain(LOCAL_VOLMLIB_SOURCE + " @ " + shortCommit + dirtyMark).fact("VolmLib");
|
||||
}
|
||||
|
||||
static Optional<DiagnosticFact> natives(Natives natives) {
|
||||
boolean nativeNoise = natives.noiseStatus().startsWith(NATIVE_NOISE_STATUS_PREFIX);
|
||||
return new DiagnosticFact.Items()
|
||||
.flagged(nativeNoise ? "noise ok" : "noise " + natives.noiseStatus(), !nativeNoise)
|
||||
.flagged(terrainLabel(natives.terrain()), natives.terrain() != TerrainProvider.NATIVE)
|
||||
.flagged("SIMD " + natives.simd(), SCALAR_SIMD.equals(natives.simd()))
|
||||
.fact("Natives");
|
||||
}
|
||||
|
||||
private static String terrainLabel(TerrainProvider terrain) {
|
||||
return switch (terrain) {
|
||||
case NATIVE -> "terrain ok";
|
||||
case DISABLED -> "terrain off";
|
||||
case UNBOUND -> "terrain failed";
|
||||
};
|
||||
}
|
||||
|
||||
static Optional<DiagnosticFact> settings(Map<String, String> changes) {
|
||||
DiagnosticFact.Items items = new DiagnosticFact.Items();
|
||||
if (changes.isEmpty()) {
|
||||
return items.muted("defaults").fact("Settings");
|
||||
}
|
||||
changes.entrySet().stream()
|
||||
.limit(SETTINGS_SHOWN)
|
||||
.forEach(change -> items.plain(change.getKey() + "=" + change.getValue()));
|
||||
int hidden = changes.size() - SETTINGS_SHOWN;
|
||||
if (hidden > 0) {
|
||||
items.muted("+" + hidden + " more");
|
||||
}
|
||||
return items.fact("Settings");
|
||||
}
|
||||
|
||||
/** Every leaf of {@code current} that differs from {@code defaults}, keyed by its dotted path, in settings order. */
|
||||
static Map<String, String> settingChanges(JsonElement current, JsonElement defaults) {
|
||||
Map<String, String> changes = new LinkedHashMap<>();
|
||||
collectSettingChanges("", current, defaults, changes);
|
||||
return changes;
|
||||
}
|
||||
|
||||
private static void collectSettingChanges(String path, JsonElement current, JsonElement defaults,
|
||||
Map<String, String> changes) {
|
||||
if (current == null || !current.isJsonObject()) {
|
||||
if (!Objects.equals(current, defaults)) {
|
||||
changes.put(path, settingValue(current));
|
||||
}
|
||||
return;
|
||||
}
|
||||
JsonObject defaultSection = defaults != null && defaults.isJsonObject() ? defaults.getAsJsonObject() : new JsonObject();
|
||||
for (Map.Entry<String, JsonElement> setting : current.getAsJsonObject().entrySet()) {
|
||||
String settingPath = path.isEmpty() ? setting.getKey() : path + "." + setting.getKey();
|
||||
collectSettingChanges(settingPath, setting.getValue(), defaultSection.get(setting.getKey()), changes);
|
||||
}
|
||||
}
|
||||
|
||||
private static String settingValue(JsonElement value) {
|
||||
if (value == null || value.isJsonNull()) {
|
||||
return "null";
|
||||
}
|
||||
return value.isJsonPrimitive() ? value.getAsString() : value.toString();
|
||||
}
|
||||
|
||||
static Optional<DiagnosticFact> checks(Map<String, String> modeIdsByCheck) {
|
||||
Map<Mode, List<String>> checksByMode = new EnumMap<>(Mode.class);
|
||||
modeIdsByCheck.forEach((check, modeId) -> checksByMode
|
||||
.computeIfAbsent(Mode.valueOf(modeId.toUpperCase(Locale.ROOT)), ignored -> new ArrayList<>())
|
||||
.add(check));
|
||||
DiagnosticFact.Items items = new DiagnosticFact.Items();
|
||||
checksByMode.forEach((mode, checks) -> {
|
||||
if (mode == Mode.STABLE) {
|
||||
items.plain(checks.size() + " ok");
|
||||
return;
|
||||
}
|
||||
String outcome = mode == Mode.WARNING ? " warn (" : " failed (";
|
||||
items.warning(checks.size() + outcome + String.join(", ", checks) + ")");
|
||||
});
|
||||
return items.fact("Checks");
|
||||
}
|
||||
|
||||
static Optional<DiagnosticFact> packs(List<PackState> packs) {
|
||||
DiagnosticFact.Items items = new DiagnosticFact.Items();
|
||||
if (packs.isEmpty()) {
|
||||
return items.muted("none").fact("Packs");
|
||||
}
|
||||
packs.stream().limit(PACKS_SHOWN).forEach(pack -> addPack(items, pack));
|
||||
int hidden = packs.size() - PACKS_SHOWN;
|
||||
if (hidden > 0) {
|
||||
items.muted("+" + hidden + " more");
|
||||
}
|
||||
return items.fact("Packs");
|
||||
}
|
||||
|
||||
private static void addPack(DiagnosticFact.Items items, PackState pack) {
|
||||
switch (pack.outcome()) {
|
||||
case FAILED -> items.warning(pack.name() + " failed");
|
||||
case WAITING -> items.muted(pack.name() + " waiting");
|
||||
case LOADABLE -> {
|
||||
if (pack.warnings() == 0) {
|
||||
items.plain(pack.name() + " ok");
|
||||
return;
|
||||
}
|
||||
items.warning(pack.name() + " " + pack.warnings() + (pack.warnings() == 1 ? " warning" : " warnings"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static List<PackState> packStates(Map<String, PackValidationResult> resultsByPack,
|
||||
Predicate<PackValidationResult> awaitingExternalContent) {
|
||||
List<PackState> states = new ArrayList<>(resultsByPack.size());
|
||||
new TreeMap<>(resultsByPack).forEach((pack, result) -> states.add(new PackState(pack,
|
||||
packOutcome(result, awaitingExternalContent), result.getWarnings().size())));
|
||||
return states;
|
||||
}
|
||||
|
||||
private static PackOutcome packOutcome(PackValidationResult result, Predicate<PackValidationResult> awaitingExternalContent) {
|
||||
if (result.isLoadable()) {
|
||||
return PackOutcome.LOADABLE;
|
||||
}
|
||||
return awaitingExternalContent.test(result) ? PackOutcome.WAITING : PackOutcome.FAILED;
|
||||
}
|
||||
|
||||
private static Optional<Jar> currentJar() {
|
||||
Optional<Path> runningJar = runningJar();
|
||||
if (runningJar.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
Path jar = runningJar.get();
|
||||
return Optional.of(new Jar(serverRelative(jar), modificationAge(jar), otherIrisJars(jar)));
|
||||
}
|
||||
|
||||
private static Optional<Path> runningJar() {
|
||||
try {
|
||||
CodeSource source = BuildFacts.class.getProtectionDomain().getCodeSource();
|
||||
if (source == null || source.getLocation() == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
Path jar = Path.of(source.getLocation().toURI()).toAbsolutePath().normalize();
|
||||
return Files.isRegularFile(jar) ? Optional.of(jar) : Optional.empty();
|
||||
} catch (URISyntaxException unresolvable) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
/** The server runs from its root folder, so the working directory is what paths are relative to. */
|
||||
private static String serverRelative(Path jar) {
|
||||
Path serverRoot = Path.of("").toAbsolutePath().normalize();
|
||||
Path shown = jar.startsWith(serverRoot) ? serverRoot.relativize(jar) : jar;
|
||||
return shown.toString().replace('\\', '/');
|
||||
}
|
||||
|
||||
/** A plain copy resets the modification time, so this is when the jar was deployed rather than built. */
|
||||
private static Optional<Duration> modificationAge(Path jar) {
|
||||
try {
|
||||
Instant modified = Files.getLastModifiedTime(jar).toInstant();
|
||||
return Optional.of(Duration.between(modified, Instant.now()));
|
||||
} catch (IOException unreadable) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> otherIrisJars(Path jar) {
|
||||
Path folder = jar.getParent();
|
||||
if (folder == null) {
|
||||
return List.of();
|
||||
}
|
||||
try (Stream<Path> files = Files.list(folder)) {
|
||||
return files.filter(file -> !file.equals(jar) && Files.isRegularFile(file))
|
||||
.map(file -> file.getFileName().toString())
|
||||
.filter(name -> IRIS_JAR_NAME.matcher(name).matches())
|
||||
.sorted()
|
||||
.toList();
|
||||
} catch (IOException unreadable) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
private static Optional<Properties> volmLibStamp() {
|
||||
try (InputStream input = BuildFacts.class.getClassLoader().getResourceAsStream(VOLMLIB_STAMP)) {
|
||||
if (input == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
Properties stamp = new Properties();
|
||||
stamp.load(input);
|
||||
return Optional.of(stamp);
|
||||
} catch (IOException unreadable) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
private static Natives currentNatives() {
|
||||
return new Natives(FractalBillowSimplexNoise.nativeBackendStatus(), currentTerrainProvider(), SimdSupport.shortStatus());
|
||||
}
|
||||
|
||||
private static TerrainProvider currentTerrainProvider() {
|
||||
if (!INMS.isBound()) {
|
||||
return TerrainProvider.UNBOUND;
|
||||
}
|
||||
return INMS.get() instanceof NMSBinding1X ? TerrainProvider.DISABLED : TerrainProvider.NATIVE;
|
||||
}
|
||||
|
||||
private static Map<String, String> currentSettingChanges() {
|
||||
Gson gson = new Gson();
|
||||
return settingChanges(gson.toJsonTree(IrisSettings.get()), gson.toJsonTree(new IrisSettings()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package art.arcane.iris.diagnostics;
|
||||
|
||||
import art.arcane.iris.BuildConstants;
|
||||
|
||||
/** Which source a jar was built from, as the splash and the build report name it. */
|
||||
public record BuildIdentity(BuildChannel channel, String commit, String environment, String branch, boolean dirty) {
|
||||
private static final int SHORT_COMMIT_LENGTH = 7;
|
||||
private static final String DIRTY_MARK = "+dirty";
|
||||
|
||||
public static BuildIdentity current() {
|
||||
return new BuildIdentity(BuildChannel.current(), BuildConstants.COMMIT, BuildConstants.ENVIRONMENT,
|
||||
BuildConstants.BRANCH, BuildConstants.DIRTY);
|
||||
}
|
||||
|
||||
/** "df31f1e/production" on a release; on a development build the environment gives way to the dirty mark. */
|
||||
public String commitLabel() {
|
||||
String shortCommit = commit.length() > SHORT_COMMIT_LENGTH ? commit.substring(0, SHORT_COMMIT_LENGTH) : commit;
|
||||
if (!channel.isDevelopment()) {
|
||||
return shortCommit + "/" + environment;
|
||||
}
|
||||
return dirty ? shortCommit + DIRTY_MARK : shortCommit;
|
||||
}
|
||||
|
||||
public boolean hasBranch() {
|
||||
return branch != null && !branch.isBlank();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package art.arcane.iris.diagnostics;
|
||||
|
||||
import art.arcane.iris.localization.ChatReport.ValuePart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/** One labelled line of a diagnostics section, such as "Jar" or "Memory". */
|
||||
public record DiagnosticFact(String label, List<ValuePart> value) {
|
||||
public DiagnosticFact {
|
||||
value = List.copyOf(value);
|
||||
}
|
||||
|
||||
public String plainValue() {
|
||||
return value.stream().map(ValuePart::text).collect(Collectors.joining());
|
||||
}
|
||||
|
||||
/** A fact's value as a comma separated list; the separators stay muted so the items carry the color. */
|
||||
static final class Items {
|
||||
private static final String SEPARATOR = ", ";
|
||||
|
||||
private final List<ValuePart> parts = new ArrayList<>();
|
||||
|
||||
Items plain(String text) {
|
||||
return add(ValuePart.plain(text));
|
||||
}
|
||||
|
||||
Items muted(String text) {
|
||||
return add(ValuePart.muted(text));
|
||||
}
|
||||
|
||||
Items warning(String text) {
|
||||
return add(ValuePart.warning(text));
|
||||
}
|
||||
|
||||
Items flagged(String text, boolean needsLook) {
|
||||
return needsLook ? warning(text) : plain(text);
|
||||
}
|
||||
|
||||
Optional<DiagnosticFact> fact(String label) {
|
||||
return parts.isEmpty() ? Optional.empty() : Optional.of(new DiagnosticFact(label, parts));
|
||||
}
|
||||
|
||||
private Items add(ValuePart part) {
|
||||
if (!parts.isEmpty()) {
|
||||
parts.add(ValuePart.muted(SEPARATOR));
|
||||
}
|
||||
parts.add(part);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package art.arcane.iris.diagnostics;
|
||||
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/** A titled block of facts, printed as a console or chat report or written as plain text into the debug dump. */
|
||||
public record DiagnosticSection(String title, List<DiagnosticFact> facts) {
|
||||
private static final String PLAIN_INDENT = " ";
|
||||
|
||||
public DiagnosticSection {
|
||||
facts = List.copyOf(facts);
|
||||
}
|
||||
|
||||
/** Gathers each fact on its own, so a fact that cannot be determined is left out instead of failing the section. */
|
||||
static DiagnosticSection gather(String title, List<Supplier<Optional<DiagnosticFact>>> gatherers) {
|
||||
List<DiagnosticFact> facts = new ArrayList<>(gatherers.size());
|
||||
for (Supplier<Optional<DiagnosticFact>> gatherer : gatherers) {
|
||||
try {
|
||||
gatherer.get().ifPresent(facts::add);
|
||||
} catch (RuntimeException | LinkageError undeterminable) {
|
||||
IrisLogging.debug("Diagnostics left out a fact of '" + title + "': " + undeterminable);
|
||||
}
|
||||
}
|
||||
return new DiagnosticSection(title, facts);
|
||||
}
|
||||
|
||||
public ChatReport report() {
|
||||
ChatReport.Builder report = ChatReport.of(ChatReport.Tone.DIAGNOSTIC, title).unlimited();
|
||||
facts.forEach(fact -> report.entry(fact.label(), fact.value()));
|
||||
return report.build();
|
||||
}
|
||||
|
||||
public String plainText() {
|
||||
StringBuilder text = new StringBuilder(title);
|
||||
for (DiagnosticFact fact : facts) {
|
||||
text.append('\n').append(PLAIN_INDENT).append(fact.label()).append(": ").append(fact.plainValue());
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package art.arcane.iris.diagnostics;
|
||||
|
||||
import art.arcane.iris.pack.PackValidationResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/** The build and system blocks, gathered fresh for each reader: the startup print, the command and the debug dump. */
|
||||
public final class DiagnosticsReport {
|
||||
private DiagnosticsReport() {
|
||||
}
|
||||
|
||||
public static List<DiagnosticSection> sections(Predicate<PackValidationResult> awaitingExternalContent) {
|
||||
return List.of(BuildFacts.current(awaitingExternalContent), SystemFacts.current());
|
||||
}
|
||||
|
||||
public static String plainText(Predicate<PackValidationResult> awaitingExternalContent) {
|
||||
return sections(awaitingExternalContent).stream()
|
||||
.map(DiagnosticSection::plainText)
|
||||
.collect(Collectors.joining("\n"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package art.arcane.iris.diagnostics;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
/** The compact units diagnostics print: ages like "36s" or "3d", sizes like "6G" or "512M". */
|
||||
final class FactFormat {
|
||||
private static final long SECONDS_PER_MINUTE = 60;
|
||||
private static final long SECONDS_PER_HOUR = 60 * SECONDS_PER_MINUTE;
|
||||
private static final long SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR;
|
||||
private static final double BYTES_PER_GIB = 1L << 30;
|
||||
private static final double BYTES_PER_MIB = 1L << 20;
|
||||
|
||||
private FactFormat() {
|
||||
}
|
||||
|
||||
static String age(Duration age) {
|
||||
long seconds = Math.max(0, age.toSeconds());
|
||||
if (seconds < SECONDS_PER_MINUTE) {
|
||||
return seconds + "s";
|
||||
}
|
||||
if (seconds < SECONDS_PER_HOUR) {
|
||||
return seconds / SECONDS_PER_MINUTE + "m";
|
||||
}
|
||||
if (seconds < SECONDS_PER_DAY) {
|
||||
return seconds / SECONDS_PER_HOUR + "h";
|
||||
}
|
||||
return seconds / SECONDS_PER_DAY + "d";
|
||||
}
|
||||
|
||||
static String size(long bytes) {
|
||||
if (bytes >= BYTES_PER_GIB) {
|
||||
return Math.round(bytes / BYTES_PER_GIB) + "G";
|
||||
}
|
||||
return Math.round(Math.max(0, bytes) / BYTES_PER_MIB) + "M";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package art.arcane.iris.diagnostics;
|
||||
|
||||
import art.arcane.iris.generation.concurrent.MultiBurst;
|
||||
import art.arcane.iris.platform.agent.Agent;
|
||||
import art.arcane.iris.world.IrisWorldStorage;
|
||||
import art.arcane.iris.world.pregen.AsyncPregenMethod;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.management.GarbageCollectorMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.OperatingSystemMXBean;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.OptionalLong;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** The system block: what the host gives this JVM and what Iris made of it. */
|
||||
public final class SystemFacts {
|
||||
private static final String TITLE = "System";
|
||||
private static final Path CPU_INFO = Path.of("/proc/cpuinfo");
|
||||
private static final Path MEMORY_INFO = Path.of("/proc/meminfo");
|
||||
private static final List<Path> CONTAINER_MARKERS = List.of(
|
||||
Path.of("/.dockerenv"), Path.of("/run/.containerenv"), Path.of("/run/systemd/container"));
|
||||
private static final String CPU_THREAD_ENTRY = "processor";
|
||||
private static final String CPU_MODEL_ENTRY = "model name";
|
||||
private static final String AVAILABLE_MEMORY_ENTRY = "MemAvailable:";
|
||||
private static final long BYTES_PER_KIB = 1024;
|
||||
private static final String PRE_TOUCH_FLAG = "-XX:+AlwaysPreTouch";
|
||||
private static final Pattern MAJOR_MINOR_VERSION = Pattern.compile("^(\\d+\\.\\d+)");
|
||||
private static final List<Pattern> CPU_MODEL_NOISE = List.of(
|
||||
Pattern.compile("\\((?:R|TM|tm)\\)"),
|
||||
Pattern.compile("\\s*@.*$"),
|
||||
Pattern.compile("\\s+\\d+-Core Processor$"),
|
||||
Pattern.compile("\\s+(?:CPU|Processor)\\b"),
|
||||
Pattern.compile("^(?:AMD|Intel)\\s+"));
|
||||
|
||||
private SystemFacts() {
|
||||
}
|
||||
|
||||
record Cpu(int availableThreads, OptionalInt hostThreads, Optional<String> model) {
|
||||
}
|
||||
|
||||
record Pools(int generation, int io, int pregen) {
|
||||
}
|
||||
|
||||
record Memory(long maxHeapBytes, OptionalLong hostBytes, OptionalLong hostAvailableBytes) {
|
||||
}
|
||||
|
||||
record Jvm(int feature, Optional<String> collector, boolean preTouch, boolean agentAttached) {
|
||||
}
|
||||
|
||||
record Os(String name, String version, String architecture, boolean container) {
|
||||
}
|
||||
|
||||
public static DiagnosticSection current() {
|
||||
return DiagnosticSection.gather(TITLE, List.of(
|
||||
() -> cpu(currentCpu()),
|
||||
() -> pools(currentPools()),
|
||||
() -> memory(currentMemory()),
|
||||
() -> jvm(currentJvm()),
|
||||
() -> os(currentOs()),
|
||||
() -> disk(IrisWorldStorage.levelRoot().getFreeSpace())));
|
||||
}
|
||||
|
||||
static Optional<DiagnosticFact> cpu(Cpu cpu) {
|
||||
DiagnosticFact.Items items = new DiagnosticFact.Items();
|
||||
if (cpu.hostThreads().isEmpty()) {
|
||||
items.plain(cpu.availableThreads() + " threads available");
|
||||
cpu.model().ifPresent(items::muted);
|
||||
return items.fact("CPU");
|
||||
}
|
||||
int hostThreads = cpu.hostThreads().getAsInt();
|
||||
boolean limited = cpu.availableThreads() < hostThreads;
|
||||
items.flagged(cpu.availableThreads() + " of " + hostThreads + " threads available", limited);
|
||||
cpu.model().ifPresent(items::muted);
|
||||
if (limited) {
|
||||
items.warning("limited");
|
||||
} else {
|
||||
items.muted("no limit");
|
||||
}
|
||||
return items.fact("CPU");
|
||||
}
|
||||
|
||||
static Optional<DiagnosticFact> pools(Pools pools) {
|
||||
DiagnosticFact.Items items = new DiagnosticFact.Items();
|
||||
addPool(items, "generation", pools.generation());
|
||||
addPool(items, "io", pools.io());
|
||||
addPool(items, "pregen", pools.pregen());
|
||||
return items.fact("Iris pools");
|
||||
}
|
||||
|
||||
private static void addPool(DiagnosticFact.Items items, String pool, int workers) {
|
||||
if (workers > 0) {
|
||||
items.plain(pool + " " + workers);
|
||||
}
|
||||
}
|
||||
|
||||
static Optional<DiagnosticFact> memory(Memory memory) {
|
||||
String heap = "heap " + FactFormat.size(memory.maxHeapBytes());
|
||||
DiagnosticFact.Items items = new DiagnosticFact.Items();
|
||||
memory.hostBytes().ifPresentOrElse(
|
||||
host -> items.plain(heap + " of " + FactFormat.size(host) + " host"),
|
||||
() -> items.plain(heap));
|
||||
memory.hostAvailableBytes().ifPresent(available -> items.muted(FactFormat.size(available) + " available"));
|
||||
return items.fact("Memory");
|
||||
}
|
||||
|
||||
static Optional<DiagnosticFact> jvm(Jvm jvm) {
|
||||
DiagnosticFact.Items items = new DiagnosticFact.Items().plain("Java " + jvm.feature());
|
||||
jvm.collector().ifPresent(items::plain);
|
||||
if (jvm.preTouch()) {
|
||||
items.muted("pretouch");
|
||||
}
|
||||
items.muted(jvm.agentAttached() ? "agent attached" : "no agent");
|
||||
return items.fact("JVM");
|
||||
}
|
||||
|
||||
static Optional<DiagnosticFact> os(Os os) {
|
||||
Matcher majorMinor = MAJOR_MINOR_VERSION.matcher(os.version());
|
||||
String version = majorMinor.find() ? majorMinor.group(1) : os.version();
|
||||
DiagnosticFact.Items items = new DiagnosticFact.Items()
|
||||
.plain(os.name() + " " + version)
|
||||
.muted(os.architecture());
|
||||
if (os.container()) {
|
||||
items.muted("container");
|
||||
}
|
||||
return items.fact("OS");
|
||||
}
|
||||
|
||||
static Optional<DiagnosticFact> disk(long worldFreeBytes) {
|
||||
return new DiagnosticFact.Items().plain("world folder " + FactFormat.size(worldFreeBytes) + " free").fact("Disk");
|
||||
}
|
||||
|
||||
/** Drops trademarks, vendor, clock and core count, so "AMD Ryzen 9 7950X 16-Core Processor" reads "Ryzen 9 7950X". */
|
||||
static String compactCpuModel(String model) {
|
||||
String compact = model.strip();
|
||||
for (Pattern noise : CPU_MODEL_NOISE) {
|
||||
compact = noise.matcher(compact).replaceAll("");
|
||||
}
|
||||
return compact.replaceAll("\\s+", " ").strip();
|
||||
}
|
||||
|
||||
private static Cpu currentCpu() {
|
||||
int availableThreads = Runtime.getRuntime().availableProcessors();
|
||||
List<String> cpuInfo = readLines(CPU_INFO);
|
||||
long hostThreads = cpuInfo.stream().filter(line -> line.startsWith(CPU_THREAD_ENTRY)).count();
|
||||
Optional<String> model = cpuInfo.stream()
|
||||
.filter(line -> line.startsWith(CPU_MODEL_ENTRY))
|
||||
.findFirst()
|
||||
.map(line -> compactCpuModel(line.substring(line.indexOf(':') + 1)));
|
||||
return new Cpu(availableThreads, hostThreads > 0 ? OptionalInt.of((int) hostThreads) : OptionalInt.empty(), model);
|
||||
}
|
||||
|
||||
private static Pools currentPools() {
|
||||
return new Pools(MultiBurst.burst.parallelism(), MultiBurst.ioBurst.parallelism(),
|
||||
AsyncPregenMethod.plannedWorkerThreads());
|
||||
}
|
||||
|
||||
private static Memory currentMemory() {
|
||||
long maxHeap = Runtime.getRuntime().maxMemory();
|
||||
OperatingSystemMXBean system = ManagementFactory.getOperatingSystemMXBean();
|
||||
if (!(system instanceof com.sun.management.OperatingSystemMXBean host)) {
|
||||
return new Memory(maxHeap, OptionalLong.empty(), OptionalLong.empty());
|
||||
}
|
||||
OptionalLong available = availableMemory();
|
||||
return new Memory(maxHeap, OptionalLong.of(host.getTotalMemorySize()),
|
||||
available.isPresent() ? available : OptionalLong.of(host.getFreeMemorySize()));
|
||||
}
|
||||
|
||||
/** Linux counts page cache as used in its free figure, so the reclaimable estimate says more about headroom. */
|
||||
private static OptionalLong availableMemory() {
|
||||
return readLines(MEMORY_INFO).stream()
|
||||
.filter(line -> line.startsWith(AVAILABLE_MEMORY_ENTRY))
|
||||
.findFirst()
|
||||
.map(line -> line.substring(AVAILABLE_MEMORY_ENTRY.length()).replace("kB", "").strip())
|
||||
.map(kibibytes -> OptionalLong.of(Long.parseLong(kibibytes) * BYTES_PER_KIB))
|
||||
.orElse(OptionalLong.empty());
|
||||
}
|
||||
|
||||
private static Jvm currentJvm() {
|
||||
Optional<String> collector = ManagementFactory.getGarbageCollectorMXBeans().stream()
|
||||
.findFirst()
|
||||
.map(GarbageCollectorMXBean::getName)
|
||||
.map(SystemFacts::collectorName);
|
||||
boolean preTouch = ManagementFactory.getRuntimeMXBean().getInputArguments().contains(PRE_TOUCH_FLAG);
|
||||
return new Jvm(Runtime.version().feature(), collector, preTouch, Agent.isInstalled());
|
||||
}
|
||||
|
||||
/** Collector beans are named per generation, like "G1 Young Generation" or "PS Scavenge". */
|
||||
static String collectorName(String beanName) {
|
||||
String family = beanName.split(" ", 2)[0];
|
||||
return switch (family) {
|
||||
case "PS" -> "Parallel";
|
||||
case "Copy", "MarkSweepCompact" -> "Serial";
|
||||
default -> family;
|
||||
};
|
||||
}
|
||||
|
||||
private static Os currentOs() {
|
||||
boolean container = CONTAINER_MARKERS.stream().anyMatch(Files::exists);
|
||||
return new Os(System.getProperty("os.name", "unknown"), System.getProperty("os.version", ""),
|
||||
System.getProperty("os.arch", "unknown"), container);
|
||||
}
|
||||
|
||||
private static List<String> readLines(Path file) {
|
||||
if (!Files.isReadable(file)) {
|
||||
return List.of();
|
||||
}
|
||||
try {
|
||||
return Files.readAllLines(file);
|
||||
} catch (IOException unreadable) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,108 @@
|
||||
package art.arcane.iris.diagnostics.splash;
|
||||
|
||||
import art.arcane.iris.BuildConstants;
|
||||
import art.arcane.iris.diagnostics.BuildIdentity;
|
||||
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 LABEL_WIDTH = 14;
|
||||
private static final String FACT_GAP = " ";
|
||||
private static final String DEVELOPMENT_TAG_SUFFIX = " DEV";
|
||||
private static final String DEVELOPMENT_VERSION_SUFFIX = " (dev)";
|
||||
|
||||
private IrisSplashComposer() {
|
||||
}
|
||||
|
||||
public static String[] composeInfo(String version, String serverLine, InfoStyle style) {
|
||||
String releaseTrain = releaseTrain(version);
|
||||
return composeInfo(version, serverLine, style, List.of());
|
||||
}
|
||||
|
||||
public static String[] composeInfo(String version, String serverLine, InfoStyle style, List<List<Detail>> detailRows) {
|
||||
return composeInfo(version, serverLine, style, BuildIdentity.current(), detailRows);
|
||||
}
|
||||
|
||||
public static String[] composeInfo(String version, String serverLine, InfoStyle style, BuildIdentity build,
|
||||
List<List<Detail>> detailRows) {
|
||||
String[] info = composeHeader(version, serverLine, style, build);
|
||||
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[] composeHeader(String version, String serverLine, InfoStyle style, BuildIdentity build) {
|
||||
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("[" + titleTag(version, build) + "]"),
|
||||
prefix + styledRow(List.of(Detail.headline("Version", versionLabel(version, build))), 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", build.commitLabel())), style),
|
||||
"",
|
||||
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),
|
||||
"",
|
||||
"",
|
||||
""
|
||||
};
|
||||
}
|
||||
|
||||
private static String titleTag(String version, BuildIdentity build) {
|
||||
String releaseTrain = releaseTrain(version);
|
||||
return build.channel().isDevelopment() ? releaseTrain + DEVELOPMENT_TAG_SUFFIX : releaseTrain;
|
||||
}
|
||||
|
||||
private static String versionLabel(String version, BuildIdentity build) {
|
||||
return build.channel().isDevelopment() ? version + DEVELOPMENT_VERSION_SUFFIX : version;
|
||||
}
|
||||
|
||||
public static String compose(String[] splash, String[] info) {
|
||||
StringBuilder builder = new StringBuilder("\n\n");
|
||||
for (int i = 0; i < splash.length; i++) {
|
||||
@@ -43,29 +111,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 +167,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 +205,9 @@ public final class IrisSplashComposer {
|
||||
default String value(String text) {
|
||||
return text;
|
||||
}
|
||||
|
||||
default String headlineValue(String text) {
|
||||
return value(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,37 +18,27 @@
|
||||
|
||||
package art.arcane.iris.generation.biome;
|
||||
|
||||
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.SeedTable;
|
||||
import art.arcane.volmlib.util.noise.CNG;
|
||||
|
||||
/**
|
||||
* What one engine derives from an {@link IrisBiomePaletteLayer}: the block selection and depth generators of the
|
||||
* seeds that sample it. A column walk asks for one layer seed per depth, so the layer table holds the layer's whole
|
||||
* thickness for a few parent seeds instead of rebuilding a generator on every depth step.
|
||||
* seeds that sample it.
|
||||
*/
|
||||
public final class PaletteLayerRuntime {
|
||||
private static final int LAYER_SEED_CAPACITY = 32;
|
||||
private static final int LAYER_RECENT_SLOTS = 32;
|
||||
private static final int MAX_LAYER_RECENT_SLOTS = 4096;
|
||||
private static final int PARENT_SEEDS_PER_LAYER = 4;
|
||||
private static final int HEIGHT_SEED_CAPACITY = 32;
|
||||
|
||||
private final PackRuntime runtime;
|
||||
private final SeedTable<CNG> layerGenerators;
|
||||
private final SeedTable<CNG> heightGenerators;
|
||||
private final boolean shareGenerator;
|
||||
|
||||
public PaletteLayerRuntime(IrisBiomePaletteLayer layer, PackRuntime runtime) {
|
||||
this.runtime = runtime;
|
||||
IrisGeneratorStyle style = layer.getStyle();
|
||||
// A seeded style rolls from its own seed and the world seed, never the caller's, so every depth builds the same noise.
|
||||
this.shareGenerator = style != null
|
||||
&& (style.isSeeded() || style.canShareExpressionGenerator(runtime.data()));
|
||||
int depthSeeds = Math.max(1, Math.max(layer.getMinHeight(), layer.getMaxHeight()));
|
||||
this.layerGenerators = new SeedTable<>(Math.max(LAYER_SEED_CAPACITY, depthSeeds * PARENT_SEEDS_PER_LAYER),
|
||||
recentSlots(depthSeeds), seed -> layer.createLayerGenerator(seed, runtime));
|
||||
this.layerGenerators = new SeedTable<>(LAYER_SEED_CAPACITY, LAYER_RECENT_SLOTS,
|
||||
seed -> layer.createLayerGenerator(seed, runtime));
|
||||
this.heightGenerators = new SeedTable<>(HEIGHT_SEED_CAPACITY, IrisBiomePaletteLayer::createHeightGenerator);
|
||||
}
|
||||
|
||||
@@ -58,16 +48,10 @@ public final class PaletteLayerRuntime {
|
||||
}
|
||||
|
||||
public CNG layerGenerator(long seed) {
|
||||
return layerGenerators.get(shareGenerator ? 0L : seed);
|
||||
return layerGenerators.get(seed);
|
||||
}
|
||||
|
||||
public CNG heightGenerator(long seed) {
|
||||
return heightGenerators.get(seed);
|
||||
}
|
||||
|
||||
/** Consecutive depth seeds land in distinct slots when the slot count covers the thickness. */
|
||||
private static int recentSlots(int depthSeeds) {
|
||||
int covering = Integer.highestOneBit(Math.min(depthSeeds, MAX_LAYER_RECENT_SLOTS) - 1) << 1;
|
||||
return Math.clamp(covering, LAYER_RECENT_SLOTS, MAX_LAYER_RECENT_SLOTS);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ package art.arcane.iris.generation.noise;
|
||||
import art.arcane.iris.generation.image.IrisImageMap;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.pack.loading.ResourceLoader;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.world.history.GenerationKernelRegistry;
|
||||
@@ -43,9 +42,7 @@ import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Snippet("style")
|
||||
@@ -102,46 +99,6 @@ public class IrisGeneratorStyle {
|
||||
return createNoCache(rng, runtime, 1, 0, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this style can share an expression generator across caller seeds within a pack runtime.
|
||||
*/
|
||||
public boolean canShareExpressionGenerator(IrisData data) {
|
||||
return expression != null && canShareExpressionGenerator(data, new HashSet<>());
|
||||
}
|
||||
|
||||
private boolean canShareExpressionGenerator(IrisData data, Set<String> activeExpressions) {
|
||||
if (getClass() != IrisGeneratorStyle.class || expression == null || data == null
|
||||
|| fracture != null || cellularFrequency != 0D || cacheSize != 0
|
||||
|| !activeExpressions.add(expression)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
ResourceLoader<IrisExpression> loader = data.getExpressionLoader();
|
||||
IrisExpression source = loader == null ? null : loader.load(expression);
|
||||
if (source == null || source.getClass() != IrisExpression.class
|
||||
|| source.getVariables() == null || source.getFunctions() == null) {
|
||||
return false;
|
||||
}
|
||||
for (IrisExpressionLoad variable : source.getVariables()) {
|
||||
if (variable.getEngineValue() != null || variable.getEngineStreamValue() != null
|
||||
|| (variable.getStyleValue() != null
|
||||
&& !variable.getStyleValue().canShareExpressionGenerator(data, activeExpressions))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (IrisExpressionFunction function : source.getFunctions()) {
|
||||
if (function.getEngineStreamValue() != null || function.getStyleValue() == null
|
||||
|| !function.getStyleValue().canShareExpressionGenerator(data, activeExpressions)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} finally {
|
||||
activeExpressions.remove(expression);
|
||||
}
|
||||
}
|
||||
|
||||
public CNG createScaledGenerator(RNG rng, PackRuntime runtime, double scaleFactor) {
|
||||
return createNoCache(rng, runtime).bake().scale(scaleFactor).bake();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -300,6 +300,14 @@ public class IrisPostModifier extends EngineAssignedModifier<NativeBlockState> {
|
||||
setPostBlock(x, h + 1, z, result, originX, originZ, currentData);
|
||||
}
|
||||
}
|
||||
|
||||
if (B.isFoliage(b) || IrisProceduralBlocks.materialKey(b).equals("minecraft:dead_bush")) {
|
||||
NativeBlockState onto = getPostBlock(x, h, z, originX, originZ, currentData);
|
||||
|
||||
if (!B.canPlaceOnto(b, onto) && !B.isDecorant(b)) {
|
||||
setPostBlock(x, h + 1, z, AIR.get(), originX, originZ, currentData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAir(int x, int y, int z, int originX, int originZ, Hunk<NativeBlockState> currentData) {
|
||||
|
||||
@@ -8,7 +8,6 @@ import art.arcane.iris.integration.ExternalDataSVC;
|
||||
import art.arcane.iris.generation.cache.Cache;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.platform.bukkit.BukkitBlockResolution;
|
||||
import art.arcane.iris.platform.bukkit.nms.INMS;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.IrisServices;
|
||||
import art.arcane.iris.generation.block.IrisCustomData;
|
||||
@@ -84,7 +83,6 @@ public class CraftEngineDataProvider extends ExternalDataProvider implements Lis
|
||||
|
||||
@EventHandler
|
||||
public void onReload(CraftEngineReloadEvent event) {
|
||||
forgetServerBlockRules();
|
||||
if (!updateContent()) {
|
||||
return;
|
||||
}
|
||||
@@ -94,13 +92,6 @@ public class CraftEngineDataProvider extends ExternalDataProvider implements Lis
|
||||
}
|
||||
}
|
||||
|
||||
// Custom blocks carry their own placement rules, so answers about them can change with a reload.
|
||||
private static void forgetServerBlockRules() {
|
||||
if (INMS.isBound()) {
|
||||
INMS.get().forgetBlockRules();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<BlockProperty> getBlockProperties(@NotNull Identifier blockId) throws MissingResourceException {
|
||||
ImmutableBlockState blockState = findBlockState(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,433 @@
|
||||
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),
|
||||
/** Build and system facts wear the purple of the development splash fins. */
|
||||
DIAGNOSTIC(C.LIGHT_PURPLE, C.LIGHT_PURPLE, ConsoleGlyphs.DIAMOND);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/** How much a part of an entry's value asks to be read: the fact itself, an aside, or something to look at. */
|
||||
public enum Emphasis {
|
||||
PLAIN,
|
||||
MUTED,
|
||||
WARNING
|
||||
}
|
||||
|
||||
public record ValuePart(String text, Emphasis emphasis) {
|
||||
public static ValuePart plain(String text) {
|
||||
return new ValuePart(text, Emphasis.PLAIN);
|
||||
}
|
||||
|
||||
public static ValuePart muted(String text) {
|
||||
return new ValuePart(text, Emphasis.MUTED);
|
||||
}
|
||||
|
||||
public static ValuePart warning(String text) {
|
||||
return new ValuePart(text, Emphasis.WARNING);
|
||||
}
|
||||
|
||||
/** Plain parts keep the value color of their layout: Iris in chat, white on the console. */
|
||||
private String styled(C plainColor) {
|
||||
C color = switch (emphasis) {
|
||||
case PLAIN -> plainColor;
|
||||
case MUTED -> C.GRAY;
|
||||
case WARNING -> Tone.WARNING.consoleColor();
|
||||
};
|
||||
return color + cleanInline(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 consoleValue) {
|
||||
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), C.WHITE + clean(value));
|
||||
}
|
||||
|
||||
static Entry labelled(String label, List<ValuePart> value) {
|
||||
String chatLine = C.GRAY + clean(label) + C.DARK_GRAY + ": " + styledParts(value, C.IRIS);
|
||||
return new Entry(List.of(chatLine), clean(label), styledParts(value, C.WHITE));
|
||||
}
|
||||
|
||||
private static String styledParts(List<ValuePart> value, C plainColor) {
|
||||
StringBuilder styled = new StringBuilder();
|
||||
value.forEach(part -> styled.append(part.styled(plainColor)));
|
||||
return styled.toString();
|
||||
}
|
||||
|
||||
/** 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 + consoleValue);
|
||||
}
|
||||
return List.of(C.GRAY + label, " ".repeat(CONSOLE_LABEL_WIDTH) + consoleValue);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
return cleanInline(text).strip();
|
||||
}
|
||||
|
||||
/** Like {@link #clean(String)}, but keeps the surrounding spaces a value part needs to join its neighbours. */
|
||||
private static String cleanInline(String text) {
|
||||
if (text == null) {
|
||||
return "";
|
||||
}
|
||||
return LEGACY_COLOR.matcher(text).replaceAll("")
|
||||
.replace("<", "‹")
|
||||
.replace(">", "›");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/** A labelled entry whose value parts each keep their own emphasis. */
|
||||
public Builder entry(String label, List<ValuePart> value) {
|
||||
entries.add(Entry.labelled(label, List.copyOf(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,86 @@
|
||||
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 DIAMOND = "\u25c6";
|
||||
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(DIAMOND, "*");
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ public final class DirectorCommandMessages {
|
||||
public static final TextKey DEBUG_DESCRIPTION = TextKey.of("iris.director.commanddebug.description", "Iris diagnostic tools");
|
||||
public static final TextKey DEBUG_DUMP_DESCRIPTION = TextKey.of("iris.director.commandiris.director.debugdump", "Create and optionally upload a diagnostic report");
|
||||
public static final TextKey DEBUG_DUMP_UPLOAD = TextKey.of("iris.director.commandiris.param.debugdump_upload", "Upload the report to mclo.gs");
|
||||
public static final TextKey DEBUG_INFO_DESCRIPTION = TextKey.of("iris.director.commanddebug.director.info", "Print build and system facts");
|
||||
public static final TextKey COMMAND_DATAPACK_DIRECTOR_DOWNLOAD_MANAGE_EXTERNAL_DATAPACK_IMPORTS_MODRINTH = TextKey.of(
|
||||
"iris.director.commanddatapack.director.download_manage_external_datapack_imports_modrinth",
|
||||
"Download & manage external datapack imports"
|
||||
@@ -213,6 +214,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"
|
||||
@@ -942,6 +951,7 @@ public final class DirectorCommandMessages {
|
||||
DEBUG_DESCRIPTION,
|
||||
DEBUG_DUMP_DESCRIPTION,
|
||||
DEBUG_DUMP_UPLOAD,
|
||||
DEBUG_INFO_DESCRIPTION,
|
||||
COMMAND_DATAPACK_DIRECTOR_DOWNLOAD_MANAGE_EXTERNAL_DATAPACK_IMPORTS_MODRINTH,
|
||||
COMMAND_DATAPACK_DIRECTOR_DOWNLOAD_UPDATE_EVERY_DATAPACK_LISTED_PACK_DIMENSION_S_DATAPACKIMPORTS_INSTALL_IT_INTO,
|
||||
COMMAND_DATAPACK_PARAM_RESTART_SERVER_WHEN_NEW_DATAPACKS_ARE_INSTALLED_REQUIRED_NEW_STRUCTURES_REGISTER_GENERATE,
|
||||
@@ -992,6 +1002,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,
|
||||
|
||||
@@ -122,6 +122,8 @@ public final class RuntimeUiMessages {
|
||||
public static final TextKey PREGEN_PAUSE_HOVER = TextKey.of("iris.runtime.pregen.button.pause.hover", "Toggle pregeneration pause state");
|
||||
public static final TextKey PREGEN_STOP_BUTTON = TextKey.of("iris.runtime.pregen.button.stop", "Stop");
|
||||
public static final TextKey PREGEN_STOP_HOVER = TextKey.of("iris.runtime.pregen.button.stop.hover", "Finish the current region and stop pregeneration");
|
||||
public static final TextKey REPORT_MORE = TextKey.of("iris.runtime.report.more", "+{count} more");
|
||||
public static final TextKey REPORT_CLICK_TO_INSERT = TextKey.of("iris.runtime.report.click_to_insert", "Click to insert {command}");
|
||||
|
||||
private static final List<MessageKey> KEYS = List.of(
|
||||
FINDING_REGIONS,
|
||||
@@ -239,7 +241,9 @@ public final class RuntimeUiMessages {
|
||||
PREGEN_PAUSE_BUTTON,
|
||||
PREGEN_PAUSE_HOVER,
|
||||
PREGEN_STOP_BUTTON,
|
||||
PREGEN_STOP_HOVER
|
||||
PREGEN_STOP_HOVER,
|
||||
REPORT_MORE,
|
||||
REPORT_CLICK_TO_INSERT
|
||||
);
|
||||
|
||||
private RuntimeUiMessages() {
|
||||
|
||||
@@ -46,6 +46,7 @@ import java.util.stream.Stream;
|
||||
|
||||
public final class ContentKeyValidator {
|
||||
private static final int MAX_SUGGESTION_SCANS = 4096;
|
||||
private static final int GROUPED_KEYS_SHOWN = 5;
|
||||
private static final int MAX_OBJECT_PALETTE_SCANS = 20_000;
|
||||
private static final String DEFAULT_NAMESPACE = "minecraft";
|
||||
private static final String STRICT_PROPERTY = "iris.strictContent";
|
||||
@@ -403,10 +404,67 @@ public final class ContentKeyValidator {
|
||||
* @param strict issues the caller may promote to blocking errors under {@link #strictContent()}
|
||||
* @param advisory issues that stay warnings whatever the mode - see {@link #collectContentKeyIssues(File)}
|
||||
*/
|
||||
record ContentKeyIssues(List<String> strict, List<String> advisory) {
|
||||
record ContentKeyIssues(List<ContentKeyError> strictKeys, List<String> propertyIssues, List<ContentKeyError> advisoryKeys) {
|
||||
static ContentKeyIssues none() {
|
||||
return new ContentKeyIssues(List.of(), List.of());
|
||||
return new ContentKeyIssues(List.of(), List.of(), List.of());
|
||||
}
|
||||
|
||||
List<String> strict(Set<String> alreadyReportedKeys) {
|
||||
List<String> messages = new ArrayList<>(groupedMessages(withoutKeys(strictKeys, alreadyReportedKeys)));
|
||||
messages.addAll(propertyIssues);
|
||||
return messages;
|
||||
}
|
||||
|
||||
List<String> advisory(Set<String> alreadyReportedKeys) {
|
||||
return groupedMessages(withoutKeys(advisoryKeys, alreadyReportedKeys));
|
||||
}
|
||||
|
||||
private static List<ContentKeyError> withoutKeys(List<ContentKeyError> errors, Set<String> excluded) {
|
||||
return errors.stream().filter(error -> !excluded.contains(error.key())).toList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* One message per registry and namespace instead of one per key, so a pack that references a missing plugin's
|
||||
* blocks reports a single line rather than one line per block.
|
||||
*/
|
||||
static List<String> groupedMessages(List<ContentKeyError> errors) {
|
||||
Map<String, List<ContentKeyError>> groups = new LinkedHashMap<>();
|
||||
for (ContentKeyError error : errors) {
|
||||
String group = error.registry().name() + '|' + (error.namespaceLoaded() ? "" : namespaceOf(error.key()));
|
||||
groups.computeIfAbsent(group, ignored -> new ArrayList<>()).add(error);
|
||||
}
|
||||
List<String> messages = new ArrayList<>(groups.size());
|
||||
for (List<ContentKeyError> group : groups.values()) {
|
||||
messages.add(group.size() == 1 ? group.getFirst().message() : groupMessage(group));
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
|
||||
private static String groupMessage(List<ContentKeyError> group) {
|
||||
ContentKeyError first = group.getFirst();
|
||||
String registry = first.registry().label();
|
||||
StringBuilder sb = new StringBuilder(96);
|
||||
sb.append(group.size()).append(" unknown ").append(registry).append(" keys");
|
||||
if (!first.namespaceLoaded()) {
|
||||
sb.append(" (namespace '").append(namespaceOf(first.key())).append("' is not loaded on this server)");
|
||||
}
|
||||
sb.append(": ");
|
||||
int shown = Math.min(GROUPED_KEYS_SHOWN, group.size());
|
||||
for (int index = 0; index < shown; index++) {
|
||||
if (index > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
ContentKeyError error = group.get(index);
|
||||
sb.append(error.key());
|
||||
if (error.suggestion() != null) {
|
||||
sb.append(" (did you mean '").append(error.suggestion()).append("'?)");
|
||||
}
|
||||
}
|
||||
if (group.size() > shown) {
|
||||
sb.append(" +").append(group.size() - shown).append(" more");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,8 +480,9 @@ public final class ContentKeyValidator {
|
||||
* library over keys the author cannot edit and the engine handles.
|
||||
*/
|
||||
static ContentKeyIssues collectContentKeyIssues(File packFolder) {
|
||||
List<String> strict = new ArrayList<>();
|
||||
List<String> advisory = new ArrayList<>();
|
||||
List<ContentKeyError> strict = new ArrayList<>();
|
||||
List<ContentKeyError> advisory = new ArrayList<>();
|
||||
List<String> propertyIssues = new ArrayList<>();
|
||||
try {
|
||||
if (!IrisPlatforms.isBound()) {
|
||||
return ContentKeyIssues.none();
|
||||
@@ -448,16 +507,16 @@ public final class ContentKeyValidator {
|
||||
registries, referenced.blocks(), referenced.items(), referenced.entities());
|
||||
for (ContentKeyValidator.ContentKeyError error : errors) {
|
||||
if (referenced.paletteOnlyBlocks().contains(error.key())) {
|
||||
advisory.add(error.message());
|
||||
advisory.add(error);
|
||||
} else {
|
||||
strict.add(error.message());
|
||||
strict.add(error);
|
||||
}
|
||||
}
|
||||
strict.addAll(validateBlockStateProperties(registries, referenced.blockStates()));
|
||||
propertyIssues.addAll(validateBlockStateProperties(registries, referenced.blockStates()));
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError("PackValidator content-key validation failed for pack '" + packFolder.getName() + "'", e);
|
||||
}
|
||||
return new ContentKeyIssues(List.copyOf(strict), List.copyOf(advisory));
|
||||
return new ContentKeyIssues(List.copyOf(strict), List.copyOf(propertyIssues), List.copyOf(advisory));
|
||||
}
|
||||
|
||||
private static int size(List<String> keys) {
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,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";
|
||||
@@ -170,8 +171,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()
|
||||
@@ -180,6 +179,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);
|
||||
}
|
||||
@@ -362,14 +366,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();
|
||||
}
|
||||
|
||||
@@ -445,7 +451,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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ public class DataFixerV1217 extends DataFixerV1213 {
|
||||
attributes.put("minecraft:gameplay/bed_rule", new JSONObject()
|
||||
.put("can_set_spawn", "never")
|
||||
.put("can_sleep", "never")
|
||||
.put("explodes", true));
|
||||
.put("destroy_on_use", true));
|
||||
}
|
||||
|
||||
attributes.put("minecraft:gameplay/respawn_anchor_works", json.remove("respawn_anchor_works"));
|
||||
|
||||
@@ -49,16 +49,6 @@ public final class DataFixerV263 extends DataFixerV1217 {
|
||||
return fixed;
|
||||
}
|
||||
|
||||
/** 26.3 renamed the bed rule's explodes flag to destroy_on_use; the old key is ignored there. */
|
||||
@Override
|
||||
public void fixDimension(Dimension dimension, JSONObject json) {
|
||||
super.fixDimension(dimension, json);
|
||||
JSONObject bedRule = json.getJSONObject("attributes").optJSONObject("minecraft:gameplay/bed_rule");
|
||||
if (bedRule != null && bedRule.has("explodes")) {
|
||||
bedRule.put("destroy_on_use", bedRule.remove("explodes"));
|
||||
}
|
||||
}
|
||||
|
||||
private static void color(JSONObject object, String key) {
|
||||
if (object.opt(key) instanceof Number value) {
|
||||
object.put(key, String.format(Locale.ROOT, "#%06x", value.intValue() & 0xFFFFFF));
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -441,7 +441,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -25,7 +25,6 @@ import art.arcane.iris.integration.ExternalDataSVC;
|
||||
import art.arcane.iris.structure.object.IrisObjectRotation;
|
||||
import art.arcane.volmlib.nativelib.terrain.BlockStateKey;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.nativelib.block.SurvivalAnswer;
|
||||
import art.arcane.iris.generation.block.IrisCustomData;
|
||||
import art.arcane.iris.generation.geometry.IrisBlockVector;
|
||||
import art.arcane.iris.spi.IrisServices;
|
||||
@@ -430,18 +429,7 @@ public final class BukkitBlockState implements NativeBlockState {
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOnto(NativeBlockState onto) {
|
||||
BlockData plant = realBlockOf(data);
|
||||
BlockData ground = realBlockOf((BlockData) onto.nativeHandle());
|
||||
SurvivalAnswer serverRule = INMS.isBound() ? INMS.get().canSurviveOn(plant, ground) : SurvivalAnswer.UNANSWERED;
|
||||
return switch (serverRule) {
|
||||
case SURVIVES -> true;
|
||||
case FAILS -> false;
|
||||
case UNANSWERED -> BukkitBlockResolution.canPlaceOnto(plant.getMaterial(), ground.getMaterial());
|
||||
};
|
||||
}
|
||||
|
||||
private static BlockData realBlockOf(BlockData data) {
|
||||
return data instanceof IrisCustomData custom ? custom.getBase() : data;
|
||||
return BukkitBlockResolution.canPlaceOnto(data.getMaterial(), ((BlockData) onto.nativeHandle()).getMaterial());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1094,11 +1094,23 @@ 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");
|
||||
}
|
||||
|
||||
private static String packKeyOf(Engine activeEngine) {
|
||||
IrisDimension dimension = activeEngine.getDimension();
|
||||
return dimension == null ? "unknown pack" : dimension.getLoadKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> hotloadAsync() {
|
||||
if (!canHotloadStudio()) {
|
||||
@@ -1108,7 +1120,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
if (!canHotloadStudio()) {
|
||||
throw new IllegalStateException("Studio is not ready for hotload.");
|
||||
}
|
||||
getEngine().hotload();
|
||||
hotloadEngine();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1133,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));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 145 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user