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

cleanup pack installation

This commit is contained in:
Julian Krings
2025-09-17 18:02:20 +02:00
parent 00997c1902
commit d50cdfec3e
2 changed files with 16 additions and 15 deletions

View File

@@ -88,16 +88,18 @@ public class StudioSVC implements IrisService {
} }
public IrisDimension installIntoWorld(VolmitSender sender, String type, File folder) { public IrisDimension installIntoWorld(VolmitSender sender, String type, File folder) {
return installInto(sender, type, new File(folder, "iris/pack"));
}
public IrisDimension installInto(VolmitSender sender, String type, File folder) {
sender.sendMessage("Looking for Package: " + type); sender.sendMessage("Looking for Package: " + type);
File iris = new File(folder, "iris");
File irispack = new File(folder, "iris/pack");
IrisDimension dim = IrisData.loadAnyDimension(type); IrisDimension dim = IrisData.loadAnyDimension(type);
if (dim == null) { if (dim == null) {
for (File i : getWorkspaceFolder().listFiles()) { for (File i : getWorkspaceFolder().listFiles()) {
if (i.isFile() && i.getName().equals(type + ".iris")) { if (i.isFile() && i.getName().equals(type + ".iris")) {
sender.sendMessage("Found " + type + ".iris in " + WORKSPACE_NAME + " folder"); sender.sendMessage("Found " + type + ".iris in " + WORKSPACE_NAME + " folder");
ZipUtil.unpack(i, irispack); ZipUtil.unpack(i, folder);
break; break;
} }
} }
@@ -106,29 +108,29 @@ public class StudioSVC implements IrisService {
File f = new IrisProject(new File(getWorkspaceFolder(), type)).getPath(); File f = new IrisProject(new File(getWorkspaceFolder(), type)).getPath();
try { try {
FileUtils.copyDirectory(f, irispack); FileUtils.copyDirectory(f, folder);
} catch (IOException e) { } catch (IOException e) {
Iris.reportError(e); Iris.reportError(e);
} }
} }
File dimf = new File(irispack, "dimensions/" + type + ".json"); File dimensionFile = new File(folder, "dimensions/" + type + ".json");
if (!dimf.exists() || !dimf.isFile()) { if (!dimensionFile.exists() || !dimensionFile.isFile()) {
downloadSearch(sender, type, false); downloadSearch(sender, type, false);
File downloaded = getWorkspaceFolder(type); File downloaded = getWorkspaceFolder(type);
for (File i : downloaded.listFiles()) { for (File i : downloaded.listFiles()) {
if (i.isFile()) { if (i.isFile()) {
try { try {
FileUtils.copyFile(i, new File(irispack, i.getName())); FileUtils.copyFile(i, new File(folder, i.getName()));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
Iris.reportError(e); Iris.reportError(e);
} }
} else { } else {
try { try {
FileUtils.copyDirectory(i, new File(irispack, i.getName())); FileUtils.copyDirectory(i, new File(folder, i.getName()));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
Iris.reportError(e); Iris.reportError(e);
@@ -139,12 +141,14 @@ public class StudioSVC implements IrisService {
IO.delete(downloaded); IO.delete(downloaded);
} }
if (!dimf.exists() || !dimf.isFile()) { if (!dimensionFile.exists() || !dimensionFile.isFile()) {
sender.sendMessage("Can't find the " + dimf.getName() + " in the dimensions folder of this pack! Failed!"); sender.sendMessage("Can't find the " + dimensionFile.getName() + " in the dimensions folder of this pack! Failed!");
return null; return null;
} }
IrisData dm = IrisData.get(irispack); IrisData dm = IrisData.get(folder);
dm.dump();
dm.clearLists();
dim = dm.getDimensionLoader().load(type); dim = dm.getDimensionLoader().load(type);
if (dim == null) { if (dim == null) {

View File

@@ -174,11 +174,8 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
if (test != null) { if (test != null) {
Iris.warn("Looks like " + dimensionKey + " exists in " + test.getLoadFile().getPath() + " "); Iris.warn("Looks like " + dimensionKey + " exists in " + test.getLoadFile().getPath() + " ");
Iris.service(StudioSVC.class).installIntoWorld(Iris.getSender(), dimensionKey, dataLocation.getParentFile().getParentFile()); test = Iris.service(StudioSVC.class).installInto(Iris.getSender(), dimensionKey, dataLocation);
Iris.warn("Attempted to install into " + data.getDataFolder().getPath()); Iris.warn("Attempted to install into " + data.getDataFolder().getPath());
data.dump();
data.clearLists();
test = data.getDimensionLoader().load(dimensionKey);
if (test != null) { if (test != null) {
Iris.success("Woo! Patched the Engine!"); Iris.success("Woo! Patched the Engine!");