mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Dim installing
This commit is contained in:
parent
b7309ccdf1
commit
32f34f1444
57
src/main/java/com/volmit/iris/core/project/IrisPack.java
Normal file
57
src/main/java/com/volmit/iris/core/project/IrisPack.java
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.Iris;
|
||||
import com.volmit.iris.core.service.StudioSVC;
|
||||
import com.volmit.iris.util.data.IrisPackRepository;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
@Data
|
||||
public class IrisPack {
|
||||
private final File folder;
|
||||
|
||||
public IrisPack(File folder)
|
||||
{
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
public void delete()
|
||||
{
|
||||
IO.delete(folder);
|
||||
folder.delete();
|
||||
}
|
||||
|
||||
public static IrisPack from(VolmitSender sender, String url) throws MalformedURLException {
|
||||
return from(sender, IrisPackRepository.from(url));
|
||||
}
|
||||
|
||||
public static IrisPack from(VolmitSender sender, IrisPackRepository repo) throws MalformedURLException {
|
||||
String name = repo.getRepo();
|
||||
String url = repo.toURL();
|
||||
repo.install(sender);
|
||||
|
||||
return new IrisPack(Iris.instance.getDataFolder(StudioSVC.WORKSPACE_NAME, repo.getRepo()));
|
||||
}
|
||||
}
|
@ -30,24 +30,12 @@ import com.volmit.iris.core.service.StudioSVC;
|
||||
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
||||
import com.volmit.iris.engine.platform.HeadlessGenerator;
|
||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.data.IrisProjectRepo;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import com.volmit.iris.util.scheduling.jobs.DownloadJob;
|
||||
import com.volmit.iris.util.scheduling.jobs.Job;
|
||||
import com.volmit.iris.util.scheduling.jobs.JobCollection;
|
||||
import com.volmit.iris.util.scheduling.jobs.SingleJob;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
import org.zeroturnaround.zip.commons.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Something you really want to wear if working on Iris. Shit gets pretty hectic down there.
|
||||
|
@ -18,12 +18,28 @@
|
||||
|
||||
package com.volmit.iris.util.data;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.service.StudioSVC;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import com.volmit.iris.util.scheduling.jobs.DownloadJob;
|
||||
import com.volmit.iris.util.scheduling.jobs.Job;
|
||||
import com.volmit.iris.util.scheduling.jobs.JobCollection;
|
||||
import com.volmit.iris.util.scheduling.jobs.SingleJob;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
import org.zeroturnaround.zip.commons.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class IrisProjectRepo {
|
||||
public class IrisPackRepository {
|
||||
@Builder.Default
|
||||
private String user = "IrisDimensions";
|
||||
|
||||
@ -36,11 +52,11 @@ public class IrisProjectRepo {
|
||||
@Builder.Default
|
||||
private String tag = "";
|
||||
|
||||
public static IrisProjectRepo from(String g) {
|
||||
public static IrisPackRepository from(String g) {
|
||||
// https://github.com/IrisDimensions/overworld
|
||||
if (g.startsWith("https://github.com/")) {
|
||||
String sub = g.split("\\Qgithub.com/\\E")[1];
|
||||
IrisProjectRepo r = IrisProjectRepo.builder()
|
||||
IrisPackRepository r = IrisPackRepository.builder()
|
||||
.user(sub.split("\\Q/\\E")[0])
|
||||
.repo(sub.split("\\Q/\\E")[1]).build();
|
||||
|
||||
@ -55,12 +71,12 @@ public class IrisProjectRepo {
|
||||
if (f.length == 1) {
|
||||
return from(g);
|
||||
} else if (f.length == 2) {
|
||||
return IrisProjectRepo.builder()
|
||||
return IrisPackRepository.builder()
|
||||
.user(f[0])
|
||||
.repo(f[1])
|
||||
.build();
|
||||
} else if (f.length >= 3) {
|
||||
IrisProjectRepo r = IrisProjectRepo.builder()
|
||||
IrisPackRepository r = IrisPackRepository.builder()
|
||||
.user(f[0])
|
||||
.repo(f[1])
|
||||
.build();
|
||||
@ -74,7 +90,7 @@ public class IrisProjectRepo {
|
||||
return r;
|
||||
}
|
||||
} else {
|
||||
return IrisProjectRepo.builder()
|
||||
return IrisPackRepository.builder()
|
||||
.user("IrisDimensions")
|
||||
.repo(g)
|
||||
.branch(g.equals("overworld") ? "stable" : "master")
|
||||
@ -91,4 +107,24 @@ public class IrisProjectRepo {
|
||||
|
||||
return "https://codeload.github.com/" + user + "/" + repo + "/zip/refs/heads/" + branch;
|
||||
}
|
||||
|
||||
public void install(VolmitSender sender) throws MalformedURLException {
|
||||
File pack = Iris.instance.getDataFolder(StudioSVC.WORKSPACE_NAME, getRepo());
|
||||
|
||||
if(!pack.exists())
|
||||
{
|
||||
File dl = new File(Iris.getTemp(), "dltk-" + UUID.randomUUID() + ".zip");
|
||||
File work = new File(Iris.getTemp(), "extk-" + UUID.randomUUID());
|
||||
new JobCollection(Form.capitalize(getRepo()),
|
||||
new DownloadJob(toURL(), pack),
|
||||
new SingleJob("Extracting", () -> ZipUtil.unpack(dl, work)),
|
||||
new SingleJob("Installing", () -> {
|
||||
try {
|
||||
FileUtils.copyDirectory(work.listFiles()[0], pack);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
})).execute(sender);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user