13
0

Add Schemtransfer #81

Manuell gemergt
Lixfel hat 5 Commits von schem-download nach master 2021-01-08 14:39:23 +01:00 zusammengeführt
Nur Änderungen aus Commit 8fb3f8b066 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -30,6 +30,8 @@ import org.apache.http.impl.client.HttpClients;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
@ -96,8 +98,14 @@ public class ExternalUpDownload {
name.append(schemName[i].replace("/", "-")); name.append(schemName[i].replace("/", "-"));
} }
Schematic testSchem = Schematic.getSchemFromDB(name.toString(), player.getUniqueId()); Schematic testSchem = Schematic.getSchemFromDB(name.toString(), player.getUniqueId());
byte[] schemData = new byte[zipInputStream.available()]; List<Byte> schemData = new ArrayList<>();
zipInputStream.read(schemData); 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) { if(testSchem != null) {
int i = 1; int i = 1;
while (true) { while (true) {
@ -110,7 +118,7 @@ public class ExternalUpDownload {
} }
Schematic.createSchem(name.toString(), player.getUniqueId(), "", SchematicType.Normal); Schematic.createSchem(name.toString(), player.getUniqueId(), "", SchematicType.Normal);
Schematic schem = Schematic.getSchemFromDB(name.toString(), player.getUniqueId()); 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(); zipInputStream.closeEntry();
player.sendMessage(SchematicSystem.PREFIX + "§6Die Schematic §e" + schematic.getName() + " §6wurde von WarGearWorld.net als §e" + name.toString() + " §6heruntergeladen!"); player.sendMessage(SchematicSystem.PREFIX + "§6Die Schematic §e" + schematic.getName() + " §6wurde von WarGearWorld.net als §e" + name.toString() + " §6heruntergeladen!");
} }