mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Bring back /iris std hotload and let studio commands find the studio you are in
- /iris std hotload (aliases reload, h) hotloads the studio you stand in, else the open studio. A pack file that does not parse stops it, the same way it stops the file watcher, and the sender sees which file. - modules, version, update, pkg, profile and importvanilla take an optional dim=<pack>. Without it they use the Iris world you stand in, else the open studio. The silent fall back to the "default" pack is gone. - map and imagemap fall back to the open studio's world from the console or a vanilla world. - The studio map link is printed only when the Studio window could not open.
This commit is contained in:
1 parent
e51f1b8c62
commit
1b08857bb8
8 files changed
+167
-39
No files matched your search
+109
-24
@@ -20,6 +20,7 @@ package art.arcane.iris.core.commands;
|
||||
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.platform.bukkit.BukkitPlatform;
|
||||
import art.arcane.iris.platform.bukkit.BukkitWorldBinding;
|
||||
import art.arcane.iris.core.IrisSettings;
|
||||
import art.arcane.iris.core.gui.ImageMapStudioGUI;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
@@ -129,23 +130,23 @@ public class CommandStudio implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Import vanilla trees, mushrooms & objects from the server into a pack's objects/vanilla folder", descriptionKey = "iris.director.commandstudio.director.import_vanilla_trees_mushrooms_objects_structures_jigsaw_from_server_into_pack_s", aliases = {"importv", "iv"}, origin = DirectorOrigin.BOTH)
|
||||
public void importvanilla(
|
||||
@Param(description = "The dimension pack to import vanilla content into", descriptionKey = "iris.director.commandstudio.param.dimension_pack_import_vanilla_content_into", aliases = {"pack", "dim"}, customHandler = DimensionHandler.class)
|
||||
@Param(defaultValue = "null", description = "The dimension pack to import vanilla content into", descriptionKey = "iris.director.commandstudio.param.dimension_pack_import_vanilla_content_into", aliases = {"pack", "dim"}, customHandler = NullableDimensionHandler.class)
|
||||
IrisDimension dimension,
|
||||
@Param(description = "How many variants to capture per tree/object feature", descriptionKey = "iris.director.commandstudio.param.how_many_variants_capture_per_tree_object_feature", defaultValue = "3")
|
||||
int variants
|
||||
) {
|
||||
if (dimension == null) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_PROVIDE_DIMENSION_PACK_IRIS_STD_IMPORTVANILLA_PACK_DIMENSION));
|
||||
IrisDimension pack = namedOrCurrentPack(dimension);
|
||||
if (pack == null) {
|
||||
return;
|
||||
}
|
||||
IrisData data = dimension.getLoader();
|
||||
IrisData data = pack.getLoader();
|
||||
if (data == null) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_COULD_NOT_RESOLVE_PACK_DIMENSION, MessageArgument.untrusted("value", dimension.getLoadKey())));
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_COULD_NOT_RESOLVE_PACK_DIMENSION, MessageArgument.untrusted("value", pack.getLoadKey())));
|
||||
return;
|
||||
}
|
||||
|
||||
VolmitSender sender = sender();
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_STUDIO_IMPORTING_VANILLA_CONTENT_INTO, MessageArgument.untrusted("value", dimension.getLoadKey())));
|
||||
sender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_STUDIO_IMPORTING_VANILLA_CONTENT_INTO, MessageArgument.untrusted("value", pack.getLoadKey())));
|
||||
|
||||
FeatureImporter.Report features = FeatureImporter.importAllObjectFeatures(data, variants, sender);
|
||||
|
||||
@@ -214,6 +215,28 @@ public class CommandStudio implements DirectorExecutor {
|
||||
}));
|
||||
}
|
||||
|
||||
@Director(description = "Hotload the studio you are in", descriptionKey = "iris.director.commandstudio.director.hotload_studio", aliases = {"reload", "h"})
|
||||
public void hotload() {
|
||||
VolmitSender commandSender = sender();
|
||||
PlatformChunkGenerator studio = currentStudio();
|
||||
if (studio == null || studio.getEngine() == null) {
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_STUDIO_NO_OPEN_STUDIO_PROJECTS));
|
||||
return;
|
||||
}
|
||||
|
||||
String pack = studio.getEngine().getDimension().getLoadKey();
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_STUDIO_HOTLOADING, MessageArgument.untrusted("value", pack)));
|
||||
studio.hotloadOnRequest().whenComplete((ignored, failure) -> J.s(() -> reportHotload(commandSender, pack, failure)));
|
||||
}
|
||||
|
||||
private static void reportHotload(VolmitSender commandSender, String pack, Throwable failure) {
|
||||
if (failure != null) {
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_STUDIO_HOTLOAD_FAILED, MessageArgument.untrusted("value", String.valueOf(failure.getMessage()))));
|
||||
return;
|
||||
}
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_STUDIO_HOTLOADED, MessageArgument.untrusted("value", pack)));
|
||||
}
|
||||
|
||||
@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();
|
||||
@@ -253,18 +276,26 @@ public class CommandStudio implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Get the version of a pack", descriptionKey = "iris.director.commandstudio.director.get_version_pack")
|
||||
public void version(
|
||||
@Param(defaultValue = "default", description = "The dimension get the version of", descriptionKey = "iris.director.commandstudio.param.dimension_get_version", aliases = "dim", contextual = true, contextualOverride = true, customHandler = DimensionHandler.class)
|
||||
@Param(defaultValue = "null", description = "The dimension get the version of", descriptionKey = "iris.director.commandstudio.param.dimension_get_version", aliases = "dim", customHandler = NullableDimensionHandler.class)
|
||||
IrisDimension dimension
|
||||
) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_PACK_HAS_VERSION, MessageArgument.untrusted("value", dimension.getName()), MessageArgument.untrusted("value2", dimension.getVersion())));
|
||||
IrisDimension pack = namedOrCurrentPack(dimension);
|
||||
if (pack == null) {
|
||||
return;
|
||||
}
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_PACK_HAS_VERSION, MessageArgument.untrusted("value", pack.getName()), MessageArgument.untrusted("value2", pack.getVersion())));
|
||||
}
|
||||
|
||||
@Director(description = "List the modules a pack loads", descriptionKey = "iris.director.commandstudio.director.list_pack_modules")
|
||||
public void modules(
|
||||
@Param(description = "The pack to list the modules of", descriptionKey = "iris.director.commandstudio.param.dimension_list_modules", aliases = "dim", customHandler = DimensionHandler.class)
|
||||
@Param(defaultValue = "null", description = "The pack to list the modules of", descriptionKey = "iris.director.commandstudio.param.dimension_list_modules", aliases = "dim", customHandler = NullableDimensionHandler.class)
|
||||
IrisDimension dimension
|
||||
) {
|
||||
PackModulesListing.describe(dimension.getLoader()).lines().forEach(sender()::sendMessage);
|
||||
IrisDimension pack = namedOrCurrentPack(dimension);
|
||||
if (pack == null) {
|
||||
return;
|
||||
}
|
||||
PackModulesListing.describe(pack.getLoader()).lines().forEach(sender()::sendMessage);
|
||||
}
|
||||
|
||||
@Director(description = "Open the image-map studio (External GUI)", descriptionKey = "iris.director.commandstudio.director.open_image_map_studio_external_gui", aliases = {"imap"})
|
||||
@@ -279,12 +310,13 @@ public class CommandStudio implements DirectorExecutor {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_YOU_MUST_HAVE_SERVER_LAUNCHED_GUIS_ENABLED_SETTINGS));
|
||||
return;
|
||||
}
|
||||
if (!IrisToolbelt.isIrisWorld(world)) {
|
||||
World target = irisWorldOrCurrent(world);
|
||||
if (target == null) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_YOU_NEED_BE_SPECIFY_IRIS_GENERATED_WORLD));
|
||||
return;
|
||||
}
|
||||
|
||||
Engine activeEngine = IrisToolbelt.access(world).getEngine();
|
||||
Engine activeEngine = IrisToolbelt.access(target).getEngine();
|
||||
ImageMapStudioGUI.launch(activeEngine);
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_OPENING_IMAGE_MAP_STUDIO));
|
||||
}
|
||||
@@ -406,18 +438,20 @@ public class CommandStudio implements DirectorExecutor {
|
||||
@Param(name = "world", description = "The world to open the generator for", descriptionKey = "iris.director.commandstudio.param.world_open_generator", contextual = true, contextualOverride = true)
|
||||
World world
|
||||
) {
|
||||
if (!IrisToolbelt.isIrisWorld(world)) {
|
||||
World target = irisWorldOrCurrent(world);
|
||||
if (target == null) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_YOU_NEED_BE_SPECIFY_IRIS_GENERATED_WORLD));
|
||||
return;
|
||||
}
|
||||
|
||||
UUID openerId = sender().isPlayer() ? player().getUniqueId() : null;
|
||||
PlatformChunkGenerator generator = IrisToolbelt.access(world);
|
||||
PlatformChunkGenerator generator = IrisToolbelt.access(target);
|
||||
try {
|
||||
StudioBridge bridge = StudioBridges.open(world.getName(), generator::getEngine, openerId);
|
||||
StudioWindow.show(bridge);
|
||||
sender().sendMessage(IrisLanguage.text(IrisMessages.STUDIO_MAP_READY,
|
||||
MessageArgument.untrusted("world", world.getName()), MessageArgument.untrusted("link", bridge.link())));
|
||||
StudioBridge bridge = StudioBridges.open(target.getName(), generator::getEngine, openerId);
|
||||
if (!StudioWindow.show(bridge)) {
|
||||
sender().sendMessage(IrisLanguage.text(IrisMessages.STUDIO_MAP_READY,
|
||||
MessageArgument.untrusted("world", target.getName()), MessageArgument.untrusted("link", bridge.link())));
|
||||
}
|
||||
} catch (IOException error) {
|
||||
sender().sendMessage(IrisLanguage.text(IrisMessages.STUDIO_MAP_FAILED, MessageArgument.untrusted("value", String.valueOf(error.getMessage()))));
|
||||
}
|
||||
@@ -425,19 +459,27 @@ public class CommandStudio implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Package a dimension into a compressed format", descriptionKey = "iris.director.commandstudio.director.package_dimension_into_compressed_format", aliases = "package")
|
||||
public void pkg(
|
||||
@Param(name = "dimension", description = "The dimension pack to compress", descriptionKey = "iris.director.commandstudio.param.dimension_pack_compress", contextual = true, contextualOverride = true, defaultValue = "default", customHandler = DimensionHandler.class)
|
||||
@Param(name = "dimension", description = "The dimension pack to compress", descriptionKey = "iris.director.commandstudio.param.dimension_pack_compress", aliases = "dim", defaultValue = "null", customHandler = NullableDimensionHandler.class)
|
||||
IrisDimension dimension,
|
||||
@Param(name = "minify", description = "Whether or not to minify the pack", descriptionKey = "iris.director.commandstudio.param.whether_not_minify_pack", defaultValue = "true")
|
||||
boolean minify
|
||||
) {
|
||||
Iris.service(StudioSVC.class).compilePackage(sender(), dimension.getLoadKey(), minify);
|
||||
IrisDimension pack = namedOrCurrentPack(dimension);
|
||||
if (pack == null) {
|
||||
return;
|
||||
}
|
||||
Iris.service(StudioSVC.class).compilePackage(sender(), pack.getLoadKey(), minify);
|
||||
}
|
||||
|
||||
@Director(description = "Profiles the performance of a dimension", descriptionKey = "iris.director.commandstudio.director.profiles_performance_dimension", origin = DirectorOrigin.PLAYER)
|
||||
public void profile(
|
||||
@Param(description = "The dimension to profile", descriptionKey = "iris.director.commandstudio.param.dimension_profile", contextual = true, contextualOverride = true, defaultValue = "default", customHandler = DimensionHandler.class)
|
||||
IrisDimension dimension
|
||||
@Param(name = "dimension", description = "The dimension to profile", descriptionKey = "iris.director.commandstudio.param.dimension_profile", aliases = "dim", defaultValue = "null", customHandler = NullableDimensionHandler.class)
|
||||
IrisDimension named
|
||||
) {
|
||||
IrisDimension dimension = namedOrCurrentPack(named);
|
||||
if (dimension == null) {
|
||||
return;
|
||||
}
|
||||
// Todo: Make this more accurate
|
||||
File pack = dimension.getLoadFile().getParentFile().getParentFile();
|
||||
File report = Iris.instance.getDataFile("profile.txt");
|
||||
@@ -687,12 +729,16 @@ public class CommandStudio implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Update a pack's modules to the versions this Iris ships", descriptionKey = "iris.director.commandstudio.director.update_pack_modules")
|
||||
public void update(
|
||||
@Param(description = "The pack to update", descriptionKey = "iris.director.commandstudio.param.dimension_update_modules", contextual = true, contextualOverride = true, defaultValue = "default", customHandler = DimensionHandler.class)
|
||||
@Param(description = "The pack to update", descriptionKey = "iris.director.commandstudio.param.dimension_update_modules", aliases = "dim", defaultValue = "null", customHandler = NullableDimensionHandler.class)
|
||||
IrisDimension dimension,
|
||||
@Param(defaultValue = "false", description = "Also add every module Iris ships that the pack does not list", descriptionKey = "iris.director.commandstudio.param.force_restore_shipped_modules", aliases = "f")
|
||||
boolean force
|
||||
) {
|
||||
IrisData data = dimension.getLoader();
|
||||
IrisDimension pack = namedOrCurrentPack(dimension);
|
||||
if (pack == null) {
|
||||
return;
|
||||
}
|
||||
IrisData data = pack.getLoader();
|
||||
List<String> lines = force ? KeptModuleUpdates.restoreForPack(data) : KeptModuleUpdates.takeForPack(data);
|
||||
lines.forEach(sender()::sendMessage);
|
||||
}
|
||||
@@ -842,6 +888,45 @@ public class CommandStudio implements DirectorExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** The studio the sender stands in, else the open studio; null when no studio is open. */
|
||||
private PlatformChunkGenerator currentStudio() {
|
||||
if (sender().isPlayer() && IrisToolbelt.isStudio(world())) {
|
||||
return IrisToolbelt.access(world());
|
||||
}
|
||||
IrisProject project = Iris.service(StudioSVC.class).getActiveProject();
|
||||
return project == null ? null : project.getActiveProvider();
|
||||
}
|
||||
|
||||
/** The Iris world the sender stands in, else the open studio; null when there is neither. */
|
||||
private Engine currentIrisEngine() {
|
||||
PlatformChunkGenerator generator = sender().isPlayer() && IrisToolbelt.isIrisWorld(world())
|
||||
? IrisToolbelt.access(world())
|
||||
: currentStudio();
|
||||
return generator == null ? null : generator.getEngine();
|
||||
}
|
||||
|
||||
/** The pack named, else the current Iris world's; null after asking the sender to name one. */
|
||||
private IrisDimension namedOrCurrentPack(IrisDimension named) {
|
||||
if (named != null) {
|
||||
return named;
|
||||
}
|
||||
Engine current = currentIrisEngine();
|
||||
if (current == null) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessages.COMMAND_STUDIO_NAME_PACK_OUTSIDE_STUDIO));
|
||||
return null;
|
||||
}
|
||||
return current.getDimension();
|
||||
}
|
||||
|
||||
/** The world given when it is an Iris world, else the current Iris world; null when there is neither. */
|
||||
private World irisWorldOrCurrent(World given) {
|
||||
if (given != null && IrisToolbelt.isIrisWorld(given)) {
|
||||
return given;
|
||||
}
|
||||
Engine current = currentIrisEngine();
|
||||
return current == null ? null : BukkitWorldBinding.world(current.getWorld());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if no studio is open or the player is not in one
|
||||
*/
|
||||
|
||||
+4
-3
@@ -207,9 +207,10 @@ public final class ModdedStudioCommands {
|
||||
String worldName = level.dimension().identifier().toString();
|
||||
try {
|
||||
StudioBridge bridge = StudioBridges.open(worldName, () -> boundEngine(server, level, openerId), openerId);
|
||||
StudioWindow.show(bridge);
|
||||
IrisModdedCommands.ok(source, IrisLanguage.plain(IrisMessages.STUDIO_MAP_READY,
|
||||
MessageArgument.untrusted("world", worldName), MessageArgument.untrusted("link", bridge.link())));
|
||||
if (!StudioWindow.show(bridge)) {
|
||||
IrisModdedCommands.ok(source, IrisLanguage.plain(IrisMessages.STUDIO_MAP_READY,
|
||||
MessageArgument.untrusted("world", worldName), MessageArgument.untrusted("link", bridge.link())));
|
||||
}
|
||||
return 1;
|
||||
} catch (IOException error) {
|
||||
IrisModdedCommands.fail(source, IrisLanguage.plain(IrisMessages.STUDIO_MAP_FAILED, MessageArgument.untrusted("value", String.valueOf(error.getMessage()))));
|
||||
|
||||
@@ -36,6 +36,10 @@ public final class BukkitCommandMessages {
|
||||
public static final TextKey COMMAND_STUDIO_IMPORTVANILLA_COMPLETE_OBJECTS_STRUCTURES_WRITTEN_FAILED = text("iris.bukkit.commandstudio.importvanilla_complete_objects_structures_written_failed");
|
||||
public static final TextKey COMMAND_STUDIO_TREES_OBJECTS_ARE_UNDER_OBJECTS_VANILLA_REFERENCE_THEM_FROM_BIOME = text("iris.bukkit.commandstudio.trees_objects_are_under_objects_vanilla_reference_them_from_biome");
|
||||
public static final TextKey COMMAND_STUDIO_NO_OPEN_STUDIO_PROJECTS = text("iris.bukkit.commandstudio.no_open_studio_projects");
|
||||
public static final TextKey COMMAND_STUDIO_NAME_PACK_OUTSIDE_STUDIO = text("iris.bukkit.commandstudio.name_pack_outside_studio");
|
||||
public static final TextKey COMMAND_STUDIO_HOTLOADING = text("iris.bukkit.commandstudio.hotloading");
|
||||
public static final TextKey COMMAND_STUDIO_HOTLOADED = text("iris.bukkit.commandstudio.hotloaded");
|
||||
public static final TextKey COMMAND_STUDIO_HOTLOAD_FAILED = text("iris.bukkit.commandstudio.hotload_failed");
|
||||
public static final TextKey COMMAND_STUDIO_CLOSING_STUDIO = text("iris.bukkit.commandstudio.closing_studio");
|
||||
public static final TextKey COMMAND_STUDIO_STUDIO_CLOSE_FAILED = text("iris.bukkit.commandstudio.studio_close_failed");
|
||||
public static final TextKey COMMAND_STUDIO_STUDIO_CLOSE_FAILED_2 = text("iris.bukkit.commandstudio.studio_close_failed_2");
|
||||
|
||||
-1
@@ -136,7 +136,6 @@ public final class BukkitCommandMessagesExtended {
|
||||
public static final TextKey COMMAND_STRUCTURE_COULD_NOT_RESOLVE_PACK_DIMENSION_3 = text("iris.bukkit.commandstructure.could_not_resolve_pack_dimension_3");
|
||||
public static final TextKey COMMAND_STRUCTURE_CAPTURED_STRUCTURES_PLACE_THEM_FROM_STRUCTURES_LIST_REGENERATE_CHUNKS_DELETE = text("iris.bukkit.commandstructure.captured_structures_place_them_from_structures_list_regenerate_chunks_delete");
|
||||
public static final TextKey COMMAND_STUDIO_OPENING_STUDIO_PACK_SEED = text("iris.bukkit.commandstudio.opening_studio_pack_seed");
|
||||
public static final TextKey COMMAND_STUDIO_PROVIDE_DIMENSION_PACK_IRIS_STD_IMPORTVANILLA_PACK_DIMENSION = text("iris.bukkit.commandstudio.provide_dimension_pack_iris_std_importvanilla_pack_dimension");
|
||||
public static final TextKey COMMAND_STUDIO_COULD_NOT_RESOLVE_PACK_DIMENSION = text("iris.bukkit.commandstudio.could_not_resolve_pack_dimension");
|
||||
public static final TextKey COMMAND_STUDIO_OPENING_EDITOR_PACK = text("iris.bukkit.commandstudio.opening_editor_pack");
|
||||
public static final TextKey COMMAND_STUDIO_PACK_HAS_VERSION = text("iris.bukkit.commandstudio.pack_has_version");
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Decides whether a pack hotload may run. A hotload is skipped, logged and announced to studio clients while any
|
||||
@@ -32,16 +33,25 @@ public final class PackHotloadGuard {
|
||||
}
|
||||
|
||||
public boolean allowsHotload(Collection<File> touched) {
|
||||
Map<File, String> blocking = unreadable.recheck(touched);
|
||||
if (blocking.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
blocking.forEach(this::reportSkipped);
|
||||
return false;
|
||||
return skipReason(touched).isEmpty();
|
||||
}
|
||||
|
||||
private void reportSkipped(File file, String reason) {
|
||||
String message = "Hotload skipped, " + packFolder.toPath().relativize(file.toPath()) + ": " + reason;
|
||||
/** The first unreadable file and what is wrong with it, empty when the hotload may run. Every skip is logged and announced. */
|
||||
public Optional<String> skipReason(Collection<File> touched) {
|
||||
Map<File, String> blocking = unreadable.recheck(touched);
|
||||
List<String> unreadableFiles = blocking.entrySet().stream()
|
||||
.map(unreadableFile -> describeUnreadable(unreadableFile.getKey(), unreadableFile.getValue()))
|
||||
.toList();
|
||||
unreadableFiles.forEach(this::reportSkipped);
|
||||
return unreadableFiles.stream().findFirst();
|
||||
}
|
||||
|
||||
private String describeUnreadable(File file, String reason) {
|
||||
return packFolder.toPath().relativize(file.toPath()) + ": " + reason;
|
||||
}
|
||||
|
||||
private void reportSkipped(String unreadableFile) {
|
||||
String message = "Hotload skipped, " + unreadableFile;
|
||||
IrisLogging.warn("%s", message);
|
||||
announce(message);
|
||||
}
|
||||
|
||||
@@ -110,10 +110,12 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
private static final int LOAD_LOCKS = Runtime.getRuntime().availableProcessors() * 4;
|
||||
private static final long HOTLOAD_LOOP_DELAY_MS = 250L;
|
||||
private static final long HOTLOAD_MAINTENANCE_DELAY_MS = 4000L;
|
||||
private static final long HOTLOAD_ACQUISITION_TIMEOUT_SECONDS = 30L;
|
||||
private final GenerationStageGate loadLock;
|
||||
private final IrisWorld world;
|
||||
private final File dataLocation;
|
||||
private final String dimensionKey;
|
||||
private final PackHotloadGuard hotloadGuard;
|
||||
private final ReactiveFolder folder;
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
private final KList<BlockPopulator> populators;
|
||||
@@ -152,7 +154,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
this.studioEntryBootstrapActive = new AtomicBoolean(studio);
|
||||
this.dataLocation = dataLocation;
|
||||
this.dimensionKey = dimensionKey;
|
||||
PackHotloadGuard hotloadGuard = new PackHotloadGuard(dataLocation);
|
||||
this.hotloadGuard = new PackHotloadGuard(dataLocation);
|
||||
this.folder = PackHotloadFolder.watch(dataLocation, (created, changed, deleted) -> {
|
||||
if (hotloadGuard.allowsHotload(PackHotloadGuard.touched(created, changed))) {
|
||||
hotloadFromWatcher();
|
||||
@@ -607,7 +609,20 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
if (!shouldRunStudioHotload(isStudio(), closing, paintedStudioActive)) {
|
||||
return;
|
||||
}
|
||||
withExclusiveControlFuture(() -> getEngine().hotload(), 30L, TimeUnit.SECONDS).join();
|
||||
withExclusiveControlFuture(() -> getEngine().hotload(), HOTLOAD_ACQUISITION_TIMEOUT_SECONDS, TimeUnit.SECONDS).join();
|
||||
}
|
||||
|
||||
/** Skipped like the watcher's hotload while a pack file does not parse. */
|
||||
@Override
|
||||
public CompletableFuture<Void> hotloadOnRequest() {
|
||||
if (!shouldRunStudioHotload(isStudio(), closing, paintedStudioActive)) {
|
||||
return CompletableFuture.failedFuture(new IllegalStateException("this studio cannot hotload right now"));
|
||||
}
|
||||
Optional<String> skipReason = hotloadGuard.skipReason(List.of());
|
||||
if (skipReason.isPresent()) {
|
||||
return CompletableFuture.failedFuture(new IllegalStateException(skipReason.get()));
|
||||
}
|
||||
return withExclusiveControlFuture(() -> getEngine().hotload(), HOTLOAD_ACQUISITION_TIMEOUT_SECONDS, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,6 +49,16 @@ public interface PlatformChunkGenerator extends Hotloadable, DataProvider {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
/** A hotload someone asked for, completing when it is done or failed. */
|
||||
default CompletableFuture<Void> hotloadOnRequest() {
|
||||
try {
|
||||
hotload();
|
||||
return CompletableFuture.completedFuture(null);
|
||||
} catch (Throwable failure) {
|
||||
return CompletableFuture.failedFuture(failure);
|
||||
}
|
||||
}
|
||||
|
||||
default CompletableFuture<Void> hotloadComplexAsync(long acquisitionTimeout, TimeUnit unit) {
|
||||
if (acquisitionTimeout <= 0L) {
|
||||
throw new IllegalArgumentException("Complex hotload acquisition timeout must be positive.");
|
||||
|
||||
@@ -65,6 +65,10 @@
|
||||
"iris.bukkit.commandstudio.importvanilla_complete_objects_structures_written_failed": "§aimportvanilla complete: §f{imported}§a objects written, §f{failed}§a failed.",
|
||||
"iris.bukkit.commandstudio.trees_objects_are_under_objects_vanilla_reference_them_from_biome": "§7Trees/objects are under objects/vanilla/...; reference them from biome object placements.",
|
||||
"iris.bukkit.commandstudio.no_open_studio_projects": "§cNo open studio projects.",
|
||||
"iris.bukkit.commandstudio.name_pack_outside_studio": "§cNot in a studio. Name a pack: dim=<pack>",
|
||||
"iris.bukkit.commandstudio.hotloading": "§aHotloading §f{value}§a...",
|
||||
"iris.bukkit.commandstudio.hotloaded": "§aHotloaded §f{value}",
|
||||
"iris.bukkit.commandstudio.hotload_failed": "§cHotload failed: {value}",
|
||||
"iris.bukkit.commandstudio.closing_studio": "§eClosing studio...",
|
||||
"iris.bukkit.commandstudio.studio_close_failed": "§cStudio close failed: {value}",
|
||||
"iris.bukkit.commandstudio.studio_close_failed_2": "§cStudio close failed: {value}",
|
||||
@@ -233,7 +237,6 @@
|
||||
"iris.bukkit.commandstructure.could_not_resolve_pack_dimension_3": "§cCould not resolve the pack for dimension {value}",
|
||||
"iris.bukkit.commandstructure.captured_structures_place_them_from_structures_list_regenerate_chunks_delete": "§7Captured {value} structures. Place them from a 'structures' list and regenerate chunks. Delete a structures/*.json to re-capture it.",
|
||||
"iris.bukkit.commandstudio.opening_studio_pack_seed": "§aOpening studio for the \"{value}\" pack (seed: {seed})",
|
||||
"iris.bukkit.commandstudio.provide_dimension_pack_iris_std_importvanilla_pack_dimension": "§cProvide a dimension pack: /iris std importvanilla pack=<dimension>",
|
||||
"iris.bukkit.commandstudio.could_not_resolve_pack_dimension": "§cCould not resolve the pack for dimension {value}",
|
||||
"iris.bukkit.commandstudio.opening_editor_pack": "§aOpening {editor} for the \"{value}\" pack",
|
||||
"iris.bukkit.commandstudio.pack_has_version": "§aThe \"{value}\" pack has version: {value2}",
|
||||
@@ -745,6 +748,7 @@
|
||||
"iris.director.commandstudio.director.get_version_pack": "Get the version of a pack",
|
||||
"iris.director.commandstudio.param.dimension_get_version": "The dimension get the version of",
|
||||
"iris.director.commandstudio.director.list_pack_modules": "List the modules a pack loads",
|
||||
"iris.director.commandstudio.director.hotload_studio": "Hotload the studio you are in",
|
||||
"iris.director.commandstudio.param.dimension_list_modules": "The pack to list the modules of",
|
||||
"iris.director.commandstudio.director.show_loot_if_chest_were_right_here": "Show loot if a chest were right here",
|
||||
"iris.director.commandstudio.param.fast_insertion_items_virtual_inventory_may_cause_performance_drop": "Fast insertion of items in virtual inventory (may cause performance drop)",
|
||||
|
||||
Reference in new issue
Block a user