9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-19 15:09:18 +00:00

fix hotloading when changing kts

This commit is contained in:
Julian Krings
2025-09-21 12:13:57 +02:00
parent 258d0d3aaa
commit 21a2e4feef
4 changed files with 13 additions and 6 deletions

View File

@@ -51,6 +51,7 @@ import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
@Data @Data
public class IrisData implements ExclusionStrategy, TypeAdapterFactory { public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
@@ -99,6 +100,10 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
return dataLoaders.computeIfAbsent(dataFolder, IrisData::new); return dataLoaders.computeIfAbsent(dataFolder, IrisData::new);
} }
public static Optional<IrisData> getLoaded(File dataFolder) {
return Optional.ofNullable(dataLoaders.get(dataFolder));
}
public static void dereference() { public static void dereference() {
dataLoaders.v().forEach(IrisData::cleanupEngine); dataLoaders.v().forEach(IrisData::cleanupEngine);
} }

View File

@@ -147,8 +147,7 @@ public class StudioSVC implements IrisService {
} }
IrisData dm = IrisData.get(folder); IrisData dm = IrisData.get(folder);
dm.dump(); dm.hotloaded();
dm.clearLists();
dim = dm.getDimensionLoader().load(type); dim = dm.getDimensionLoader().load(type);
if (dim == null) { if (dim == null) {
@@ -299,7 +298,8 @@ public class StudioSVC implements IrisService {
packEntry.mkdirs(); packEntry.mkdirs();
ZipUtil.unpack(cp, packEntry); ZipUtil.unpack(cp, packEntry);
} }
IrisData.get(packEntry).hotloaded(); IrisData.getLoaded(packEntry)
.ifPresent(IrisData::hotloaded);
sender.sendMessage("Successfully Aquired " + d.getName()); sender.sendMessage("Successfully Aquired " + d.getName());
ServerConfigurator.installDataPacks(true); ServerConfigurator.installDataPacks(true);

View File

@@ -179,6 +179,8 @@ public class IO {
JsonElement json; JsonElement json;
try (FileReader reader = new FileReader(file)) { try (FileReader reader = new FileReader(file)) {
json = JsonParser.parseReader(reader); json = JsonParser.parseReader(reader);
} catch (Throwable e) {
throw new IOException("Failed to read json file " + file, e);
} }
var queue = new LinkedList<JsonElement>(); var queue = new LinkedList<JsonElement>();

View File

@@ -46,7 +46,7 @@ public class ReactiveFolder {
if (checkCycle % 3 == 0 ? fw.checkModified() : fw.checkModifiedFast()) { if (checkCycle % 3 == 0 ? fw.checkModified() : fw.checkModifiedFast()) {
for (File i : fw.getCreated()) { for (File i : fw.getCreated()) {
if (i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".js")) { if (i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".kts")) {
if (i.getPath().contains(".iris")) { if (i.getPath().contains(".iris")) {
continue; continue;
} }
@@ -62,7 +62,7 @@ public class ReactiveFolder {
continue; continue;
} }
if (i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".js")) { if (i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".kts")) {
modified = true; modified = true;
break; break;
} }
@@ -75,7 +75,7 @@ public class ReactiveFolder {
continue; continue;
} }
if (i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".js")) { if (i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".kts")) {
modified = true; modified = true;
break; break;
} }