mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +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
@@ -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