From 1057f32b344555800fe676451e2b64a33b3af9bb Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Mon, 16 Aug 2021 17:50:50 -0400 Subject: [PATCH] Tweaks --- .../volmit/iris/core/project/IrisPack.java | 40 +++++++++++++ .../volmit/iris/core/tools/IrisToolbelt.java | 59 +++++++------------ 2 files changed, 60 insertions(+), 39 deletions(-) create mode 100644 src/main/java/com/volmit/iris/core/project/IrisPack.java diff --git a/src/main/java/com/volmit/iris/core/project/IrisPack.java b/src/main/java/com/volmit/iris/core/project/IrisPack.java new file mode 100644 index 000000000..b907103d6 --- /dev/null +++ b/src/main/java/com/volmit/iris/core/project/IrisPack.java @@ -0,0 +1,40 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.core.project; + +import com.volmit.iris.core.project.loader.IrisData; +import com.volmit.iris.engine.object.dimensional.IrisDimension; +import lombok.Data; + +import java.io.File; + +@Data +public class IrisPack { + private final File folder; + + public IrisPack(File folder) + { + this.folder = folder; + } + + public String getName() + { + return getFolder().getName(); + } +} diff --git a/src/main/java/com/volmit/iris/core/tools/IrisToolbelt.java b/src/main/java/com/volmit/iris/core/tools/IrisToolbelt.java index 9696b6163..f339590bd 100644 --- a/src/main/java/com/volmit/iris/core/tools/IrisToolbelt.java +++ b/src/main/java/com/volmit/iris/core/tools/IrisToolbelt.java @@ -185,54 +185,35 @@ public class IrisToolbelt { /** * Attempts to ensure that the pack is installed * @param sender the sender - * @param dimension the dimension key - * @param force force install even if it already exists + * @param url the dimension * @throws Throwable shit happens */ - public static void ensureInstalled(VolmitSender sender, String dimension, boolean force) throws Throwable { - IrisProjectRepo r = IrisProjectRepo.from(dimension); + public static void install(VolmitSender sender, String url) throws Throwable { + IrisProjectRepo r = IrisProjectRepo.from(url); if(r != null) { - dimension = r.getRepo(); - } - - File f = Iris.instance.getDataFolder("packs", dimension); - - if(f.exists() && force) - { - IO.delete(f); + url = r.getRepo(); } + File f = Iris.instance.getDataFolder("packs", url); + IO.delete(f); KList j = new KList<>(); + File pack = new File(Iris.getTemp(), UUID.nameUUIDFromBytes(r.toURL().getBytes(StandardCharsets.UTF_8)) + ".zip"); + j.add(new DownloadJob(r.toURL(), pack)); + j.add(new SingleJob("Extracting", () -> { + File work = new File(Iris.getTemp(), "dltk-" + UUID.randomUUID()); + ZipUtil.unpack(pack, work); + File raw = work.listFiles()[0]; + try { + FileUtils.copyDirectory(raw, f); + } catch (IOException e) { + e.printStackTrace(); + } + })); - if(!f.exists()) - { - File pack = new File(Iris.getTemp(), UUID.nameUUIDFromBytes(r.toURL().getBytes(StandardCharsets.UTF_8)) + ".zip"); - j.add(new DownloadJob(r.toURL(), pack)); - j.add(new SingleJob("Extracting", () -> { - File work = new File(Iris.getTemp(), "dltk-" + UUID.randomUUID()); - ZipUtil.unpack(pack, work); - File raw = work.listFiles()[0]; - try { - FileUtils.copyDirectory(raw, f); - } catch (IOException e) { - e.printStackTrace(); - } - })); - } - - if(j.isNotEmpty()) - { - JobCollection c = new JobCollection("Pack", j); - c.execute(sender); - } - } - - public static void download(VolmitSender sender, IrisProjectRepo repository) - { - String url = repository.toURL(); - Iris.info("Downmload"); + JobCollection c = new JobCollection("Pack", j); + c.execute(sender); } /**