Revert to `.zip`

This commit is contained in:
ME1312 2021-06-28 21:59:27 -04:00
parent 1427ff04e1
commit ee82ec32a3
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
4 changed files with 13 additions and 45 deletions

View File

@ -43,18 +43,6 @@
<version>1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kamranzafar</groupId>
<artifactId>jtar</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.tukaani</groupId>
<artifactId>xz</artifactId>
<version>1.9</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

View File

@ -12,18 +12,12 @@ import net.ME1312.SubServers.Bungee.Host.SubCreator.ServerTemplate;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.SubProxy;
import org.kamranzafar.jtar.TarEntry;
import org.kamranzafar.jtar.TarOutputStream;
import org.tukaani.xz.LZMA2Options;
import org.tukaani.xz.XZOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.util.HashMap;
import static org.tukaani.xz.LZMA2Options.MODE_FAST;
import static org.tukaani.xz.XZ.CHECK_SHA256;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* External Host Template Download Packet
@ -52,26 +46,26 @@ public class PacketExDownloadTemplates implements PacketIn, PacketStreamOut {
try {
if (client.getBlockSize() < DataSize.MBB) client.tempBlockSize(DataSize.MBB);
HashMap<String, ServerTemplate> map = Util.getDespiteException(() -> Util.reflect(ExternalSubCreator.class.getDeclaredField("templates"), ((ExternalHost) client.getHandler()).getCreator()), new HashMap<>());
TarOutputStream tar = new TarOutputStream(new XZOutputStream(stream, new LZMA2Options(MODE_FAST), CHECK_SHA256));
File dir = new UniversalFile(plugin.dir, "SubServers:Templates");
ZipOutputStream zip = new ZipOutputStream(stream);
byte[] buffer = new byte[4096];
for (String file : Util.searchDirectory(dir)) {
int index = file.indexOf(File.separatorChar);
if (index != -1 && !map.containsKey(file.substring(0, index).toLowerCase())) {
tar.putNextEntry(new TarEntry(new File(dir, file), file.replace(File.separatorChar, '/')));
zip.putNextEntry(new ZipEntry(file.replace(File.separatorChar, '/')));
FileInputStream in = new FileInputStream(dir.getAbsolutePath() + File.separator + file);
int len;
while ((len = in.read(buffer)) != -1) {
tar.write(buffer, 0, len);
zip.write(buffer, 0, len);
}
in.close();
}
}
tar.close();
zip.close();
Util.isException(() -> Util.reflect(ExternalSubCreator.class.getDeclaredField("enableRT"), host.getCreator(), true));
} catch (Exception e) {

View File

@ -51,18 +51,6 @@
<version>1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kamranzafar</groupId>
<artifactId>jtar</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.tukaani</groupId>
<artifactId>xz</artifactId>
<version>1.9</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

View File

@ -9,13 +9,11 @@ import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.ExHost;
import net.ME1312.SubServers.Host.SubAPI;
import org.kamranzafar.jtar.TarEntry;
import org.kamranzafar.jtar.TarInputStream;
import org.tukaani.xz.XZInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/**
* External Host Template Download Packet
@ -48,11 +46,11 @@ public class PacketExDownloadTemplates implements PacketOut, PacketStreamIn {
try {
dir.mkdirs();
TarInputStream tar = new TarInputStream(new XZInputStream(stream));
ZipInputStream zip = new ZipInputStream(stream);
byte[] buffer = new byte[4096];
TarEntry entry;
while ((entry = tar.getNextEntry()) != null) {
ZipEntry entry;
while ((entry = zip.getNextEntry()) != null) {
File newFile = new File(dir + File.separator + entry.getName().replace('/', File.separatorChar));
if (newFile.exists()) {
if (newFile.isDirectory()) {
@ -71,12 +69,12 @@ public class PacketExDownloadTemplates implements PacketOut, PacketStreamIn {
FileOutputStream fos = new FileOutputStream(newFile);
int len;
while ((len = tar.read(buffer)) != -1) {
while ((len = zip.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
fos.close();
}
tar.close();
zip.close();
host.creator.load(true);
host.log.info.println(((first)?"":"New ") + "Remote Template Files Downloaded");