mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Merge upstream port lane d
NativeStructureWorldgenAccess keeps both sides: writes are still recorded for the stale deferred-record check, and they go through the POI reconciler when one is bound.
This commit is contained in:
commit
4b1d85177f
69 files changed
+2413
-255
No files matched your search
@@ -46,7 +46,6 @@ import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -92,6 +91,9 @@ public class ServerConfigurator {
|
||||
private static final String COMPILER_INPUT_FINGERPRINT_CACHE = "datapack-compiler-input-fingerprint";
|
||||
static final String POST_COMPILE_RESTART_WARNING = "Iris installed updated datapack registry entries; "
|
||||
+ "restart the server before creating worlds or opening Studios.";
|
||||
private static final Path SPIGOT_CONFIGURATION = Path.of("spigot.yml");
|
||||
private static final Path PAPER_GLOBAL_CONFIGURATION = Path.of("config", "paper-global.yml");
|
||||
private static final String TIMEOUT_RECOVERY_FILE = "server-timeouts.json";
|
||||
private static final int FINGERPRINT_BUFFER_BYTES = 64 * 1024;
|
||||
private static volatile boolean loadedDatapackRuntimeReady;
|
||||
private static volatile String loadedDatapackCompilerInputFingerprint = "";
|
||||
@@ -108,11 +110,27 @@ public class ServerConfigurator {
|
||||
}
|
||||
IrisSettings.IrisSettingsAutoconfiguration s = IrisSettings.get().getAutoConfiguration();
|
||||
if (s.isConfigureSpigotTimeoutTime()) {
|
||||
J.attempt(ServerConfigurator::increaseKeepAliveSpigot);
|
||||
Throwable failure = J.attemptCatch(ServerConfigurator::increaseKeepAliveSpigot);
|
||||
if (failure != null) {
|
||||
IrisLogging.reportError("Unable to persist the Spigot timeout setting.", failure);
|
||||
}
|
||||
} else {
|
||||
Throwable failure = J.attemptCatch(() -> timeoutConfiguration().restore(ServerTimeoutConfiguration.SPIGOT_TIMEOUT_KEY));
|
||||
if (failure != null) {
|
||||
IrisLogging.reportError("Unable to restore the Spigot timeout setting.", failure);
|
||||
}
|
||||
}
|
||||
|
||||
if (s.isConfigurePaperWatchdogDelay()) {
|
||||
J.attempt(ServerConfigurator::increasePaperWatchdog);
|
||||
Throwable failure = J.attemptCatch(ServerConfigurator::increasePaperWatchdog);
|
||||
if (failure != null) {
|
||||
IrisLogging.reportError("Unable to persist the Paper watchdog setting.", failure);
|
||||
}
|
||||
} else {
|
||||
Throwable failure = J.attemptCatch(() -> timeoutConfiguration().restore(ServerTimeoutConfiguration.PAPER_WATCHDOG_KEY));
|
||||
if (failure != null) {
|
||||
IrisLogging.reportError("Unable to restore the Paper watchdog setting.", failure);
|
||||
}
|
||||
}
|
||||
|
||||
if (DefaultPackBootstrapProvisioner.wasProvisionedThisStartup()) {
|
||||
@@ -240,34 +258,45 @@ public class ServerConfigurator {
|
||||
}
|
||||
|
||||
private static void increaseKeepAliveSpigot() throws IOException, InvalidConfigurationException {
|
||||
File spigotConfig = new File("spigot.yml");
|
||||
FileConfiguration f = new YamlConfiguration();
|
||||
f.load(spigotConfig);
|
||||
long tt = f.getLong("settings.timeout-time");
|
||||
increaseKeepAliveSpigot(SPIGOT_CONFIGURATION, timeoutConfiguration());
|
||||
}
|
||||
|
||||
long spigotTimeout = TimeUnit.MINUTES.toSeconds(5);
|
||||
|
||||
if (tt < spigotTimeout) {
|
||||
IrisLogging.warn("Updating spigot.yml timeout-time: " + tt + " -> " + spigotTimeout + " (5 minutes)");
|
||||
IrisLogging.warn("You can disable this change (autoconfigureServer) in Iris settings, then change back the value.");
|
||||
f.set("settings.timeout-time", spigotTimeout);
|
||||
f.save(spigotConfig);
|
||||
static void increaseKeepAliveSpigot(Path file, ServerTimeoutConfiguration timeouts) throws IOException, InvalidConfigurationException {
|
||||
long previous = loadConfiguration(file).getLong(ServerTimeoutConfiguration.SPIGOT_TIMEOUT_KEY);
|
||||
long minimum = TimeUnit.MINUTES.toSeconds(5);
|
||||
if (previous >= minimum) {
|
||||
return;
|
||||
}
|
||||
timeouts.raise(file, ServerTimeoutConfiguration.SPIGOT_TIMEOUT_KEY, minimum);
|
||||
IrisLogging.warn("Updated " + file + " settings.timeout-time: " + previous + " -> " + minimum
|
||||
+ " seconds. Takes effect after a server restart.");
|
||||
IrisLogging.warn("Disable autoConfiguration.configureSpigotTimeoutTime in iris.json to restore the original value.");
|
||||
}
|
||||
|
||||
private static void increasePaperWatchdog() throws IOException, InvalidConfigurationException {
|
||||
File spigotConfig = new File("config/paper-global.yml");
|
||||
FileConfiguration f = new YamlConfiguration();
|
||||
f.load(spigotConfig);
|
||||
long tt = f.getLong("watchdog.early-warning-delay");
|
||||
increasePaperWatchdog(PAPER_GLOBAL_CONFIGURATION, timeoutConfiguration());
|
||||
}
|
||||
|
||||
long watchdog = TimeUnit.MINUTES.toMillis(3);
|
||||
if (tt < watchdog) {
|
||||
IrisLogging.warn("Updating paper.yml watchdog early-warning-delay: " + tt + " -> " + watchdog + " (3 minutes)");
|
||||
IrisLogging.warn("You can disable this change (autoconfigureServer) in Iris settings, then change back the value.");
|
||||
f.set("watchdog.early-warning-delay", watchdog);
|
||||
f.save(spigotConfig);
|
||||
static void increasePaperWatchdog(Path file, ServerTimeoutConfiguration timeouts) throws IOException, InvalidConfigurationException {
|
||||
long previous = loadConfiguration(file).getLong(ServerTimeoutConfiguration.PAPER_WATCHDOG_KEY);
|
||||
long minimum = TimeUnit.MINUTES.toMillis(3);
|
||||
if (previous >= minimum) {
|
||||
return;
|
||||
}
|
||||
timeouts.raise(file, ServerTimeoutConfiguration.PAPER_WATCHDOG_KEY, minimum);
|
||||
IrisLogging.warn("Updated " + file + " watchdog.early-warning-delay: " + previous + " -> " + minimum
|
||||
+ " milliseconds. Takes effect after a server restart.");
|
||||
IrisLogging.warn("Disable autoConfiguration.configurePaperWatchdogDelay in iris.json to restore the original value.");
|
||||
}
|
||||
|
||||
private static YamlConfiguration loadConfiguration(Path file) throws IOException, InvalidConfigurationException {
|
||||
YamlConfiguration configuration = new YamlConfiguration();
|
||||
configuration.load(file.toFile());
|
||||
return configuration;
|
||||
}
|
||||
|
||||
private static ServerTimeoutConfiguration timeoutConfiguration() {
|
||||
return new ServerTimeoutConfiguration(IrisPlatforms.get().dataFolder().toPath().resolve(TIMEOUT_RECOVERY_FILE));
|
||||
}
|
||||
|
||||
public static KList<File> getDatapacksFolder() {
|
||||
@@ -852,7 +881,7 @@ public class ServerConfigurator {
|
||||
|
||||
private static void writeFingerprintCache(Path cacheFile, PackFingerprint fingerprint) {
|
||||
try {
|
||||
writeFingerprintAtomic(cacheFile, fingerprint.content() + "\n" + fingerprint.metadata());
|
||||
writeStringAtomic(cacheFile, fingerprint.content() + "\n" + fingerprint.metadata());
|
||||
} catch (IOException e) {
|
||||
IrisLogging.warn("Failed to write datapack fingerprint cache: " + e.getMessage());
|
||||
}
|
||||
@@ -860,23 +889,23 @@ public class ServerConfigurator {
|
||||
|
||||
private static void writeCompilerInputFingerprintCache(Path cacheFile, String fingerprint) {
|
||||
try {
|
||||
writeFingerprintAtomic(cacheFile, fingerprint);
|
||||
writeStringAtomic(cacheFile, fingerprint);
|
||||
} catch (IOException exception) {
|
||||
IrisLogging.warn("Failed to write datapack compiler-input fingerprint cache: "
|
||||
+ exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeFingerprintAtomic(Path target, String fingerprint) throws IOException {
|
||||
static void writeStringAtomic(Path target, String content) throws IOException {
|
||||
Path absoluteTarget = target.toAbsolutePath().normalize();
|
||||
Path parent = absoluteTarget.getParent();
|
||||
if (parent == null) {
|
||||
throw new IOException("Datapack fingerprint target has no parent: " + absoluteTarget);
|
||||
throw new IOException("Atomic write target has no parent: " + absoluteTarget);
|
||||
}
|
||||
Files.createDirectories(parent);
|
||||
Path staged = Files.createTempFile(parent, ".datapack-fingerprint-", ".tmp");
|
||||
Path staged = Files.createTempFile(parent, ".iris-write-", ".tmp");
|
||||
try {
|
||||
Files.writeString(staged, fingerprint, StandardCharsets.UTF_8);
|
||||
Files.writeString(staged, content, StandardCharsets.UTF_8);
|
||||
try (FileChannel channel = FileChannel.open(staged, StandardOpenOption.WRITE)) {
|
||||
channel.force(true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
package art.arcane.iris.core;
|
||||
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParseException;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
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.Objects;
|
||||
|
||||
final class ServerTimeoutConfiguration {
|
||||
static final String SPIGOT_TIMEOUT_KEY = "settings.timeout-time";
|
||||
static final String PAPER_WATCHDOG_KEY = "watchdog.early-warning-delay";
|
||||
|
||||
private static final Object MUTATION_LOCK = new Object();
|
||||
private static final Gson JSON = new GsonBuilder().setPrettyPrinting().serializeNulls().create();
|
||||
|
||||
private final Path recoveryFile;
|
||||
|
||||
ServerTimeoutConfiguration(Path recoveryFile) {
|
||||
this.recoveryFile = Objects.requireNonNull(recoveryFile);
|
||||
}
|
||||
|
||||
void raise(Path file, String key, long minimum) throws IOException {
|
||||
synchronized (MUTATION_LOCK) {
|
||||
Path target = file.toRealPath();
|
||||
YamlConfiguration configuration = load(target);
|
||||
Long original = value(configuration, key);
|
||||
List<SavedTimeout> changes = readChanges();
|
||||
SavedTimeout saved = find(changes, target, key);
|
||||
if (saved == null || !Objects.equals(original, saved.original()) && !Objects.equals(original, saved.applied())) {
|
||||
changes.remove(saved);
|
||||
changes.add(new SavedTimeout(target.toString(), key, original, minimum));
|
||||
writeChanges(changes);
|
||||
}
|
||||
configuration.set(key, minimum);
|
||||
ServerConfigurator.writeStringAtomic(target, configuration.saveToString());
|
||||
}
|
||||
}
|
||||
|
||||
void restore(String key) throws IOException {
|
||||
synchronized (MUTATION_LOCK) {
|
||||
List<SavedTimeout> changes = readChanges();
|
||||
for (SavedTimeout saved : List.copyOf(changes)) {
|
||||
if (!saved.key().equals(key)) {
|
||||
continue;
|
||||
}
|
||||
restore(saved);
|
||||
changes.remove(saved);
|
||||
writeChanges(changes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void restore(SavedTimeout saved) throws IOException {
|
||||
Path target = Path.of(saved.file());
|
||||
if (!Files.exists(target)) {
|
||||
return;
|
||||
}
|
||||
YamlConfiguration configuration = load(target);
|
||||
if (!Objects.equals(value(configuration, saved.key()), saved.applied())) {
|
||||
IrisLogging.info("Kept the current " + target + " " + saved.key()
|
||||
+ " because it differs from the value saved by Iris.");
|
||||
return;
|
||||
}
|
||||
configuration.set(saved.key(), saved.original());
|
||||
ServerConfigurator.writeStringAtomic(target, configuration.saveToString());
|
||||
IrisLogging.info("Restored " + target + " " + saved.key() + " to "
|
||||
+ (saved.original() == null ? "its server default" : saved.original())
|
||||
+ ". Takes effect after a server restart.");
|
||||
}
|
||||
|
||||
private List<SavedTimeout> readChanges() throws IOException {
|
||||
if (!Files.exists(recoveryFile)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
try {
|
||||
SavedTimeouts saved = JSON.fromJson(Files.readString(recoveryFile), SavedTimeouts.class);
|
||||
if (saved == null) {
|
||||
throw new IOException("Empty server timeout recovery data: " + recoveryFile);
|
||||
}
|
||||
return new ArrayList<>(saved.changes());
|
||||
} catch (JsonParseException | IllegalArgumentException exception) {
|
||||
throw new IOException("Invalid server timeout recovery data: " + recoveryFile, exception);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeChanges(List<SavedTimeout> changes) throws IOException {
|
||||
ServerConfigurator.writeStringAtomic(recoveryFile, JSON.toJson(new SavedTimeouts(changes)));
|
||||
}
|
||||
|
||||
private static SavedTimeout find(List<SavedTimeout> changes, Path target, String key) {
|
||||
for (SavedTimeout change : changes) {
|
||||
if (change.file().equals(target.toString()) && change.key().equals(key)) {
|
||||
return change;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static YamlConfiguration load(Path file) throws IOException {
|
||||
YamlConfiguration configuration = new YamlConfiguration();
|
||||
try {
|
||||
configuration.load(file.toFile());
|
||||
} catch (InvalidConfigurationException exception) {
|
||||
throw new IOException("Invalid server configuration: " + file, exception);
|
||||
}
|
||||
return configuration;
|
||||
}
|
||||
|
||||
private static Long value(YamlConfiguration configuration, String key) throws IOException {
|
||||
if (!configuration.isSet(key)) {
|
||||
return null;
|
||||
}
|
||||
if (!configuration.isInt(key) && !configuration.isLong(key)) {
|
||||
throw new IOException("Server timeout " + key + " must be an integer.");
|
||||
}
|
||||
return configuration.getLong(key);
|
||||
}
|
||||
|
||||
private record SavedTimeout(String file, String key, Long original, long applied) {
|
||||
private SavedTimeout {
|
||||
Objects.requireNonNull(file, "file");
|
||||
Objects.requireNonNull(key, "key");
|
||||
if (!Path.of(file).isAbsolute() || applied <= 0
|
||||
|| !key.equals(SPIGOT_TIMEOUT_KEY) && !key.equals(PAPER_WATCHDOG_KEY)) {
|
||||
throw new IllegalArgumentException("Invalid saved server timeout");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private record SavedTimeouts(List<SavedTimeout> changes) {
|
||||
private SavedTimeouts {
|
||||
changes = List.copyOf(changes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,15 +152,19 @@ public final class IrisWorldRemovalService {
|
||||
boolean deleteFiles,
|
||||
AtomicBoolean terminal
|
||||
) {
|
||||
AtomicBoolean maintenanceEntered = new AtomicBoolean(false);
|
||||
CompletableFuture<RemovalResult> operation = phase(
|
||||
RemovalStatus.RESOLUTION_FAILED,
|
||||
() -> backend.beginMaintenance(resolved).thenApply(ignored -> resolved),
|
||||
RemovalStatus.TELEPORT_FAILED,
|
||||
() -> backend.evacuatePlayers(resolved).thenApply(ignored -> resolved),
|
||||
terminal
|
||||
)
|
||||
.thenCompose(activeWorld -> phase(
|
||||
RemovalStatus.TELEPORT_FAILED,
|
||||
() -> backend.evacuatePlayers(activeWorld)
|
||||
.thenApply(ignored -> activeWorld),
|
||||
RemovalStatus.RESOLUTION_FAILED,
|
||||
() -> {
|
||||
CompletableFuture<Void> begun = backend.beginMaintenance(activeWorld);
|
||||
maintenanceEntered.set(true);
|
||||
return begun.thenApply(ignored -> activeWorld);
|
||||
},
|
||||
terminal
|
||||
))
|
||||
.thenCompose(activeWorld -> phase(
|
||||
@@ -198,7 +202,7 @@ public final class IrisWorldRemovalService {
|
||||
);
|
||||
}));
|
||||
|
||||
return operation.handle((result, throwable) -> backend.endMaintenance(resolved)
|
||||
return operation.handle((result, throwable) -> endMaintenance(resolved, maintenanceEntered.get())
|
||||
.handle((ignored, cleanupFailure) -> {
|
||||
if (cleanupFailure != null) {
|
||||
Throwable unwrappedCleanup = unwrap(cleanupFailure);
|
||||
@@ -216,6 +220,10 @@ public final class IrisWorldRemovalService {
|
||||
})).thenCompose(result -> result);
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> endMaintenance(ResolvedWorld resolved, boolean entered) {
|
||||
return entered ? backend.endMaintenance(resolved) : CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
private CompletableFuture<ResolvedWorld> validateResolvedWorld(ResolvedWorld resolvedWorld) {
|
||||
if (!resolvedWorld.managed()) {
|
||||
return CompletableFuture.failedFuture(new RemovalFailure(
|
||||
|
||||
@@ -21,7 +21,10 @@ public final class ModdedCommandMessages {
|
||||
public static final TextKey IRIS_MODDED_COMMANDS_CONSOLE_MUST_NAME_PLAYER_IRIS_TP_DIMENSION_PLAYER = text("iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player");
|
||||
public static final TextKey IRIS_MODDED_COMMANDS_IS_NOT_GENERATED_BY_IRIS = text("iris.modded.irismoddedcommands.is_not_generated_by_iris");
|
||||
public static final TextKey IRIS_MODDED_COMMANDS_TELEPORT_FAILED_DIMENSION_IS_NOT_LOADED = text("iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded");
|
||||
public static final TextKey IRIS_MODDED_COMMANDS_TELEPORTING = text("iris.modded.irismoddedcommands.teleporting");
|
||||
public static final TextKey IRIS_MODDED_COMMANDS_TELEPORT_FAILED_REASON = text("iris.modded.irismoddedcommands.teleport_failed_reason");
|
||||
public static final TextKey IRIS_MODDED_COMMANDS_TELEPORT_CANCELLED_PLAYER_OFFLINE = text("iris.modded.irismoddedcommands.teleport_cancelled_player_offline");
|
||||
public static final TextKey IRIS_MODDED_COMMANDS_TELEPORT_REFUSED = text("iris.modded.irismoddedcommands.teleport_refused");
|
||||
public static final TextKey IRIS_MODDED_COMMANDS_TELEPORTING =text("iris.modded.irismoddedcommands.teleporting");
|
||||
public static final TextKey IRIS_MODDED_COMMANDS_IS_NOT_GENERATED_BY_IRIS_2 = text("iris.modded.irismoddedcommands.is_not_generated_by_iris_2");
|
||||
public static final TextKey IRIS_MODDED_COMMANDS_CANNOT_EVACUATE_PRIMARY_WORLD_THERE_IS_NOWHERE_SEND_PLAYERS = text("iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players");
|
||||
public static final TextKey IRIS_MODDED_COMMANDS_EVACUATED_PLAYER_S_FROM = text("iris.modded.irismoddedcommands.evacuated_player_s_from");
|
||||
|
||||
@@ -230,6 +230,9 @@ public interface INMSBinding {
|
||||
default void flushChunkIO(World world) {
|
||||
}
|
||||
|
||||
default void reconcileNativeStructurePois(Chunk chunk) {
|
||||
}
|
||||
|
||||
void injectBiomesFromMantle(Chunk e, Mantle<Matter> mantle);
|
||||
|
||||
ItemStack applyCustomNbt(ItemStack itemStack, KMap<String, Object> customNbt) throws IllegalArgumentException;
|
||||
|
||||
@@ -485,12 +485,17 @@ public final class StudioOpenCoordinator {
|
||||
AtomicBoolean unloadStarted = new AtomicBoolean(false);
|
||||
AtomicBoolean folderDeleted = new AtomicBoolean(!deleteFolder);
|
||||
AtomicBoolean terminalTimeout = new AtomicBoolean(false);
|
||||
if (world != null) {
|
||||
IrisToolbelt.beginWorldMaintenance(world, "studio-close", true);
|
||||
}
|
||||
AtomicBoolean maintenanceEntered = new AtomicBoolean(false);
|
||||
|
||||
CompletableFuture<Void> sequence = sequenceStudioClose(
|
||||
() -> evacuateWorldFamily(worldName, world),
|
||||
() -> {
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
IrisToolbelt.beginWorldMaintenance(world, "studio-close", true);
|
||||
maintenanceEntered.set(true);
|
||||
},
|
||||
() -> {
|
||||
unloadStarted.set(true);
|
||||
return unloadWorldFamily(worldName, world).thenRun(() -> {
|
||||
@@ -535,7 +540,7 @@ public final class StudioOpenCoordinator {
|
||||
);
|
||||
});
|
||||
return operation.whenComplete((result, throwable) -> {
|
||||
if (world != null) {
|
||||
if (maintenanceEntered.get()) {
|
||||
IrisToolbelt.endWorldMaintenance(world, "studio-close", true);
|
||||
}
|
||||
});
|
||||
@@ -549,22 +554,27 @@ public final class StudioOpenCoordinator {
|
||||
|
||||
static CompletableFuture<Void> sequenceStudioClose(
|
||||
Supplier<CompletableFuture<Void>> evacuate,
|
||||
Runnable enterMaintenance,
|
||||
Supplier<CompletableFuture<Void>> unload,
|
||||
Supplier<CompletableFuture<Void>> closeGenerator,
|
||||
Supplier<CompletableFuture<Void>> deleteFolders
|
||||
) {
|
||||
return sequenceStudioClose(evacuate, unload, closeGenerator, deleteFolders, () -> false);
|
||||
return sequenceStudioClose(evacuate, enterMaintenance, unload, closeGenerator, deleteFolders, () -> false);
|
||||
}
|
||||
|
||||
static CompletableFuture<Void> sequenceStudioClose(
|
||||
Supplier<CompletableFuture<Void>> evacuate,
|
||||
Runnable enterMaintenance,
|
||||
Supplier<CompletableFuture<Void>> unload,
|
||||
Supplier<CompletableFuture<Void>> closeGenerator,
|
||||
Supplier<CompletableFuture<Void>> deleteFolders,
|
||||
BooleanSupplier terminalTimeout
|
||||
) {
|
||||
return invokePhase(evacuate)
|
||||
.thenCompose(ignored -> invokePhaseUnlessTimedOut(unload, terminalTimeout))
|
||||
.thenCompose(ignored -> invokePhaseUnlessTimedOut(() -> {
|
||||
enterMaintenance.run();
|
||||
return unload.get();
|
||||
}, terminalTimeout))
|
||||
.thenCompose(ignored -> invokePhaseUnlessTimedOut(closeGenerator, terminalTimeout))
|
||||
.thenCompose(ignored -> invokePhaseUnlessTimedOut(deleteFolders, terminalTimeout));
|
||||
}
|
||||
|
||||
@@ -845,12 +845,12 @@ public class StudioSVC implements IrisService {
|
||||
}
|
||||
|
||||
private void destroyStudioWorld(World world, PlatformChunkGenerator generator) {
|
||||
IrisToolbelt.beginWorldMaintenance(world, "studio-disable", true);
|
||||
try {
|
||||
IrisToolbelt.evacuate(world);
|
||||
} catch (Throwable e) {
|
||||
IrisLogging.reportError("Failed to evacuate studio world \"" + world.getName() + "\" during shutdown cleanup.", e);
|
||||
}
|
||||
IrisToolbelt.beginWorldMaintenance(world, "studio-disable", true);
|
||||
try {
|
||||
WorldLifecycleService.get().unloadAsync(world, false)
|
||||
.thenCompose(unloaded -> {
|
||||
|
||||
@@ -313,6 +313,8 @@ public class IrisCreator {
|
||||
.thenCompose(Function.identity())
|
||||
.get(WORLD_CREATE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
|
||||
if (!studio && !benchmark) {
|
||||
World createdWorld = world;
|
||||
J.sfut(() -> createdWorld.save()).get(WORLD_CREATE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
|
||||
awaitInitialSpawnPreparation(access, name);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
@@ -745,12 +747,15 @@ public class IrisCreator {
|
||||
}
|
||||
}
|
||||
if (activeWorld != null) {
|
||||
IrisToolbelt.beginWorldMaintenance(activeWorld, "world-create-rollback", true);
|
||||
boolean maintenanceEntered = false;
|
||||
try {
|
||||
PlatformChunkGenerator generator = IrisToolbelt.access(activeWorld);
|
||||
boolean evacuated = Boolean.TRUE.equals(IrisToolbelt.evacuateAsync(activeWorld)
|
||||
.get(ROLLBACK_PHASE_TIMEOUT_SECONDS, TimeUnit.SECONDS));
|
||||
if (!evacuated) {
|
||||
if (evacuated) {
|
||||
IrisToolbelt.beginWorldMaintenance(activeWorld, "world-create-rollback", true);
|
||||
maintenanceEntered = true;
|
||||
} else {
|
||||
safeToDelete = false;
|
||||
failure.addSuppressed(new IllegalStateException(
|
||||
"Rollback could not evacuate world \"" + name + "\"."));
|
||||
@@ -778,7 +783,9 @@ public class IrisCreator {
|
||||
ServerConfigurator.restart("World creation rollback timed out for \"" + name + "\".");
|
||||
}
|
||||
} finally {
|
||||
IrisToolbelt.endWorldMaintenance(activeWorld, "world-create-rollback", true);
|
||||
if (maintenanceEntered) {
|
||||
IrisToolbelt.endWorldMaintenance(activeWorld, "world-create-rollback", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ package art.arcane.iris.engine;
|
||||
import art.arcane.iris.platform.bukkit.BukkitWorldBinding;
|
||||
import art.arcane.iris.core.IrisSettings;
|
||||
import art.arcane.volmlib.util.cache.CacheKey;
|
||||
import art.arcane.iris.core.nms.INMS;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineAssignedWorldManager;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
@@ -205,6 +206,8 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
return;
|
||||
}
|
||||
|
||||
INMS.get().reconcileNativeStructurePois(e);
|
||||
|
||||
if (cleanupServiceStopped || cleanupService == null || cleanupService.isShutdown()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,43 +19,33 @@
|
||||
package art.arcane.iris.platform.bukkit;
|
||||
|
||||
import art.arcane.iris.spi.PlatformBiome;
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Interned Bukkit adapter for a neutral biome handle.
|
||||
*/
|
||||
public final class BukkitBiome implements PlatformBiome {
|
||||
private static final ConcurrentHashMap<String, BukkitBiome> CACHE = new ConcurrentHashMap<>();
|
||||
private static final Cache<Biome, BukkitBiome> CACHE = Caffeine.newBuilder()
|
||||
.weakKeys()
|
||||
.maximumSize(4_096)
|
||||
.build();
|
||||
|
||||
private final Biome biome;
|
||||
private final String key;
|
||||
private final String namespace;
|
||||
|
||||
private BukkitBiome(Biome biome, String key) {
|
||||
private BukkitBiome(Biome biome) {
|
||||
this.biome = biome;
|
||||
this.key = key;
|
||||
int colon = key.indexOf(':');
|
||||
this.namespace = colon >= 0 ? key.substring(0, colon) : "minecraft";
|
||||
NamespacedKey biomeKey = biome.getKey();
|
||||
this.key = biomeKey.toString();
|
||||
this.namespace = biomeKey.getNamespace();
|
||||
}
|
||||
|
||||
public static BukkitBiome of(Biome biome) {
|
||||
String key = biomeKey(biome);
|
||||
return CACHE.computeIfAbsent(key, (String k) -> new BukkitBiome(biome, k));
|
||||
}
|
||||
|
||||
private static String biomeKey(Biome biome) {
|
||||
for (String method : new String[]{"getKeyOrNull", "getKeyOrThrow", "getKey"}) {
|
||||
try {
|
||||
Object key = Biome.class.getMethod(method).invoke(biome);
|
||||
if (key != null) {
|
||||
return key.toString();
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
return biome.toString();
|
||||
return CACHE.get(biome, BukkitBiome::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "Die Konsole muss einen Spieler benennen: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} wird nicht von Iris generiert.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Teleportation fehlgeschlagen: Dimension {dimensionId} ist nicht geladen.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "Teleportiere {value} nach {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "Teleport nach {dimensionId} fehlgeschlagen: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "Teleport nach {dimensionId} abgebrochen: {value} ist nicht mehr online.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "Teleport nach {dimensionId} wurde vom Server abgelehnt.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"Teleportiere {value} nach {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} wird nicht von Iris generiert.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "Die primäre Welt kann nicht evakuiert werden, da es kein Ziel für die Spieler gibt.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "{count} Spieler von {value} nach {value2} evakuiert.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "La consola debe indicar un jugador: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} no se genera por Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "El teletransporte falló: la dimensión {dimensionId} no está cargada.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "Teletransportando a {value} a {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "El teletransporte a {dimensionId} falló: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "Teletransporte a {dimensionId} cancelado: {value} ya no está conectado.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "El servidor rechazó el teletransporte a {dimensionId}.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"Teletransportando a {value} a {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} no se genera por Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "No se puede evacuar el mundo principal porque no hay adónde enviar a los jugadores.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "Se evacuaron {count} jugador(es) de {value} a {value2}.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "Konsolin on nimettävä pelaaja: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} ei ole tuotettu Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Teleportti epäonnistui: ulottuvuus {dimensionId} ei ole ladattu.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "Telesiirtäminen {value} - {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "Teleporttaus ulottuvuuteen {dimensionId} epäonnistui: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "Teleporttaus ulottuvuuteen {dimensionId} peruttiin: {value} ei ole enää paikalla.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "Palvelin hylkäsi teleporttauksen ulottuvuuteen {dimensionId}.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"Telesiirtäminen {value} - {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} ei ole tuotettu Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "Ensisijaista maailmaa ei voida evakuoida; pelaajia ei voi lähettää minnekään.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "Evakuoitu {count} pelaajat {value} - {value2}.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "La console doit indiquer un joueur : /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} n'est pas généré par Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Échec de la téléportation : la dimension {dimensionId} n'est pas chargée.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "Téléportation de {value} vers {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "Échec de la téléportation vers {dimensionId} : {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "Téléportation vers {dimensionId} annulée : {value} n'est plus connecté.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "Le serveur a refusé la téléportation vers {dimensionId}.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"Téléportation de {value} vers {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} n'est pas généré par Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "Impossible d'évacuer le monde principal, car aucun autre monde ne peut accueillir les joueurs.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "{count} joueur(s) évacué(s) de {value} vers {value2}.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "הקונסולה חייבת לקרוא לשחקן: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} לא נוצר על ידי Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "טלפורט נכשל: ממד {dimensionId} לא טעון.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "תקשורת {value} כדי {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "השיגור אל {dimensionId} נכשל: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "השיגור אל {dimensionId} בוטל: {value} כבר לא מחובר.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "השרת דחה את השיגור אל {dimensionId}.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"תקשורת {value} כדי {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} לא נוצר על ידי Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "לא ניתן לפנות לעולם הראשי, אין מקום לשלוח שחקנים.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "הערכה {count} שחקן(s) {value} כדי {value2}.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "La console deve specificare un giocatore: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} non è generato da Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Teletrasporto non riuscito: la dimensione {dimensionId} non è caricata.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "Teletrasporto di {value} verso {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "Teletrasporto verso {dimensionId} non riuscito: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "Teletrasporto verso {dimensionId} annullato: {value} non è più online.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "Il server ha rifiutato il teletrasporto verso {dimensionId}.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"Teletrasporto di {value} verso {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} non è generato da Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "Impossibile evacuare il mondo principale: non esiste una destinazione per i giocatori.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "Evacuati {count} giocatori da {value} a {value2}.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "コンソールではプレイヤーを指定してください: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} は Iris によって生成されていません。",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "テレポートに失敗しました: ディメンション {dimensionId} は読み込まれていません。",
|
||||
"iris.modded.irismoddedcommands.teleporting": "{value} を {dimensionId} にテレポートしています...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "{dimensionId} へのテレポートに失敗しました: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "{dimensionId} へのテレポートを中止しました: {value} はオフラインです。",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "サーバーが {dimensionId} へのテレポートを拒否しました。",
|
||||
"iris.modded.irismoddedcommands.teleporting":"{value} を {dimensionId} にテレポートしています...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} は Iris によって生成されていません。",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "プライマリーワールドからは退避できません。プレイヤーの移動先がありません。",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "{count} 人のプレイヤーを {value} から {value2} へ退避させました。",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "콘솔은 플레이어를 지정해야 합니다: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} 에 의해 생성되지 않음 Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Teleport 실패: 차원 {dimensionId} 로드 되지 않습니다.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "팟캐스트 {value} 으로 {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "{dimensionId}(으)로 순간이동 실패: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "{dimensionId}(으)로 순간이동 취소됨: {value} 님이 더 이상 접속해 있지 않습니다.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "서버가 {dimensionId}(으)로의 순간이동을 거부했습니다.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"팟캐스트 {value} 으로 {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} 에 의해 생성되지 않음 Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "1 차 세계를 피할 수 없습니다. 플레이어에게 보내는 곳이 없습니다.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "플레이어 {count}명을 {value}에서 {value2}(으)로 대피시켰습니다.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "Konsolė turi pavadinti žaidėją: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} generuoja ne Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Teleportas nepavyko: dimensija {dimensionId} neįkrauta.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "Teleportavimas {value} iki {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "Teleportavimas į {dimensionId} nepavyko: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "Teleportavimas į {dimensionId} atšauktas: {value} nebėra prisijungęs.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "Serveris atmetė teleportavimą į {dimensionId}.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"Teleportavimas {value} iki {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} generuoja ne Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "Negalima evakuoti pirminio pasaulio; nėra kur siųsti žaidėjų.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "Evakuoti {count} grotuvas (-ai) iš {value} iki {value2}.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "Console moet een speler een naam geven: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} wordt niet gegenereerd door Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Teleporteren mislukt: dimensie {dimensionId} is niet geladen.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "Teleporteren {value} tot {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "Teleporteren naar {dimensionId} mislukt: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "Teleporteren naar {dimensionId} geannuleerd: {value} is niet meer online.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "De server heeft het teleporteren naar {dimensionId} geweigerd.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"Teleporteren {value} tot {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} wordt niet gegenereerd door Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "Kan de primaire wereld niet evacueren; er is geen plek om spelers te sturen.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "Ontruimd {count} speler(s) van {value} tot {value2}.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "Konsola musi nazwać gracza: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} nie jest generowany przez Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Teleport nie powiódł się: wymiar {dimensionId} nie jest załadowany.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "Teleportowanie {value} do {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "Teleportacja do {dimensionId} nie powiodła się: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "Teleportacja do {dimensionId} anulowana: {value} nie jest już online.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "Serwer odrzucił teleportację do {dimensionId}.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"Teleportowanie {value} do {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} nie jest generowany przez Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "Nie można ewakuować głównego świata; nie ma gdzie wysłać graczy.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "Ewakuowane {count} odtwarzacz (-i) z {value} do {value2}.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "A consola deve nomear um jogador: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} não é gerado por Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Falha no teletransporte: dimensão {dimensionId} não está carregada.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "Teletransportando {value} para {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "Falha no teletransporte para {dimensionId}: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "Teletransporte para {dimensionId} cancelado: {value} já não está online.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "O servidor recusou o teletransporte para {dimensionId}.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"Teletransportando {value} para {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} não é gerado por Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "Não é possível evacuar o mundo primário; não há nenhum lugar para enviar jogadores.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "Evacuado {count} jogador( s) de {value} para {value2}.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "Консоль должна называть игрока: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} не генерируется путем Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Телепорт провалился: измерение {dimensionId} не загружается.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "телепортация {value} то {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "Не удалось телепортироваться в {dimensionId}: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "Телепортация в {dimensionId} отменена: {value} больше не в сети.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "Сервер отклонил телепортацию в {dimensionId}.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"телепортация {value} то {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} не генерируется путем Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "Нельзя эвакуировать основной мир, негде отправить игроков.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "эвакуированный {count} Игрок(ы) из {value} то {value2}.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "Konsol bir oyuncu adı olmalıdır: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} tarafından üretilmiyor Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Teleport başarısız oldu: Boyut {dimensionId} yüklenemez.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "Telporting {value} tom için {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "{dimensionId} boyutuna ışınlanma başarısız oldu: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "{dimensionId} boyutuna ışınlanma iptal edildi: {value} artık çevrimiçi değil.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "Sunucu {dimensionId} boyutuna ışınlanmayı reddetti.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"Telporting {value} tom için {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} tarafından üretilmiyor Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "birincil dünyayı tahliye edemez; oyuncuları göndermek için hiçbir yer yoktur.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "Evakuated {count} oyuncu(s) -den {value} tom için {value2}.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "Cần phải đặt tên người chơi: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} không được tạo ra bởi Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Chuyển tiếp thất bại: chiều {dimensionId} không nạp đạn.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "Chuyển tiếp {value} phải {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "Dịch chuyển tới {dimensionId} thất bại: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "Đã hủy dịch chuyển tới {dimensionId}: {value} không còn trực tuyến.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "Máy chủ đã từ chối dịch chuyển tới {dimensionId}.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"Chuyển tiếp {value} phải {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} không được tạo ra bởi Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "Không thể sơ tán thế giới chính; không có nơi nào để gửi cầu thủ.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "Đã sơ tán{count}người chơi từ{value}phải{value2}.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "控制台必须给玩家命名 : /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} 不由 Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Teleport 失败: 维度 {dimensionId} 未加载。",
|
||||
"iris.modded.irismoddedcommands.teleporting": "远程传送 {value} 改为: {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "传送到 {dimensionId} 失败:{reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "已取消传送到 {dimensionId}:{value} 已不在线。",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "服务器拒绝了传送到 {dimensionId}。",
|
||||
"iris.modded.irismoddedcommands.teleporting":"远程传送 {value} 改为: {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} 不由 Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "无法撤离主世界; 没有地方可以发送玩家 。",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "已撤离{count}玩家从{value}改为:{value2}.",
|
||||
|
||||
@@ -307,7 +307,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "控制檯必須給玩家命名 : /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} 不由 Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Teleport 失敗: 維度 {dimensionId} 未載入。",
|
||||
"iris.modded.irismoddedcommands.teleporting": "遠端傳送 {value} 改為: {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "傳送到 {dimensionId} 失敗:{reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "已取消傳送到 {dimensionId}:{value} 已不在線上。",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "伺服器拒絕了傳送到 {dimensionId}。",
|
||||
"iris.modded.irismoddedcommands.teleporting":"遠端傳送 {value} 改為: {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} 不由 Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "無法撤離主世界; 沒有地方可以傳送玩家 。",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "已撤離{count}玩家從{value}改為:{value2}.",
|
||||
|
||||
@@ -284,7 +284,10 @@
|
||||
"iris.modded.irismoddedcommands.console_must_name_player_iris_tp_dimension_player": "Console must name a player: /iris tp <dimension> <player>",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris": "{value} is not generated by Iris.",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_dimension_is_not_loaded": "Teleport failed: dimension {dimensionId} is not loaded.",
|
||||
"iris.modded.irismoddedcommands.teleporting": "Teleporting {value} to {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.teleport_failed_reason": "Teleport into {dimensionId} failed: {reason}",
|
||||
"iris.modded.irismoddedcommands.teleport_cancelled_player_offline": "Teleport into {dimensionId} cancelled: {value} is no longer online.",
|
||||
"iris.modded.irismoddedcommands.teleport_refused": "Teleport into {dimensionId} was refused by the server.",
|
||||
"iris.modded.irismoddedcommands.teleporting":"Teleporting {value} to {dimensionId}...",
|
||||
"iris.modded.irismoddedcommands.is_not_generated_by_iris_2": "{value} is not generated by Iris.",
|
||||
"iris.modded.irismoddedcommands.cannot_evacuate_primary_world_there_is_nowhere_send_players": "Cannot evacuate the primary world; there is nowhere to send players.",
|
||||
"iris.modded.irismoddedcommands.evacuated_player_s_from": "Evacuated {count} player(s) from {value} to {value2}.",
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
package art.arcane.iris.core;
|
||||
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.MockedStatic;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.CALLS_REAL_METHODS;
|
||||
import static org.mockito.Mockito.mockStatic;
|
||||
|
||||
public class ServerTimeoutConfigurationTest {
|
||||
private static final String SPIGOT_KEY = ServerTimeoutConfiguration.SPIGOT_TIMEOUT_KEY;
|
||||
private static final String PAPER_KEY = ServerTimeoutConfiguration.PAPER_WATCHDOG_KEY;
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void originalValuesSurviveRestartsAndRestoreIndependently() throws Exception {
|
||||
Path spigot = configuration("spigot.yml", "settings:\n timeout-time: 60\n");
|
||||
Path paper = configuration("paper-global.yml", "watchdog:\n early-warning-delay: 10000\n early-warning-every: 5000\n");
|
||||
try (MockedStatic<IrisLogging> logging = mockStatic(IrisLogging.class)) {
|
||||
ServerConfigurator.increaseKeepAliveSpigot(spigot, timeouts());
|
||||
ServerConfigurator.increasePaperWatchdog(paper, timeouts());
|
||||
ServerConfigurator.increaseKeepAliveSpigot(spigot, timeouts());
|
||||
timeouts().restore(SPIGOT_KEY);
|
||||
assertEquals(60L, load(spigot).getLong(SPIGOT_KEY));
|
||||
assertEquals(180000L, load(paper).getLong(PAPER_KEY));
|
||||
timeouts().restore(PAPER_KEY);
|
||||
assertEquals(10000L, load(paper).getLong(PAPER_KEY));
|
||||
assertEquals(5000L, load(paper).getLong("watchdog.early-warning-every"));
|
||||
assertFalse(Files.readString(recoveryFile()).contains("spigot.yml"));
|
||||
assertFalse(Files.readString(recoveryFile()).contains("paper-global.yml"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valueAtOrAboveTheMinimumIsLeftAlone() throws Exception {
|
||||
String original = "settings:\n timeout-time: 600\n";
|
||||
Path file = configuration("spigot.yml", original);
|
||||
try (MockedStatic<IrisLogging> logging = mockStatic(IrisLogging.class)) {
|
||||
ServerConfigurator.increaseKeepAliveSpigot(file, timeouts());
|
||||
assertEquals(original, Files.readString(file));
|
||||
assertFalse(Files.exists(recoveryFile()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restoringAbsentSettingRemovesTheOverride() throws Exception {
|
||||
Path file = configuration("spigot.yml", "settings:\n unrelated: retained\n");
|
||||
try (MockedStatic<IrisLogging> logging = mockStatic(IrisLogging.class)) {
|
||||
ServerConfigurator.increaseKeepAliveSpigot(file, timeouts());
|
||||
assertEquals(300L, load(file).getLong(SPIGOT_KEY));
|
||||
timeouts().restore(SPIGOT_KEY);
|
||||
assertFalse(load(file).isSet(SPIGOT_KEY));
|
||||
assertEquals("retained", load(file).getString("settings.unrelated"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restorePreservesOperatorChangesAndOtherSettings() throws Exception {
|
||||
Path file = configuration("spigot.yml", "settings:\n timeout-time: 60\n");
|
||||
try (MockedStatic<IrisLogging> logging = mockStatic(IrisLogging.class)) {
|
||||
ServerConfigurator.increaseKeepAliveSpigot(file, timeouts());
|
||||
Files.writeString(file, "# Operator settings\nsettings:\n timeout-time: 90\n unrelated: retained\n");
|
||||
String changed = Files.readString(file);
|
||||
timeouts().restore(SPIGOT_KEY);
|
||||
assertEquals(changed, Files.readString(file));
|
||||
ServerConfigurator.increaseKeepAliveSpigot(file, timeouts());
|
||||
timeouts().restore(SPIGOT_KEY);
|
||||
assertEquals(90L, load(file).getLong(SPIGOT_KEY));
|
||||
assertEquals("retained", load(file).getString("settings.unrelated"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void symlinkSurvivesRaiseAndRestore() throws Exception {
|
||||
Path target = configuration("shared-spigot.yml", "settings:\n timeout-time: 60\n");
|
||||
Path link = temporaryFolder.getRoot().toPath().resolve("spigot.yml");
|
||||
Files.createSymbolicLink(link, target.getFileName());
|
||||
try (MockedStatic<IrisLogging> logging = mockStatic(IrisLogging.class)) {
|
||||
ServerConfigurator.increaseKeepAliveSpigot(link, timeouts());
|
||||
assertEquals(300L, load(target).getLong(SPIGOT_KEY));
|
||||
timeouts().restore(SPIGOT_KEY);
|
||||
assertTrue(Files.isSymbolicLink(link));
|
||||
assertEquals(60L, load(target).getLong(SPIGOT_KEY));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aLaterAdjustmentRecordsTheOperatorsNewOriginal() throws Exception {
|
||||
Path file = configuration("spigot.yml", "settings:\n timeout-time: 60\n");
|
||||
try (MockedStatic<IrisLogging> logging = mockStatic(IrisLogging.class)) {
|
||||
ServerConfigurator.increaseKeepAliveSpigot(file, timeouts());
|
||||
Files.writeString(file, "settings:\n timeout-time: 90\n");
|
||||
ServerConfigurator.increaseKeepAliveSpigot(file, timeouts());
|
||||
timeouts().restore(SPIGOT_KEY);
|
||||
assertEquals(90L, load(file).getLong(SPIGOT_KEY));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failedRecoveryWriteLeavesServerSettingsUntouched() throws Exception {
|
||||
Path file = configuration("spigot.yml", "settings:\n timeout-time: 60\n");
|
||||
Path blocked = temporaryFolder.newFile("blocked").toPath();
|
||||
ServerTimeoutConfiguration timeouts = new ServerTimeoutConfiguration(blocked.resolve("server-timeouts.json"));
|
||||
assertThrows(IOException.class, () -> timeouts.raise(file, SPIGOT_KEY, 300L));
|
||||
assertEquals(60L, load(file).getLong(SPIGOT_KEY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failedServerWriteKeepsTheOriginalRecorded() throws Exception {
|
||||
Path file = configuration("spigot.yml", "settings:\n timeout-time: 60\n");
|
||||
try (MockedStatic<ServerConfigurator> writes = mockStatic(ServerConfigurator.class, CALLS_REAL_METHODS)) {
|
||||
writes.when(() -> ServerConfigurator.writeStringAtomic(eq(file.toRealPath()), anyString()))
|
||||
.thenThrow(new IOException("blocked server write"));
|
||||
assertThrows(IOException.class, () -> timeouts().raise(file, SPIGOT_KEY, 300L));
|
||||
}
|
||||
assertEquals(60L, load(file).getLong(SPIGOT_KEY));
|
||||
assertTrue(Files.readString(recoveryFile()).contains("\"original\": 60"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void interruptedRestoreRetriesWithoutOverwritingLaterOperatorEdits() throws Exception {
|
||||
Path file = configuration("spigot.yml", "settings:\n timeout-time: 60\n");
|
||||
try (MockedStatic<IrisLogging> logging = mockStatic(IrisLogging.class)) {
|
||||
ServerConfigurator.increaseKeepAliveSpigot(file, timeouts());
|
||||
try (MockedStatic<ServerConfigurator> writes = mockStatic(ServerConfigurator.class, CALLS_REAL_METHODS)) {
|
||||
writes.when(() -> ServerConfigurator.writeStringAtomic(eq(recoveryFile()), anyString()))
|
||||
.thenThrow(new IOException("interrupted recovery write"));
|
||||
assertThrows(IOException.class, () -> timeouts().restore(SPIGOT_KEY));
|
||||
}
|
||||
assertTrue(Files.readString(recoveryFile()).contains("spigot.yml"));
|
||||
Files.writeString(file, "settings:\n timeout-time: 120\n");
|
||||
timeouts().restore(SPIGOT_KEY);
|
||||
assertEquals(120L, load(file).getLong(SPIGOT_KEY));
|
||||
assertFalse(Files.readString(recoveryFile()).contains("spigot.yml"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void recordForADeletedFileIsDropped() throws Exception {
|
||||
Path file = configuration("spigot.yml", "settings:\n timeout-time: 60\n");
|
||||
try (MockedStatic<IrisLogging> logging = mockStatic(IrisLogging.class)) {
|
||||
ServerConfigurator.increaseKeepAliveSpigot(file, timeouts());
|
||||
Files.delete(file);
|
||||
timeouts().restore(SPIGOT_KEY);
|
||||
assertFalse(Files.readString(recoveryFile()).contains("spigot.yml"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void malformedRecoveryDataPreventsNewConfigurationWrites() throws Exception {
|
||||
Path file = configuration("spigot.yml", "settings:\n timeout-time: 60\n");
|
||||
Files.writeString(recoveryFile(), "{invalid");
|
||||
assertThrows(IOException.class, () -> timeouts().raise(file, SPIGOT_KEY, 300L));
|
||||
assertEquals(60L, load(file).getLong(SPIGOT_KEY));
|
||||
assertEquals("{invalid", Files.readString(recoveryFile()));
|
||||
}
|
||||
|
||||
private Path configuration(String name, String content) throws IOException {
|
||||
Path file = temporaryFolder.newFile(name).toPath();
|
||||
Files.writeString(file, content);
|
||||
return file;
|
||||
}
|
||||
|
||||
private ServerTimeoutConfiguration timeouts() {
|
||||
return new ServerTimeoutConfiguration(recoveryFile());
|
||||
}
|
||||
|
||||
private Path recoveryFile() {
|
||||
return temporaryFolder.getRoot().toPath().resolve("server-timeouts.json");
|
||||
}
|
||||
|
||||
private static YamlConfiguration load(Path file) throws Exception {
|
||||
YamlConfiguration configuration = new YamlConfiguration();
|
||||
configuration.load(file.toFile());
|
||||
return configuration;
|
||||
}
|
||||
}
|
||||
@@ -67,12 +67,26 @@ public class IrisWorldRemovalServiceTest {
|
||||
assertTrue(result.succeeded());
|
||||
assertTrue(result.registryChanged());
|
||||
assertEquals(
|
||||
List.of("resolve", "begin", "evacuate", "unload", "close", "unregister", "unregisterRegistry", "end"),
|
||||
List.of("resolve", "evacuate", "begin", "unload", "close", "unregister", "unregisterRegistry", "end"),
|
||||
backend.operations
|
||||
);
|
||||
assertTrue(coordinator.isIdle());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mantleBypassMaintenanceStartsOnlyAfterPlayersLeave() throws Exception {
|
||||
LifecycleOperationCoordinator coordinator = new LifecycleOperationCoordinator();
|
||||
FakeBackend backend = new FakeBackend(target("evacuation-failed"));
|
||||
backend.evacuation = CompletableFuture.failedFuture(new IllegalStateException("no destination world"));
|
||||
IrisWorldRemovalService service = new IrisWorldRemovalService(coordinator, backend);
|
||||
|
||||
IrisWorldRemovalService.RemovalResult result = service.remove("evacuation-failed", true).join();
|
||||
|
||||
assertEquals(IrisWorldRemovalService.RemovalStatus.TELEPORT_FAILED, result.status());
|
||||
assertEquals(List.of("resolve", "evacuate"), backend.operations);
|
||||
assertTrue(coordinator.isIdle());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configurationFailureStopsBeforeDeletionAndRetainsCause() throws Exception {
|
||||
LifecycleOperationCoordinator coordinator = new LifecycleOperationCoordinator();
|
||||
|
||||
+32
-4
@@ -22,12 +22,37 @@ public class StudioOpenCoordinatorCloseSequenceTest {
|
||||
|
||||
StudioOpenCoordinator.sequenceStudioClose(
|
||||
() -> phase(phases, "evacuate"),
|
||||
() -> phases.add("maintenance"),
|
||||
() -> phase(phases, "unload"),
|
||||
() -> phase(phases, "close-generator"),
|
||||
() -> phase(phases, "delete-folders")
|
||||
).join();
|
||||
|
||||
assertEquals(List.of("evacuate", "unload", "close-generator", "delete-folders"), phases);
|
||||
assertEquals(List.of("evacuate", "maintenance", "unload", "close-generator", "delete-folders"), phases);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void evacuationFailureNeverEntersMaintenance() {
|
||||
ArrayList<String> phases = new ArrayList<>();
|
||||
IllegalStateException failure = new IllegalStateException("evacuation failed");
|
||||
|
||||
try {
|
||||
StudioOpenCoordinator.sequenceStudioClose(
|
||||
() -> {
|
||||
phases.add("evacuate");
|
||||
return CompletableFuture.failedFuture(failure);
|
||||
},
|
||||
() -> phases.add("maintenance"),
|
||||
() -> phase(phases, "unload"),
|
||||
() -> phase(phases, "close-generator"),
|
||||
() -> phase(phases, "delete-folders")
|
||||
).join();
|
||||
fail("Expected evacuation failure");
|
||||
} catch (CompletionException exception) {
|
||||
assertSame(failure, exception.getCause());
|
||||
}
|
||||
|
||||
assertEquals(List.of("evacuate"), phases);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -38,6 +63,7 @@ public class StudioOpenCoordinatorCloseSequenceTest {
|
||||
try {
|
||||
StudioOpenCoordinator.sequenceStudioClose(
|
||||
() -> phase(phases, "evacuate"),
|
||||
() -> phases.add("maintenance"),
|
||||
() -> {
|
||||
phases.add("unload");
|
||||
return CompletableFuture.failedFuture(failure);
|
||||
@@ -50,7 +76,7 @@ public class StudioOpenCoordinatorCloseSequenceTest {
|
||||
assertSame(failure, exception.getCause());
|
||||
}
|
||||
|
||||
assertEquals(List.of("evacuate", "unload"), phases);
|
||||
assertEquals(List.of("evacuate", "maintenance", "unload"), phases);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -61,6 +87,7 @@ public class StudioOpenCoordinatorCloseSequenceTest {
|
||||
try {
|
||||
StudioOpenCoordinator.sequenceStudioClose(
|
||||
() -> phase(phases, "evacuate"),
|
||||
() -> phases.add("maintenance"),
|
||||
() -> phase(phases, "unload"),
|
||||
() -> {
|
||||
phases.add("close-generator");
|
||||
@@ -73,7 +100,7 @@ public class StudioOpenCoordinatorCloseSequenceTest {
|
||||
assertSame(failure, exception.getCause());
|
||||
}
|
||||
|
||||
assertEquals(List.of("evacuate", "unload", "close-generator"), phases);
|
||||
assertEquals(List.of("evacuate", "maintenance", "unload", "close-generator"), phases);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,6 +111,7 @@ public class StudioOpenCoordinatorCloseSequenceTest {
|
||||
|
||||
CompletableFuture<Void> close = StudioOpenCoordinator.sequenceStudioClose(
|
||||
() -> phase(phases, "evacuate"),
|
||||
() -> phases.add("maintenance"),
|
||||
() -> {
|
||||
phases.add("unload");
|
||||
return unload;
|
||||
@@ -100,7 +128,7 @@ public class StudioOpenCoordinatorCloseSequenceTest {
|
||||
} catch (CompletionException exception) {
|
||||
assertEquals("Studio close stopped after its terminal timeout.", exception.getCause().getMessage());
|
||||
}
|
||||
assertEquals(List.of("evacuate", "unload"), phases);
|
||||
assertEquals(List.of("evacuate", "maintenance", "unload"), phases);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package art.arcane.iris.engine;
|
||||
|
||||
import art.arcane.iris.core.nms.INMS;
|
||||
import art.arcane.iris.core.nms.INMSBinding;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import org.bukkit.Chunk;
|
||||
import org.junit.Test;
|
||||
import org.mockito.MockedStatic;
|
||||
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.mockito.Mockito.CALLS_REAL_METHODS;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.mockStatic;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class IrisWorldManagerNativePoiTest {
|
||||
@Test
|
||||
public void chunkLoadReconcilesPoisWithoutAnOptionalCleanupExecutor() {
|
||||
IrisWorldManager manager = mock(IrisWorldManager.class, CALLS_REAL_METHODS);
|
||||
Engine engine = mock(Engine.class);
|
||||
Chunk chunk = mock(Chunk.class);
|
||||
INMSBinding binding = mock(INMSBinding.class);
|
||||
when(manager.getEngine()).thenReturn(engine);
|
||||
|
||||
try (MockedStatic<INMS> nms = mockStatic(INMS.class)) {
|
||||
nms.when(INMS::get).thenReturn(binding);
|
||||
manager.onChunkLoad(chunk, false);
|
||||
}
|
||||
|
||||
verify(binding).reconcileNativeStructurePois(chunk);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void chunkLoadPropagatesPoiFailuresToTheRuntimeEventReporter() {
|
||||
IrisWorldManager manager = mock(IrisWorldManager.class, CALLS_REAL_METHODS);
|
||||
Engine engine = mock(Engine.class);
|
||||
Chunk chunk = mock(Chunk.class);
|
||||
INMSBinding binding = mock(INMSBinding.class);
|
||||
IllegalStateException failure = new IllegalStateException("Native POI storage failure");
|
||||
when(manager.getEngine()).thenReturn(engine);
|
||||
doThrow(failure).when(binding).reconcileNativeStructurePois(chunk);
|
||||
|
||||
try (MockedStatic<INMS> nms = mockStatic(INMS.class)) {
|
||||
nms.when(INMS::get).thenReturn(binding);
|
||||
assertSame(failure, assertThrows(IllegalStateException.class,
|
||||
() -> manager.onChunkLoad(chunk, true)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package art.arcane.iris.platform.bukkit;
|
||||
|
||||
import art.arcane.iris.spi.PlatformBiome;
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BukkitBiomeTest {
|
||||
private Class<?> biomeType;
|
||||
private Method wrap;
|
||||
|
||||
@Before
|
||||
public void loadAdapterWithoutServerRegistryInitialization() throws Exception {
|
||||
ClassLoader loader = new BiomeClassLoader();
|
||||
biomeType = loader.loadClass("org.bukkit.block.Biome");
|
||||
wrap = loader.loadClass(BukkitBiome.class.getName()).getMethod("of", biomeType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cachedHandlesKeepCanonicalIdentityWithoutReadingTheKeyAgain() throws Exception {
|
||||
AtomicInteger keyReads = new AtomicInteger();
|
||||
Object biome = biome("iris", "riverbank", keyReads);
|
||||
|
||||
PlatformBiome wrapped = wrap(biome);
|
||||
assertEquals("iris:riverbank", wrapped.key());
|
||||
assertEquals("iris", wrapped.namespace());
|
||||
assertSame(biome, wrapped.nativeHandle());
|
||||
assertSame(wrapped, wrap(biome));
|
||||
assertSame(wrapped, wrap(biome));
|
||||
assertEquals(1, keyReads.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replacementRegistryHandleCannotReturnThePreviousNativeBiome() throws Exception {
|
||||
Object previous = biome("iris", "registry_replacement", new AtomicInteger());
|
||||
Object replacement = biome("iris", "registry_replacement", new AtomicInteger());
|
||||
|
||||
PlatformBiome oldHandle = wrap(previous);
|
||||
PlatformBiome newHandle = wrap(replacement);
|
||||
|
||||
assertNotSame(oldHandle, newHandle);
|
||||
assertEquals(oldHandle.key(), newHandle.key());
|
||||
assertSame(previous, oldHandle.nativeHandle());
|
||||
assertSame(replacement, newHandle.nativeHandle());
|
||||
assertSame(newHandle, wrap(replacement));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customAndVanillaNamespacesRemainDistinct() throws Exception {
|
||||
PlatformBiome vanilla = wrap(biome("minecraft", "plains", new AtomicInteger()));
|
||||
PlatformBiome custom = wrap(biome("iris", "plains", new AtomicInteger()));
|
||||
|
||||
assertEquals("minecraft:plains", vanilla.key());
|
||||
assertEquals("minecraft", vanilla.namespace());
|
||||
assertEquals("iris:plains", custom.key());
|
||||
assertNotSame(vanilla, custom);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cacheEvictionPreservesBiomeKeysAndNativeHandles() throws Exception {
|
||||
Object retained = biome("iris", "retained", new AtomicInteger());
|
||||
PlatformBiome original = wrap(retained);
|
||||
for (int index = 0; index < 8_192; index++) {
|
||||
wrap(biome("iris", "eviction_" + index, new AtomicInteger()));
|
||||
}
|
||||
Field field = wrap.getDeclaringClass().getDeclaredField("CACHE");
|
||||
field.setAccessible(true);
|
||||
Cache<?, ?> cache = (Cache<?, ?>) field.get(null);
|
||||
cache.cleanUp();
|
||||
|
||||
assertTrue(cache.estimatedSize() <= 4_096);
|
||||
PlatformBiome restored = wrap(retained);
|
||||
assertEquals(original.key(), restored.key());
|
||||
assertEquals(original.namespace(), restored.namespace());
|
||||
assertSame(retained, restored.nativeHandle());
|
||||
}
|
||||
|
||||
private PlatformBiome wrap(Object biome) throws Exception {
|
||||
return (PlatformBiome) wrap.invoke(null, biome);
|
||||
}
|
||||
|
||||
private Object biome(String namespace, String name, AtomicInteger keyReads) {
|
||||
NamespacedKey key = new NamespacedKey(namespace, name);
|
||||
return Proxy.newProxyInstance(biomeType.getClassLoader(), new Class<?>[]{biomeType}, (proxy, method, arguments) -> switch (method.getName()) {
|
||||
case "getKey" -> {
|
||||
keyReads.incrementAndGet();
|
||||
yield key;
|
||||
}
|
||||
case "hashCode" -> System.identityHashCode(proxy);
|
||||
case "equals" -> proxy == arguments[0];
|
||||
case "toString" -> key.toString();
|
||||
default -> throw new UnsupportedOperationException(method.getName());
|
||||
});
|
||||
}
|
||||
|
||||
private static final class BiomeClassLoader extends ClassLoader {
|
||||
private BiomeClassLoader() {
|
||||
super(BukkitBiomeTest.class.getClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||
if (!name.equals("org.bukkit.block.Biome") && !name.equals(BukkitBiome.class.getName())) {
|
||||
return super.loadClass(name, resolve);
|
||||
}
|
||||
synchronized (getClassLoadingLock(name)) {
|
||||
Class<?> loaded = findLoadedClass(name);
|
||||
if (loaded == null) {
|
||||
try (InputStream source = getParent().getResourceAsStream(name.replace('.', '/') + ".class")) {
|
||||
if (source == null) {
|
||||
throw new ClassNotFoundException(name);
|
||||
}
|
||||
byte[] bytecode = source.readAllBytes();
|
||||
if (name.equals("org.bukkit.block.Biome")) {
|
||||
ClassWriter writer = new ClassWriter(0);
|
||||
new ClassReader(bytecode).accept(new ClassVisitor(Opcodes.ASM9, writer) {
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String method, String descriptor, String signature, String[] exceptions) {
|
||||
return method.equals("<clinit>") ? null : super.visitMethod(access, method, descriptor, signature, exceptions);
|
||||
}
|
||||
}, 0);
|
||||
bytecode = writer.toByteArray();
|
||||
}
|
||||
loaded = defineClass(name, bytecode, 0, bytecode.length);
|
||||
} catch (IOException exception) {
|
||||
throw new ClassNotFoundException(name, exception);
|
||||
}
|
||||
}
|
||||
if (resolve) {
|
||||
resolveClass(loaded);
|
||||
}
|
||||
return loaded;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user