From 8fb3f8b0662753ea96bd01d8e67b4b69f23b409a Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 8 Jan 2021 14:07:17 +0100 Subject: [PATCH] Fixing of Big Schems --- .../schematicsystem/ExternalUpDownload.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/ExternalUpDownload.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/ExternalUpDownload.java index d7efd54..b1be11f 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/ExternalUpDownload.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/ExternalUpDownload.java @@ -30,6 +30,8 @@ import org.apache.http.impl.client.HttpClients; import org.bukkit.entity.Player; import java.io.InputStream; import java.net.URL; +import java.util.ArrayList; +import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -96,8 +98,14 @@ public class ExternalUpDownload { name.append(schemName[i].replace("/", "-")); } Schematic testSchem = Schematic.getSchemFromDB(name.toString(), player.getUniqueId()); - byte[] schemData = new byte[zipInputStream.available()]; - zipInputStream.read(schemData); + List schemData = new ArrayList<>(); + while (zipInputStream.available() == 1) { + schemData.add((byte) zipInputStream.read()); + } + byte[] bytes = new byte[schemData.size()]; + for (int i = 0; i < schemData.size(); i++) { + bytes[i] = schemData.get(i); + } if(testSchem != null) { int i = 1; while (true) { @@ -110,7 +118,7 @@ public class ExternalUpDownload { } Schematic.createSchem(name.toString(), player.getUniqueId(), "", SchematicType.Normal); Schematic schem = Schematic.getSchemFromDB(name.toString(), player.getUniqueId()); - schem.saveFromBytes(schemData, schemName[schemName.length - 1].equals("schem")); + schem.saveFromBytes(bytes, schemName[schemName.length - 1].equals("schem")); zipInputStream.closeEntry(); player.sendMessage(SchematicSystem.PREFIX + "§6Die Schematic §e" + schematic.getName() + " §6wurde von WarGearWorld.net als §e" + name.toString() + " §6heruntergeladen!"); }