Merge remote-tracking branch 'upstream/master' into DecreeCommands

This commit is contained in:
CocoTheOwner 2021-08-16 23:54:14 +02:00
commit ca63b412cb
3 changed files with 87 additions and 39 deletions

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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();
}
}

View File

@ -185,54 +185,35 @@ public class IrisToolbelt {
/** /**
* Attempts to ensure that the pack is installed * Attempts to ensure that the pack is installed
* @param sender the sender * @param sender the sender
* @param dimension the dimension key * @param url the dimension
* @param force force install even if it already exists
* @throws Throwable shit happens * @throws Throwable shit happens
*/ */
public static void ensureInstalled(VolmitSender sender, String dimension, boolean force) throws Throwable { public static void install(VolmitSender sender, String url) throws Throwable {
IrisProjectRepo r = IrisProjectRepo.from(dimension); IrisProjectRepo r = IrisProjectRepo.from(url);
if(r != null) if(r != null)
{ {
dimension = r.getRepo(); url = r.getRepo();
}
File f = Iris.instance.getDataFolder("packs", dimension);
if(f.exists() && force)
{
IO.delete(f);
} }
File f = Iris.instance.getDataFolder("packs", url);
IO.delete(f);
KList<Job> j = new KList<>(); KList<Job> 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()) JobCollection c = new JobCollection("Pack", j);
{ c.execute(sender);
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");
} }
/** /**

View File

@ -0,0 +1,27 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.plugin;
import org.bukkit.event.Listener;
public interface IrisService extends Listener {
void onEnable();
void onDisable();
}