12
0

Uncompressed schem api

Dieser Commit ist enthalten in:
Lixfel 2021-08-24 07:50:14 +02:00
Ursprung 6202a78f41
Commit c032baf879
3 geänderte Dateien mit 10 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -54,7 +54,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.GZIPInputStream;
import static com.google.common.base.Preconditions.checkNotNull;
@ -111,9 +110,9 @@ class Schematic_14 {
static Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException {
try {
if(schemFormat){
return new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(is))).read();
return new SpongeSchematicReader(new NBTInputStream(is)).read();
}else{
return new MCEditSchematicReader(new NBTInputStream(new GZIPInputStream(is))).read();
return new MCEditSchematicReader(new NBTInputStream(is)).read();
}
} catch (NullPointerException e) {
throw new NoClipboardException();

Datei anzeigen

@ -32,6 +32,7 @@ import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
import com.sk89q.worldedit.extent.clipboard.io.SchematicReader;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.registry.WorldData;
@ -47,7 +48,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.zip.GZIPInputStream;
class Schematic_8 {
private Schematic_8(){}
@ -88,9 +88,9 @@ class Schematic_8 {
static Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException {
if(schemFormat)
return new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(is))).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
return new SpongeSchematicReader(new NBTInputStream(is)).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
else
return ClipboardFormat.SCHEMATIC.getReader(is).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
return new SchematicReader(new NBTInputStream(is)).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
}
private static WorldEditPlugin getWorldEditPlugin() {

Datei anzeigen

@ -32,6 +32,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.zip.GZIPInputStream;
public class Schematic {
@ -189,7 +190,7 @@ public class Schematic {
Blob schemData = rs.getBlob("SchemData");
if(schemData == null)
throw new IOException("SchemData is null");
return schemData.getBinaryStream();
return new GZIPInputStream(schemData.getBinaryStream());
} catch (SQLException e) {
throw new IOException(e);
}
@ -205,18 +206,9 @@ public class Schematic {
}
public void loadToPlayer(Player player) throws IOException, NoClipboardException {
ResultSet rs = SQL.select("SELECT SchemData FROM Schematic WHERE SchemID = ?", schemID);
try {
rs.next();
Blob blob = rs.getBlob("SchemData");
if(blob == null)
throw new NoClipboardException();
InputStream is = blob.getBinaryStream();
VersionedRunnable.call(new VersionedRunnable(() -> Schematic_8.setPlayerClipboard(player, is, schemFormat), 8),
new VersionedRunnable(() -> Schematic_14.setPlayerClipboard(player, is, schemFormat), 14));
} catch (SQLException e) {
throw new IOException(e);
}
InputStream is = schemData();
VersionedRunnable.call(new VersionedRunnable(() -> Schematic_8.setPlayerClipboard(player, is, schemFormat), 8),
new VersionedRunnable(() -> Schematic_14.setPlayerClipboard(player, is, schemFormat), 14));
}
public void saveOldFormatFromPlayer(Player player) throws IOException, NoClipboardException {